Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica syntax problem

  1. Jan 31, 2008 #1
    1. The problem statement, all variables and given/known data
    When I type
    into mathematica 6 why does it give me
    and not just
    ?


    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd
  3. Jan 31, 2008 #2

    NateTG

    User Avatar
    Science Advisor
    Homework Helper

    Could be an off-by-one. What does:
    Code (Text):

    RSolve[{a[n] == a[n - 1] + a[n - 2], a[1] == 1 && a[0] == 1}, a[n], n]
     
    give?
     
  4. Jan 31, 2008 #3
    same thing.

    Code (Text):
    {{a[n] -> Fibonacci[n] - C[2] Fibonacci[n] + C[2] LucasL[n]}}
    I think its a bug.
     
  5. Jan 31, 2008 #4

    NateTG

    User Avatar
    Science Advisor
    Homework Helper

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

    Code (Text):

    RSolve[{a[n] == a[n - 1] + a[n - 2], a[1] == 1 , a[0] == 1}, a[n], n]
     
    or
    Code (Text):

    RSolve[{a[n] == a[n - 1] + a[n - 2] &&  a[1] == 1 && a[0] == 1}, a[n], n]
     
    seem more consistent.
     
  6. Jan 31, 2008 #5
    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?
     
  7. Jan 31, 2008 #6

    EnumaElish

    User Avatar
    Science Advisor
    Homework Helper

    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])}}
     
  8. Jan 31, 2008 #7
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Mathematica syntax problem
  1. Mathematica Problem (Replies: 3)

  2. Mathematica problem (Replies: 4)

  3. Mathematica problem (Replies: 2)

Loading...