| MATH1020 Calculus II | Maple Lab 5 | |
| Sections 1-4 | Due: Tuesday, October 19, 1999. | |
| http://www.math.rpi.edu/~mitchj/math1020 | ||
In this lab, we explore the behavior of a sequence and find the root of some functions using Newton's method. Be sure to follow the lab guidelines as described on the class handouts.
> a:=sqrt(n)*(sqrt(n+1)-sqrt(n));
> A:=[seq([n,evalf(a)], n=1..25)];
> plot(A,n=1..25,style=point);
> L:=limit(a,n=infinity);
> solve(L-a=.001);
where L should be defined as the value you found in part (b).)
> Newton:=proc(f,a0,n) local i,j; global a,A,Error;
> a[0]:=evalf(a0);
> for i from 1 to n do
> a[i]:=evalf(a[i-1]-subs(x=a[i-1],f)/subs(x=a[i-1],diff(f,x)));
> od;
> A:=[seq([j,evalf(a[j])], j=0..n)]:
> Error:=[seq([j,evalf(a[j]-a[n])], j=0..n-1)]:
> plot(A,style=point);
> end;
To use this procedure to find
,
we set
f(x)=x2-5 and take a0=2, so we type
> f:=x2-5;
> Newton(f,2,6);
In this example, 6 iterations are used and the plot shows the behavior of the an's. Type
> A; Error;to see the iterates and the errors. (Type
> Digits:=20;to increase the number of digits used in evalf. You will need to rerun Newton after changing Digits to see any effect.)