{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

355w2003_lab04 - MLC Lab Visit Lab 04 Maple Mth 355(a.k.a...

Info icon This 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 , = ( ) a 0 0 = ( ) a 1 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 5 1 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));
Image of page 1

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

View Full Document Right Arrow Icon
:= gen1 z + + 1 z z 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 [ ] , 0 0 [ ] , 1 1 [ ] , 2 1 [ ] , 3 2 [ ] , 4 3 [ ] , 5 5 [ ] , 6 8 [ ] , 7 13 [ ] , 8 21 [ ] , 9 34 , , , , , , , , , , := [ ] , 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);
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);
Image of page 3

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

View Full Document Right 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 = ( ) d 2 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.
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern