[Math] How to define a recurrence relation in Maple

computer-algebra-systemsmaple

I'm new with Maple and want to define a recurrence relation. I want to 1) have Maple solve it to the explicit formula 2)have Maple output a few evaluations of it for various values of n

For example if I have $a_n=2a_{n-1}+3a_{n-2}$ with $a_0=1$ and $a_1=2$ how would I use Maple to solve for an explicit formula and output the evaluated $a_1, a_2, a_3, a_4$?

In terms of Maple commands, do I want to define a function or does a recurrence sequence have it's on "type"? I know I want to use rsolve but I haven't got the commands right. Could someone please give me an example?

EDIT: the given solutions don't seem to work if you do a second recurrence realtion, that is having $a(n)$ equal to something else and try solving it.

Best Answer

What you want is the makeproc option to rsolve.

A:= rsolve({a(n)=2*a(n-1)+3*a(n-2), a(0)=1, a(1)=2}, a(n), makeproc):

A(n);

                     1     n   3  n
                     - (-1)  + - 3 
                     4         4   

'A(n)' $ n= 1..4;

                      2, 7, 20, 61
Related Question