Maple Examples

Newton's Method

The following procedure implements Newton's method to find the root of the equation f(x)=0 correct to n decimal places, starting with an initial approximation x0.

> Newt:=proc (f,x0,n) local x; x:=x0; while f(x-0.5*0.1^n)*f(x+0.5*0.1^n)>0 do x:=x-f(x)/D(f)(x) od end:

Exercise 19 (p. 174). x^4+3*x^3-x-10=0 .

> f:=x->x^4+3*x^3-x-10:

> plot(f(x),x=-4..2);

y=x^4+3*x^3-x-10

> Newt(f,-3.2,8);

-3.206142669

> Newt(f,1.4,8);

1.375064696

> fsolve(f(x)=0);

-3.206142667, 1.375064696

Exercise 20 (p. 174). [Maple Math] .

> f:=x->x^9-x^6+2*x^4+5*x-14:

> plot(f(x),x=-2..2);

[Maple Plot]

> Newt(f,1.2,8);

[Maple Math]

> fsolve(f(x)=0);

[Maple Math]

Exercise 21 (p. 174). [Maple Math] .

> f:=x->sqrt(x^2-x+1)-2*evalf(sin(Pi*x)):

> plot(f(x),x=-2..2);

[Maple Plot]

> Newt(f,0.2,8);

[Maple Math]

> Newt(f,0.8,8);

[Maple Math]

> fsolve(f(x)=0,x=0..0.5);

[Maple Math]

> fsolve(f(x)=0,x=0.5..1);

[Maple Math]

Exercise 22 (p.174). [Maple Math] .

> f:=x->cos(x^2+1)-x^3:

> plot(f(x),x=-2..2);

[Maple Plot]

> Newt(f,0.6,8);

[Maple Math]

> fsolve(f(x)=0);

[Maple Math]