Zeros of functions with Matlab: Bisection method and fixed point iteration

Similar documents
Numerical Solution of f(x) = 0

Numerical Methods Lecture 3

1.1: The bisection method. September 2017

Finding the Roots of f(x) = 0. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Finding the Roots of f(x) = 0

NON-LINEAR ALGEBRAIC EQUATIONS Lec. 5.1: Nonlinear Equation in Single Variable

2.4 - Convergence of the Newton Method and Modified Newton Method

Lecture 8. Root finding II

MATH 3795 Lecture 13. Numerical Solution of Nonlinear Equations in R N.

INTRODUCTION TO NUMERICAL ANALYSIS

Chapter 3: Root Finding. September 26, 2005

CS 221 Lecture 9. Tuesday, 1 November 2011

APPENDIX : PARTIAL FRACTIONS

Solution of nonlinear equations

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

Homework 2 - Solutions MA/CS 375, Fall 2005

Bisection and False Position Dr. Marco A. Arocha Aug, 2014

SOLVING EQUATIONS OF ONE VARIABLE

Variable. Peter W. White Fall 2018 / Numerical Analysis. Department of Mathematics Tarleton State University

Midterm Review. Igor Yanovsky (Math 151A TA)

Root Finding: Close Methods. Bisection and False Position Dr. Marco A. Arocha Aug, 2014

Computer Applications in Engineering and Construction Programming Assignment #4 Chemical equilibrium using root-finding techniques

ECONOMICS 207 SPRING 2006 LABORATORY EXERCISE 5 KEY. 8 = 10(5x 2) = 9(3x + 8), x 50x 20 = 27x x = 92 x = 4. 8x 2 22x + 15 = 0 (2x 3)(4x 5) = 0

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

BEKG 2452 NUMERICAL METHODS Solution of Nonlinear Equations

Solutions of Equations in One Variable. Newton s Method

Lecture 10: Finite Differences for ODEs & Nonlinear Equations

Numerical Methods I Solving Nonlinear Equations

Math Introduction to Numerical Methods - Winter 2011 Homework 2 Assigned: Friday, January 14, Due: Thursday, January 27,

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Numerical Methods in Informatics

Math Numerical Analysis

Outline. Math Numerical Analysis. Intermediate Value Theorem. Lecture Notes Zeros and Roots. Joseph M. Mahaffy,

MA 8019: Numerical Analysis I Solution of Nonlinear Equations

GAMS. Loops and Conditional Statements. x 2, x < 0. write a GAMS model that calculates the value of f(x) for the following set of x values:

Root Finding Convergence Analysis

Solution Methods. Richard Lusby. Department of Management Engineering Technical University of Denmark

Optimization and Calculus

Practical Numerical Analysis: Sheet 3 Solutions

Outline. Additional Nonlinear Systems. Abstract. Finding Equilibrium Points Numerically. Newton s Method

Chapter 2 Solutions of Equations of One Variable

Lecture 7. Root finding I. 1 Introduction. 2 Graphical solution

Some MATLAB Programs and Functions. Bisection Method

Numerical Optimization

5.6 Logarithmic and Exponential Equations

More On Exponential Functions, Inverse Functions and Derivative Consequences

Numerical Methods 5633

Homework and Computer Problems for Math*2130 (W17).

STOP, a i+ 1 is the desired root. )f(a i) > 0. Else If f(a i+ 1. Set a i+1 = a i+ 1 and b i+1 = b Else Set a i+1 = a i and b i+1 = a i+ 1

Section 4.8 Anti Derivative and Indefinite Integrals 2 Lectures. Dr. Abdulla Eid. College of Science. MATHS 101: Calculus I

R x n. 2 R We simplify this algebraically, obtaining 2x n x n 1 x n x n

11.5. The Chain Rule. Introduction. Prerequisites. Learning Outcomes

MATH 350: Introduction to Computational Mathematics


Solution of Algebric & Transcendental Equations

6.4 BASIS AND DIMENSION (Review) DEF 1 Vectors v 1, v 2,, v k in a vector space V are said to form a basis for V if. (a) v 1,, v k span V and

If you need the source code from the sample solutions, copy and paste from the PDF should work. If you re having trouble, send me an .

Figure 1: Graph of y = x cos(x)

Notes 6: Polynomials in One Variable

10.3 Steepest Descent Techniques

Iterative solution methods and their rate of convergence

Math 128A: Homework 2 Solutions

TWO METHODS FOR OF EQUATIONS

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB

Quadratic and Polynomial Inequalities in one variable have look like the example below.

MATH 350: Introduction to Computational Mathematics

Application - Ray Tracing and Bézier surfaces. TANA09 Lecture 3. Error Estimate. Application - Ray tracing and Beziér surfaces.

Numerical Analysis. EE, NCKU Tien-Hao Chang (Darby Chang)

Numerical Analysis Fall. Roots: Open Methods

f(x) = 2x + 5 3x 1. f 1 (x) = x + 5 3x 2. f(x) = 102x x

Continuity. MATH 161 Calculus I. J. Robert Buchanan. Fall Department of Mathematics

Goals for This Lecture:

Solving nonlinear equations (See online notes and lecture notes for full details) 1.3: Newton s Method

Taylor Series. Math114. March 1, Department of Mathematics, University of Kentucky. Math114 Lecture 18 1/ 13

Halley s Method: A Cubically Converging. Method of Root Approximation

Section 5.5 More Integration Formula (The Substitution Method) 2 Lectures. Dr. Abdulla Eid. College of Science. MATHS 101: Calculus I

Motivation: We have already seen an example of a system of nonlinear equations when we studied Gaussian integration (p.8 of integration notes)

Continuity. Chapter 4

Numerical Methods. Root Finding

Chapter 4. Solution of a Single Nonlinear Algebraic Equation

Monday, 6 th October 2008

MAT137 - Week 12. Last lecture of the term! Next Thursday is the last day of classes, but it counts as a Monday.

1 The best of all possible worlds

Solving nonlinear equations

Homework 2 solutions

Finding Roots of Equations

Numerical Integration of Functions

15 Nonlinear Equations and Zero-Finders

Analysis III Solutions - Serie 12

Calculus. Weijiu Liu. Department of Mathematics University of Central Arkansas 201 Donaghey Avenue, Conway, AR 72035, USA

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method

Solution of Nonlinear Equations

Chapter 8: Taylor s theorem and L Hospital s rule

Physics 202 Laboratory 3. Root-Finding 1. Laboratory 3. Physics 202 Laboratory

Examination paper for TMA4215 Numerical Mathematics

OR MSc Maths Revision Course

Mathematics for Business and Economics - I. Chapter 5. Functions (Lecture 9)

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

Intro to Scientific Computing: How long does it take to find a needle in a haystack?

1. Use the properties of exponents to simplify the following expression, writing your answer with only positive exponents.

Transcription:

Zeros of functions with Matlab: Bisection method and fixed point iteration Emma Perracchione Corso di Calcolo Numerico per Ingegneria Meccanica - Matr. PARI (Univ. PD) A.A. 2017/2018, secondo semestre 20 Marzo 2018 Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 1 / 8

Remarks Introduction Finding the zeros of a function means finding: x : f ( x) = 0. In the lecture we will see two approaches: 1 bisection method, 2 fixed-point iteration. The first one is the simplest approach. It divides iteratively the searching interval into two subsets with respect to the midpoint. The second one is based on building {x k } k 1 converging to the fixed-point of an auxiliary function g(x) = x f (x). Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 2 / 8

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. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 3 / 8

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 (x) < K x [a, b]; then g has a unique fixed point x in [a, b] and {x (k) } k>1 converges to x (0) [a, b]. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 4 / 8

Matlab Built-in routines: roots, fzero and fsolve. 1 roots computes the zeros (also complex ones) of polynomials. Call it as roots(a), with a the vector of the polynomial coefficients from the coefficient of higher order to that of the constant term. 2 fzero can be called in the following way: x=fzero(fun,x0,opt) with fun specified using the symbol @. For example, f = @(x,c) sin(xˆ3/c); x0 =2; sol = fzero(f,x0,[],9), here 9 is the value of the parameter c and [] is for the options. 3 fsolve is more general since it works on systems of non linear equations. A typical call is x = fsolve(fun,x0) where fun can be specified using @. For example, x = fsolve(@myfun,[2 3 4]), where myfun is a Matlab function such as: function F = myfun(x) F = sin(x); Note that the initial point is specified as a real vector or real array. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 5 / 8

Exercises Exercise 1 Exercise Write the functions bisection.m and fixedpoint.m for computing the zeros of a functions with the bisection s method and fixed point iteration. Hint Use an exit criterion in case the methods do not converge. For the bisection method the inputs that we need are f,a,b,tol,maxiter, while fixedpoint.m requires g,x0,tol,maxiter. Fix the stopping criterion for the bisection as abs(f(c))<tol, where c is the midpoint of the k-th interval. Fix the stopping criterion for the fixed point as abs(x1-x0)<tol, where x1,x0 are two successive iterations. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 6 / 8

Exercises Exercise 2 Exercise Take the function f (x) = x 2 log(x 2 + 2) of which we want to compute its zeros. 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 determine 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. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 7 / 8

Exercises Exercise 3 Exercise Using a suitable iteration function, compare the bisection method, and the fixed point iteration method for computing the only real root of 1 = g (sinh(x) sin(x)), 2x 2 g = 9.81. Take k max = 50 and the tolerance tol = 1.e 06 for the relative error. Hint Remark that and sinh(x) = ex e x, 2 ( arsinhx = ln x + ) x 2 + 1. Emma Perracchione (CN17/18) emma.perracchione@math.unipd.it 20 Marzo 2018 8 / 8