I have the following recurrence relation: $B_j=-\frac{1}{4 j (j+n)} ((4(j+λ1-1) (j+λ1-2)+A_1) B_{j-1}+A_2 B_{j-2}+A_3 B_{j-3}+A_4 B_{j-4}),\, n>0$

with initial condition $B_0=1$. (This has arisen form the solution of an ODE with Frobenius method and $λ1$ is the first root of the indicial equation). What i want to do is to create a vector with i.e.$j=20$ elements and somehow within a Do loop compute analytically the first 20 coefficients $B_j$. I am a rookie in Mathematica and have some problems in understanding how to do it. Can anyone help?

I have already used the RSolve command but this premises to know three more initial conditions $B_1,B_2$ and $B_3$. To find these initial conditions we first have to employ the recurrence relation three times by hand. What i am aware of is to build a routine (loop) that will repeatedly calculate the coefficients for $(j,1,j_{max})$ with the only known initial condition: $B_0=1$.

Thanks for your time and appreciate your answers.

  • 3
    $\begingroup$ Consider looking at RSolve[]. $\endgroup$ Commented Jan 24, 2017 at 10:51
  • $\begingroup$ Solving Recurrence Equations tutorial in the documentation. $\endgroup$
    – Edmund
    Commented Jan 24, 2017 at 11:37
  • $\begingroup$ Are you not missing some conditions? $\endgroup$
    – zhk
    Commented Jan 24, 2017 at 12:19

1 Answer 1


As suggested by J. M., RSolve is the appropriate built-in function to use for such problems.

Deq = B[j] == -1/(j*(j + n))*((4*(j + lambda1 - 1)*(j + lambda1 - 2) +
         A1)*B[j - 1] + A2*B[j - 2] + A3*B[j - 3] + A4*B[j - 4]);
sol = RSolve[{Deq, B[0] == 1}, B[j], j];
Table[Evaluate[B[j] /. First[sol]], {j, 0, 4, 1}] // FullSimplify

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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