• Non ci sono risultati.

Zeros of functions with Matlab: Fixed point iteration

N/A
N/A
Protected

Academic year: 2021

Condividi "Zeros of functions with Matlab: Fixed point iteration"

Copied!
9
0
0

Testo completo

(1)

Zeros of functions with Matlab: Fixed point iteration

Zeros of functions with Matlab: Fixed point iteration

Emma Perracchione

Corso di Calcolo Numerico per Ingegneria Meccanica - Matr. PARI (Univ. PD)

Gli esercizi sono presi dal libro: S. De Marchi, D. Poggiali, Exercices of numerical calculus with solutions in Matlab/Octave.

A.A. 2018/2019

(2)

Materiale

Materiale

TUTTO IL MATERIALE SI TROVA AL SEGUENTE LINK E VERRA’

AGGIORNATO AD OGNI LEZIONE.

https://www.math.unipd.it/~emma/CN1819.html OPUURE VEDASI

https://elearning.unipd.it/dii/course/view.php?id=1720

(3)

Zeros of functions with Matlab: Fixed point iteration Remarks

Introduction

Finding the zeros of a function means finding:

¯

x : f (¯ x ) = 0.

We already know two approaches to solve such problem:

1

bisection method,

2

Newton.

In this lecture we will see the fixed point iteration.

It is based on building {x k } k≥1 converging to the fixed-point of an

auxiliary function g (x ) = x − f (x ).

(4)

Remarks

Bisection

Property

Given a continuous function f : [a, b] −→ R such that f (a)f (b) < 0 then

∃ ¯ x ∈ (a, b) so that f (¯ x ) = 0.

Thus, at the first step of the bisection method, we evaluate the mid point m 1 of [a, b] = [a 1 , b 1 ]. If f (m 1 )f (a) < 0 then

[a 2 , b 2 ] = [a 1 , m 1 ], else

[a 2 , b 2 ] = [m 1 , b 1 ].

We proceed in this way until a stopping criterion is satisfied, such as

f (m k ) < τ , for a fixed tolerance τ , at a certain step k.

(5)

Zeros of functions with Matlab: Fixed point iteration Remarks

Newton

Theorem (Convergence of Newton’s method)

Let f (x ) ∈ C 2 ([a, b]). Suppose f (¯ x ) = 0 and f

0

(¯ x ) 6= 0 for some

x ∈ (a, b). Then, there exists δ ∈ R, δ > 0 such that for x ¯ 0 ∈ [¯ x − δ, ¯ x + δ]

the iterations via Newton’s method x k+1 = x k − f (x k )

f 0 (x k ) , k = 1, 2, . . . , converges quadratically to ¯ x .

The main drawback is that with Newton’s method we need to start

with an initial condition sufficiently close to the zeros of functions.

(6)

Exercises

Exercise 0

Exercise

Modify the script Newton for multiple zeros. Call it NewtonMod.

Hint

The iteration becomes

x k+1 = x k − m f (x k )

f 0 (x k ) , k = 1, 2, . . . ,

where m is the multiplicity of the zero.

(7)

Zeros of functions with Matlab: Fixed point iteration Remarks

Fixed point

We want to find ¯ x so that f (¯ x ) = 0 or equivalently the fixed point of g (x ) = x , for f (x ) = x − g (x ) = 0.

Theorem

Let us consider x (k+1) = g (x (k) ), for k ≥ 0, with x (0) given. If

1

g : [a, b] → [a, b];

2

g ∈ C 1 ([a, b]);

3

∃K < 1 such that |g

0

(x )| < K ∀x ∈ [a, b];

then g has a unique fixed point ¯ x in [a, b] and {x (k) } k>1 converges to

¯

x ∈ [a, b].

(8)

Exercises

Exercise 1

Exercise

Write a Matlab function called fixedpoint for computing the zeros of functions with the fixed point iteration.

Hint

Use an exit criterion in case the method does not converge.

For the fixed point iteration the inputs that we need are g,x0,tol,maxiter.

Fix the stopping criterion for the fixed point as abs(x1-x0)<tol, where

x1,x0 are two successive iterations.

(9)

Zeros of functions with Matlab: Fixed point iteration Exercises

Exercise 2

Exercise

Take the function f (x ) = x 2 − log(x 2 + 2) of which we want to compute its zeros. Write a script called Esercizio2 so that:

By plotting the graph of f , individuates the two real roots of f (x ) = 0 and the corresponding separation intervals, I 1 e I 2 .

Find two convergent iterative methods, with iteration functions g i (x ), i = 1, 2. For each one of them determines the number of necessary iterations. Consider k max = 50, as max number of iterations and, for the test on the relative error tol = 1.e − 6.

Compare the results with the ones obtained with fzero.

Riferimenti

Documenti correlati

The main drawback is that with Newton’s method we need to start with an initial condition sufficiently close to the zeros of

For that use bisection, Newton, Aikten (alredy in your folder!) and fixed point with the iteration function g (x ) = plog(x 2 + 2). Are the convergence hypothesis for the fixed

The graphs [20] can be explained by the presence of a significant stray thermal flux (Fig. 3) in the studied TFPC, which heats the measuring junction of the TC while melting

punti che si attraggono o si respingono tra loro. Planar central configurations as fixed points. Fixed Point Theory Appl. Finiteness of relative equilibria of the four-body problem.

Analisi numerica dello stimatore Band-inverse e confronto con lo stimatore FP .... Processo autoregressivo non stazionario di ordine m:

A new energetic selective criterion is then proposed, able to predict the final state after a jump and representing intrinsically the energy contribution of rate-dependent phenomena

L’adozione di questo materiale, ancora sperimentale all’epoca della sua messa in opera, nella definizione esecutiva presenta diverse incertezze e difficoltà tecniche che si

Being f () &lt; , the origin is a source and the existence of a limit cycle is granted by the Poincaré-Bendixson theorem, while the uniqueness is given by monotonicity properties.