355w2003_lab04 - MLC Lab Visit - Lab 04 - Maple Mth 355...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
MLC Lab Visit - Lab 04 - Maple Mth 355 (a.k.a. Mth 399) Jan 29, 2003 Maple 7 Bent E. Petersen [email protected] [email protected] There are 6 problems below. Problem solutions are due Feb 5, 2003. Email your solutions to me as Maple worksheet attachments. Your worksheet must execute correctly for full credit. This worksheet contains a few comments on some of Maple’s recurrence relations support. If you find a serious error be sure to mention it in your solution report. Linear Recurrence Equations - Examples > restart; Example. Fibonacci sequence The Maple function rsolve() is used to solve linear recurrence relations. Here is an example of an order 2 recurrence relation with initial conditions. The solution is the Fibonacci sequence > eqn1:=a(n)=a(n-1)+a(n-2); := eqn1 = () a n + a n 1( ) a n 2 > init1:=a(0)=0,a(1)=1; := init1 , = a0 0 = a1 1 To solve the recurrence equation we use rsolve(). Note how we specify for which variable to solve. > soln1:=rsolve({eqn1,init1},a); := soln1 + 1 1 5 5 2 1 − + 1 5 n 1 5 1 5 51 2 1 + 1 5 n + 1 5 We can also use rsolve() to find the generating function for the solution. Note the single quotes surrounding genfunc in the following command. > gen1:=rsolve({eqn1,init1},a,’genfunc’(z));
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
:= gen1 z − + + 1 zz 2 A very nice feature of Maple is that we can even define a procedure which will compute the a(n): > fun1:=rsolve({eqn1,init1},a,’makeproc’): Let’s check it: > fun1(3); fun1(4); fun1(5); fun1(6); fun1(7); fun1(8); 2 3 5 8 13 21 The fun1() procedure can be use to plot the sequence a(n) > seq1:=seq([n,fun1(n)],n=0. .15); seq1 [] , 00 [ ] , 11 [ ] , 21 [ ] , 32 [ ] , 43 [ ] , 55 [ ] , 68 [ ] , 71 3 [ ] , 82 1 [ ] , 93 4 ,,,,,,, , , , := , 10 55 [ ] , 11 89 [ ] , 12 144 [ ] , 13 233 [ ] , 14 377 [ ] , 15 610 , ,,,, > plot([seq1],style=point,symbol=diamond,symbolsize=20,title="f un1 - Fibonacci sequence",color=blue);
Background image of page 2
If we omit the "style=point" directive Maple will produce the plot of the piecewise linear interpolation rather than the individual points: > plot([seq1],title="fun1 - Fibonacci sequence" ,color=blue, thickness=2);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
> Example. Derangements In class we obtained a recurrence equation for the number of derangements. > eqn2:=d(n)=n*d(n-1)+(-1)^n; := eqn2 = () d n + n d n 1( ) -1 n > init2:=d(2)=1; := init2 = d2 1 The initial condition just means the number of derangements of the set {1,2} is 1, which is clear. > soln2:=rsolve({eqn2,init2},d); := soln2 e -1 Γ , + n 1-1 Hmm. Maple’s response is in terms of the Incomplete Gamma function - not a familiar object to most of us.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/11/2012 for the course MTH 141, 142, taught by Professor Mcallister during the Spring '08 term at SUNY Empire State.

Page1 / 14

355w2003_lab04 - MLC Lab Visit - Lab 04 - Maple Mth 355...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online