1
LAB HOMEWORK 11/04/2016
CALCOLO NUMERICO IM MAT PARI A.A. 2015/16
FEDERICO PIAZZON1
Abstract. Madatory homeworks for the exam.
Exercise 1. Write a Matlab function ptofisso.m for the fixed point method
• Inputs: iteration function, starting point, tolerance, maximum num- ber of iterations.
• Outputs: approximated fixed point, sequence of approximations, se- quence of steps sk = xk − xk−1 (i.e. difference of two consecutive approximations).
Write a Matlab script for solving x= cos(x), more precisely:
(1) plots x andcos(x) on the same figure in the interval [−1, 1] (choose your starting point basing on this graphic)
(2) invokesptofisso.m to compute the fixed point
(3) produce another figure with the profile of convergence (i.e. |sk+1/sk|).
Exercise 2. Write a Matlab function Newton.m for the Newton method.
• Inputs: considered function f , derivative, starting point, tolerance, maximum number of iterations.
• Outputs: approximated zero of f , sequence of approximations, se- quence of steps sk = xk − xk−1 (i.e. difference of two consecutive approximations).
Write a Matlab script for solving f(x) := xn− 2= 0, more precisely define n at the beginning and:
(1) plot f in the interval[−2, 2] (choose your starting point basing on this graphic)
1Universit´a degli studi di Padova, Dipartimento di Matematica. Supported by INdAM GNCS.
Date: April 18, 2016.
Key words and phrases.
1
2 FEDERICO PIAZZON1
(2) invokesNewton.m to compute the zero
(3) produce another figure with the profile of convergence (i.e. |sk+1/sk|) (4) produce a third figure for comparing |sk| with the absolute errors
|xk− √n 2|.
Exercise 3. Write a function Newtonmod.m for the modified Newton Method.
• Inputs: considered function f , derivative, assumed multiplicity, start- ing point, tolerance, maximum number of iterations.
• Outputs: approximated zero of f , sequence of approximations, se- quence of steps sk = xk − xk−1 (i.e. difference of two consecutive approximations).
Consider the case f(x) := (x − 1) log x: implement a script (similar to the one above) to solve f(x)= 0 and present the results by some plots.
Exercise 4. Consider the equation fn(x) := (x − 1)nlog x = 0. Solve the equation (possible varying n) in the following way using a script.
• Use Newton.m (run it for few iterations) and, by the suitable for- mula, deduce an approximation m off the multiplicity of the root.
• Use Newtonmod.m passing the multiplicity m computed above to the function.
• Run Newton.m again (with enough iterations) and produce some figures for comparing the convergence profiles of the two methods.
room 712 Department of Mathematics, Universit´a di Padova, Italy. Phone +39 0498271260 E-mail address: [email protected]
URL: http://www.math.unipd.it/˜fpiazzon/teaching (work in progress)