Dr. Kevin G. TeBeest
Kettering University
Copyright © 2002−2024 Kevin G. TeBeest. All rights reserved.
After starting Maple, you must first load Maple's
"student" library of commands:
This is the case ONLY if you want to write this demo in a Maple session.
> with(student) :
Define the function f( x ) . As an example, we'll use function
>
f := x −> evalf( cos( ln(x) ) ) ;
The evalf command automatically converts the results to
floating point (decimal) form any time function f is evaluated.
Determine the derivative f '( x ) and store it AS A FUNCTION in fp (using the unapply command):
> fp := unapply( diff( f(x) , x ) , x ) ;
Plot function to determine roughly where its zero is. We'll plot it on the x interval [0,10] and restict the y range to [−1,1]:
> plot( f(x), x = 0.0 .. 10.0, −1.0 .. 1.0, thickness = 4 ) ;
We see that ONE zero of function f lies near x = 5.
Let's suppose we want to approximate that zero of f.
Also, remember to STAY AWAY from the critical
value near x = 1.5.
Although x = 5 would be an excellent starting value, to demonstrate Newton's method we'll use a starting value of x = 9.5
> x0 := 9.5 ;
FOR ILLUSTRATION PURPOSES ONLY, here we will use Maple's "showtangent" command to
automatically plot function f
(x)
and its tangent line at
x0 = 9.5 :
To obtain a clean plot, we'll restrict the
x
interval (horizontal range) to [0,10] and the
y
interval (vertical range) to [−1,1].
> showtangent( f(x), x = x0, x = 0.0 .. 10.0, −1.0 .. 1.0, thickness = 4 ) ;
Now use Newton's method to calculate x1, the first approximation to z :
> x1 := x0 − f(x0) / fp(x0) ;
FOR ILLUSTRATION PURPOSES ONLY, here we will use Maple's "showtangent" command to
automatically plot function f
(x)
and its tangent line at
x1.
To obtain a clean plot, we'll restrict the
x
interval (horizontal range) to [0,10] and the
y
interval (vertical range) to [−1,1].
> showtangent( f(x), x = x1, x = 0.0 .. 10.0, −1.0 .. 1.0, thickness = 4 ) ;
Now use Newton's method to calculate x2, the second approximation to z :
> x2 := x1 − f(x1) / fp(x1) ;
FOR ILLUSTRATION PURPOSES ONLY, here we will use Maple's "showtangent" command to
automatically plot function f
(x)
and its tangent line at
x2.
To obtain a clean plot, we'll restrict the
x
interval (horizontal range) to [0,10] and the
y
interval (vertical range) to [−1,1], or we may "zoom in" by changing these ranges.
> showtangent( f(x), x = x2, x = 0.0 .. 10.0, −1.0 .. 1.0, thickness = 4 ) ;
> x3 := x2 − f(x2) / fp(x2) ;
FOR ILLUSTRATION PURPOSES ONLY, here we will use Maple's "showtangent" command to
automatically plot function f
(x)
and its tangent line at
x3.
To obtain a clean plot, we'll restrict the
x
interval to [0,10] and the
y
interval to [−1,1], or we may "zoom in" by changing these ranges.
> showtangent( f(x), x = x3, x = 0.0 .. 10.0, −1.0 .. 1.0, thickness = 4 ) ;
We may use Maple's "fsolve" command to approximate the zero automatically. We'll search on the interval [2,8].
> correct_zero := fsolve( f(x), x = 2.0 .. 8.0 ) ;
Return to Section 1.3 assignment
Dr. Kevin G. TeBeest
Applied Mathematics
Kettering University