Approximate the Zero of f(x) = exp(–x ) – cos(x)

that lies between x=1 and x=2

Define f as a function:

> f := x -> exp(–x) – cos(x) ;

[Maple Math]

Plot f(x) on the interval [0,4]:

> plot( f(x), x = 0.0 .. 4.0 );

[Maple Plot]

Use fsolve to approximate the zero of f(x) that lies between x=1 and x=2:

> fsolve( f(x), x = 1.0 .. 2.0 ) ;

[Maple Math]

Store the result in z:

> z := fsolve( f(x), x = 1.0 .. 2.0 ) ;

[Maple Math]

Evaluate f(z) to see how close it is to 0:

> f(z);

[Maple Math]

This means –0.3 x 10–9, which is nearly 0 since, by default, Maple uses only 10 Digit arithmetic.


Return to Section 1.1

Return to course web site