Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Exercise session 5 – Nonlinear Equations

October 27, 2016

Exercise 1

Let α1 and α2 > α1 the zeros of the nonlinear equation

f (x) = x2 − x + 1 − e−x = 0 x ∈ [−2, 1].

Apply function bisection on the interval [−2, 1] with a tolerance tol = 10−12 . Which of the
two zeros of the function is obtained? How many iterations are necessary?
Compute α1 and α2 with function newton, using a tolerance tol = 10−12 and choosing
graphically the initial guess. For both the approximations of α1 and α2 , compare the number
of iterations necessary to achieve the absolute error tolerance tol with the stopping criterion
based on the absolute error. Which zero is approximated faster by the Newton method?
Why?

Exercise 2

Consider the function f (x) = e−x − a, whose only solution is x∗ = − ln(a). Using function
newton, approximate x∗ with n = 8 iterations with the stopping criterion based on the
absolute error in the following cases

(a) a = 10−4 , with initial guess x(0) = 2,

(b) a = 1, starting from x(0) = 2,

(c) a = 104 , starting from x(0) = −7.

Set the tolerance tol= 10−14 . Fill the following table

a |f 0 (x∗ )| |f (xn )| |xn − x∗ | |xn − xn−1 |


10−4
1
104

1
Analyse the results obtained, recalling that if x is sufficiently close to x∗ then

|f (x)|
|x − x∗ | ' .
|f 0 (x∗ )|

In which cases among (a), (b), and (c) would you trust the stopping criterion based on the
residual?

Exercise 3
Consider the nonlinear equation
 
  π  π 3
f (x) = arctan 7 x − + sin x− = 0 x ∈ [−1, 6]
2 2

1. Compute graphically the solution in [−1, 6].

2. Compute the zero with the newton method, se the tolerance equal to 10−10 and an
initial guess equal to x(0) = 1.5. Then try to use an initial guess x(0) = 4. Compute the
absolute error (the zero x∗ is equal to π/2). Motivate the obtained results.

3. Check if it is possible to use the bisection method. Use the Matlab function bisection
with a tolerance equal to 10−6 .

Exercise 4

Consider the nonlinear equation ex − 2x2 = 0, x ∈ [−2, 4]. Compute graphically the
number of solutions of the equation and using the MATLAB command fsolve. Compute all
the solutions of the equation using the following methods, with the appropriate values of the
input arguments

(a) bisection method,

(b) Newton method,

(c) fixed point method


(hint: rewrite the problemqas x = φ(x) using q three different iteration functions, i.e.
φ1 (x) = log(2x ), φ2 (x) = 2 e , φ3 (x) = − 12 ex . Check graphically which root each
2 1 x

iteration function will converge to, and select an appropriate initial value.)

Set the tolerance equal to 10−6 and the maximum number of iterations equal to 100.
Compare the number of iterations needed by the methods to reduce the error under the
selected tolerance.

2
Exercise 5

Consider the equation


2x2 − 3x − 2
f (x) = = 0.
x−1

(a) Compute graphically the solutions of the equation in [−3, 3],

(b) Consider the following iteration functions, i.e.

3x2 − 5x x
φ1 = φ2 = x − 2 + .
x−1 x−1
Which iteration function could be used to compute the positive solution x∗ of the equation
f (x∗ ) = 0 with the fixed point method?

(c) Approximate x∗ with the fixed point method with a tolerance equal to 10−9 , initial guess
x(0) = 1.2, and maximum number of iterations nmax = 1000.

(d) Compute x∗ with Newton method, by using a tolerance equal to 10−9 , initial guess x(0) =
1.2, and maximum number of iterations nmax = 1000.

You might also like