Mathematica Why isn't Mathematica giving me the desired output for this RSolve equation?

  • Thread starter Thread starter ehrenfest
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on an issue with Mathematica's RSolve function, where a user expects the output for a recurrence relation to simplify to just Fibonacci[n] but instead receives a more complex expression involving both Fibonacci and LucasL sequences. The problem arises when the initial conditions are set to a[1] == 1 and a[2] == 1, leading to unexpected results. Users suggest that modifying the initial conditions or using the Clear function may resolve the issue, as it appears to affect the evaluation of the function. The conversation highlights potential bugs or syntax issues in Mathematica 6, with some users achieving the desired output by adjusting their approach. Overall, the thread reflects the complexities of using RSolve in Mathematica and the importance of initial conditions in obtaining correct results.
ehrenfest
Messages
2,001
Reaction score
1

Homework Statement


When I type
RSolve[{a[n] == a[n - 1] + a[n - 2], a[1] == 1 && a[2] == 1}, a[n], n]
into mathematica 6 why does it give me
{{a[n] -> Fibonacci[n] - C[2] Fibonacci[n] + C[2] LucasL[n]}}
and not just
{{a[n] -> Fibonacci[n] }}
?


Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
Could be an off-by-one. What does:
Code:
RSolve[{a[n] == a[n - 1] + a[n - 2], a[1] == 1 && a[0] == 1}, a[n], n]
give?
 
same thing.

Code:
{{a[n] -> Fibonacci[n] - C[2] Fibonacci[n] + C[2] LucasL[n]}}

I think its a bug.
 
Hmm, is the syntax you're using correct? (I'm not a mathematica user.)

Code:
RSolve[{a[n] == a[n - 1] + a[n - 2], a[1] == 1 , a[0] == 1}, a[n], n]
or
Code:
RSolve[{a[n] == a[n - 1] + a[n - 2] &&  a[1] == 1 && a[0] == 1}, a[n], n]
seem more consistent.
 
I tried it and it just gives {{a[n] -> Fibonacci[n] }} for me. Not sure why, my mathematica knowledge isn't that great, but like you said could just be a bug?
 
In Math'ca 6.0.1.0,

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

gives

{{a[n] -> Fibonacci[n]}}

whereas

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

both give

{{a[n] -> 1/2 (Fibonacci[n] + LucasL[n])}}
 
Yes. You're right. I just did a Clear["Global`*"] and began getting the same answer as you. I am not really sure how why the Clear["Global`*"] would change the evaluation of this though...it seems like all variables should be local.
 

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
3
Views
3K
Replies
4
Views
2K
Back
Top