Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to use RSolve with indexing beginning at 0. Whenever I enter a basic command such as to solve a difference equation such as $a_{n} = 2a_{n-1} + 1$:

RSolve[a[n + 1] - 2 a[n] == 1, a[n], n]

it gives the solution

{{a[n] -> -1 + 2^n + 2^(-1 + n) C[1]}}

Which is the solution if indexing begins at 1. I am interested in finding a solution where indexing begins at 0. I know that this can be achieved by giving an initial value for x[n], however I am looking for a way to get a solution without specifying an initial value. Is this possible? Perhaps we could specify the range of values for n? Thanks.

share|improve this question

closed as off-topic by Szabolcs, rasher, Jens, RunnyKine, Oleksandr R. Jun 11 at 8:00

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
"Which is the solution if indexing begins at 1." $\leftarrow$ This is incorrect. The solution is generally valid for all integer $n$, not just positive ones. It does not require any starting index. This is usually true even if you do give an "initial" condition. The only difference will be that a constant won't appear in the solution. –  Szabolcs Jun 10 at 22:50
4  
This question appears to be off-topic because it is due to a mathematical misunderstanding. –  Szabolcs Jun 10 at 22:53
1  
You should read this reference page. You will find that the index 1 in C[1] has nothing to do with the index n in you recurrence equation, but is an artifact of Mathematica's internal book keeping. –  m_goldberg Jun 11 at 0:27

1 Answer 1

The solution provided is indefinite and requires initial condition. It applies to n=0, eg if a[0]=b, then C[1]=2b. You can simply specify your initial condition, e.g.

RSolve[{a[n + 1] - 2 a[n] == 1, a[0] == b}, a[n], n]

This yields:

{{a[n] -> -1 + 2^n + 2^n b}}

and perhaps your desired from (note I have used the recurrence I your text and not in your code).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.