0
$\begingroup$

I would be grateful if someone could help me with this problem. I define two series recursively, thus:

Subscript[f, 0][n_] := Subscript[f, 0][n - 1] + Subscript[f, 1][n - 2]
Subscript[f, 1][n_] := Subscript[f, 0][n - 1] + Subscript[f, 1][n - 1]
Subscript[f, 0][1] = 0
Subscript[f, 0][2] = 1
Subscript[f, 1][1] = 1
Subscript[f, 1][2] = 1

Mathematica lists the first few values (from index 1 on) just fine, but for some reason it can't find out the values of the two series for indices below 1. And RSolve can't figure out the closed formula for any of the series.

But this should be easy, say if $f_0(2)=f_0(1)+f_1(0)$, then $f_1(0)=f_0(2)-f_0(1)=1$. I thought Mathematica could extrapolate series like that.

$\endgroup$
  • $\begingroup$ You are setting the fs at zero and at one. The recursive relationship you're using is based on previous values. So, there is no way for Mma to calculate (for example) f1[-2] $\endgroup$ – Dr. belisarius Feb 26 '15 at 20:40
  • $\begingroup$ Yes but if I try rewording my definitions thus f₀[n_ + 2] := f₀[n + 1] + f₁[n], I get the same error… Surely there must be a way to make Mma calculate something I can calculate on a piece of paper in a few seconds. $\endgroup$ – vpprof Feb 26 '15 at 20:46
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Dr. belisarius Feb 26 '15 at 21:35
3
$\begingroup$

You can use RSolve indeed:

sol = RSolve[{f0[n] == f0[n - 1] + f1[n - 2], 
              f1[n] == f0[n - 1] + f1[n - 1], 
              f0[1] == 0, f0[2] == 1, f1[1] == 1, f1[2] == 1}, {f0, f1}, n]; 

f0[10] /. sol // N // Chop
(* {86.} *)

You can also revert your recursive relations to go upwards:

g1[n_] := g0[n + 2] - g0[n + 1]
g0[n_] := g1[n] - g1[n + 1]
g0[1] = 0
g0[2] = 1
g1[1] = 1
g1[2] = 1

g0[-10]
(*- 595*)
|improve this answer|||||
$\endgroup$
  • $\begingroup$ Hmm… it seems I rushed into marking your answer as the solution, for if I define my recursive relations to go upwards, Mma doesn't calculate values for indices greater than 2. Or are you suggesting I need to use four different series, two for indices > 2, and two for indices < 1? $\endgroup$ – vpprof Feb 26 '15 at 20:56
  • $\begingroup$ @vpprof You need to set a starting point ... from that you can calculate upwards OR downwards $\endgroup$ – Dr. belisarius Feb 26 '15 at 20:57
  • $\begingroup$ OK, that's a bit disappointing but let's forget about that for now. What about RSolve, it cannot find the closed form neither for my original f-s, nor for your g-s. What would you suggest I do to make RSolve work? $\endgroup$ – vpprof Feb 26 '15 at 21:05
  • $\begingroup$ @vpprof See edit, please $\endgroup$ – Dr. belisarius Feb 26 '15 at 21:35
  • $\begingroup$ Many thanks! For some reason, RSolve works just fine if you chuck all the equations into it, but gets bogged down when the series are defined beforehand (and keeps throwing the 'recursion depth exceeded' error). Thanks again :) $\endgroup$ – vpprof Feb 27 '15 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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