數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.

Slides:



Advertisements
Similar presentations
Lecture 5 Fixed point iteration Download fixedpoint.m From math.unm.edu/~plushnik/375.
Advertisements

Numerical Solution of Nonlinear Equations
數值方法 2008, Applied Mathematics NDHU 1 Nonlinear systems Newton’s method The steepest descent method.
Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ.
Newton’s Method finds Zeros Efficiently finds Zeros of an equation: –Solves f(x)=0 Why do we care?
Open Methods Chapter 6 The Islamic University of Gaza
ROOTS OF EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
數值方法 2008, Applied Mathematics NDHU 1 Spline interpolation.
Open Methods Chapter 6 The Islamic University of Gaza
Chapter 6 Open Methods.
Second Term 05/061 Roots of Equations Bracketing Methods.
Roots of Equations Bracketing Methods.
Dr. Marco A. Arocha Aug,  “Roots” problems occur when some function f can be written in terms of one or more dependent variables x, where the.
1.5 I understand Functions. Function For each input there is only one output Ex: Let g represent the age of a US citizen and d represent the number of.
Bracketing Methods Chapter 5 The Islamic University of Gaza
Fin500J: Mathematical Foundations in Finance Topic 3: Numerical Methods for Solving Non-linear Equations Philip H. Dybvig Reference: Numerical Methods.
- + Suppose f(x) is a continuous function of x within interval [a, b]. f(a) = - ive and f(b) = + ive There exist at least a number p in [a, b] with f(p)
The Binary Search Textbook Authors: Ken Lambert & Doug Nance PowerPoint Lecture by Dave Clausen
數值方法 2008, Applied Mathematics NDHU1  An iterative approach for root finding  Newton method Lecture 3II Root Finding.
Roots of Equations Chapter 3. Roots of Equations Also called “zeroes” of the equation –A value x such that f(x) = 0 Extremely important in applications.
數值方法 2008, Applied Mathematics NDHU 1 Simpson rule Composite Simpson rule.
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
CMPSC 200 Spring 2013 Lecture 38 November 18 or 20, 2013 (depending on section)
Chapter 6 Finding the Roots of Equations
Scientific Computing Linear and Quadratic Splines.
Concavity of a graph A function is concave upward on an interval (a, b) if the graph of the function lies above its tangent lines at each point of (a,
數值方法 2008, Applied Mathematics NDHU1  Looping for loop while loop  Break and return  Recursion Lecture 2 Iteration.
CSCI 125 & 161 Lecture 13 Martin van Bommel. Floating Point Data Floating point numbers are not exact Value 0.1 in binary is very close to 1/10, but not.
Graphics Graphics Korea University kucg.korea.ac.kr 2. Solving Equations of One Variable Korea University Computer Graphics Lab. Lee Seung Ho / Shin.
NETWONS METHOD DOING THAT JAWN I AM A BO$$ STUDENTS WILL BE ABLE TO USE NEWTON’S METHOD TO FIND THE ROOTS OF ALGEBRAIC EXPRESSIONS.
軟體實作與計算實驗 1  Binary search  While loop  Root Finding Lecture 6II While Loop.
Numerical Methods for Engineering MECN 3500
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
CHAPTER 3 NUMERICAL METHODS
Example Ex. Find Sol. So. Example Ex. Find (1) (2) (3) Sol. (1) (2) (3)
Newton’s Method, Root Finding with MATLAB and Excel
Applications of Loops: The power of MATLAB Mathematics + Coding
數值方法 2008 Applied Mathematics, NDHU1  Lagrange polynomial  Polynomial interpolation Lecture 4II.
數值方法 2008, Applied Mathematics NDHU1 Chaos time series.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Differentiation.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Absolute Value Absolute Value is the distance a number is away from zero on the number line. Find.| 4 | 4 | – 4 | 4 * Absolute Value Is ALWAYS POSITIVE!!!!*
數值方法, Applied Mathematics NDHU 1 Linear system. 數值方法, Applied Mathematics NDHU 2 Linear system.
Business Calculus Derivative Definition. 1.4 The Derivative The mathematical name of the formula is the derivative of f with respect to x. This is the.
軟體實作與計算實驗 1  While loop  Positive integer square root  Decimal to binary transition Lecture 6 While Loop.
Finding zeros (also called roots) of a function Overview: Define the problem Methods of solution Graphical Newton’s Bisection Secant.
CSE 330: Numerical Methods. What is true error? True error is the difference between the true value (also called the exact value) and the approximate.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Answers for Review Questions for Lectures 1-4. Review Lectures 1-4 Problems Question 2. Derive a closed form for the estimate of the solution of the equation.
MATH342: Numerical Analysis Sunjae Kim.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.
Chapter 5 Numerical Root Findings
CHAPTER 3 NUMERICAL METHODS
LECTURE 3 OF SOLUTIONS OF NON -LINEAR EQUATIONS.
Lecture 3 Taylor Series Expansion
Read Chapters 5 and 6 of the textbook
Root finding.
Ken Lambert & Doug Nance
Section 4.8: Newton’s Method
Finding zeros (also called roots) of a function
3.8: Newton’s Method Greg Kelly, Hanford High School, Richland, Washington.
Warmup 1. What is the interval [a, b] where Rolle’s Theorem is applicable? 2. What is/are the c-values? [-3, 3]
3.8: Newton’s Method Greg Kelly, Hanford High School, Richland, Washington.
Assignment 1: due 1/16/19 Estimate all of the zero of x3-x2-2x+1 graphically. Write a MatLab code for Newton’s method. Use your code to refine the graphical.
Newton-Raphson Method
The Binary Search by Mr. Dave Clausen
Presentation transcript:

數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4

數值方法 2008 Applied Mathematics, NDHU2 Drawbacks of Newton method x=linspace(-5,5);plot(x,x.^2-2*x-2); hold on;plot(x,-3,'r') Tangent line with zero slope

數值方法 2008 Applied Mathematics, NDHU3 Perturb current guess if zero derivative is detected

數值方法 2008 Applied Mathematics, NDHU4 Failure f=inline('x.^3-2*x+2'); x=linspace(-2,2);plot(x,f(x));hold on plot(x,0,'g') plot([0 1],[0 f(1)],'r'); plot([1 0],[0 f(0)],'r'); The tangent lines of x^3 - 2x + 2 at 0 and 1 intersect the x-axis at 1 and 0, respectively, illustrating why Newton's method oscillates between these values for some starting points.

Bisection method A root is within an interval [L,R] The bisection method Cut [L,R] into equal-size subintervals. such as [L,R] to [L,M] U [M,R] Determine which interval contains a root Then select it as the searching interval Repeat the same process until halting condition holds. 數值方法 2008 Applied Mathematics, NDHU5

Different signs Let f be continuous in the interval [L,R] These exists at least one root in [L,R] if f(L) and f(R) have different signs, equivalently f(L) f(R) < 0 數值方法 2008 Applied Mathematics, NDHU6

7 Bisection Method LRM=(L+R)/2 f(L) and f(M) have the same sign: L  M f(R) and f(M) have the same sign: R  M LRM L R M L  M R  M

數值方法 2008 Applied Mathematics, NDHU8 Bisection method 1. Create an inline function, f 2. Input two guesses, L < R 3. If f(L)f(R) > 0, return 4. Set M to the middle of L and R 5. If f(L)f(M) < 0, R = M 6. If f(R)f(M) < 0, L = M 7. If the halting condition holds, exit, otherwise goto step 4.

數值方法 2008 Applied Mathematics, NDHU9 Flow chart Input L,R,f with f(L)f(R) < 0 R=M abs(f(M)) < epslon T F f(L)f(M)<0 L=M M=0.5*(L+R) c=bisection(f,L,R) T

數值方法 2008 Applied Mathematics, NDHU10 Flow chart if f(L)f(R) > 0 return M=0.5*(L+R) R=M f(L)f(M)<0 L=M M=0.5*(L+R) abs(f(M)) < epslon M=bisection(f,L,R) T T return

數值方法 2008 Applied Mathematics, NDHU11 Flow chart if f(L)f(R) > 0 return M=0.5*(L+R) R=M f(L)f(M)<0 L=M M=0.5*(L+R) abs(f(M)) > epslon M=bisection(f,L,R) T T return

數值方法 2008 Applied Mathematics, NDHU12 Halting condition abs(f(M)) < epslon Absolute f(M) is small enough to approach zero.

數值方法 2008 Applied Mathematics, NDHU13 Non-decreasing sequence x = y L R

數值方法 2008 Applied Mathematics, NDHU14 Binary search Binary search is a general searching approach Let x represent a non-decreasing sequence x(i) is less or equal than x(j) if i < j Let y be an instance in sequence x Determine i such that x(i) = y

數值方法 2008 Applied Mathematics, NDHU15 Random sequence >> x=round(rand(1,15)*100) x = Columns 1 through Columns 10 through

數值方法 2008 Applied Mathematics, NDHU16 Searching for non-decreasing sequence x = y L=1 R=15 M=8

數值方法 2008 Applied Mathematics, NDHU17 Searching for non-decreasing sequence x = y R=15 L=8 M=12

數值方法 2008 Applied Mathematics, NDHU18 Searching for non-decreasing sequence x = y L=8 R=12 M=10 Halt since x(c) equals y

數值方法 2008 Applied Mathematics, NDHU19 Searching Ex. y=76 The answer i=10 indicates an index where x(i) equals y >> x(10) ans = 76

數值方法 2008 Applied Mathematics, NDHU20 Flow chart Input x,y L=1;R=length(x) L=M Halting condition T F x(M)<y R=M M=ceil(0.5*(L+R))

數值方法 2008 Applied Mathematics, NDHU21 Flow chart L=1;R=length(x) M=ceil(0.5*(L+R)) L=M x(M)<y R=M M=ceil(0.5*(L+R)) Halting condition c=bi_search(x,y) T T return

數值方法 2008 Applied Mathematics, NDHU22 Discussions What is a reasonable halting condition? Index L must be less than index R Halt if L >= R or x(M) == y

數值方法 2008 Applied Mathematics, NDHU23 MATLAB: fzero x=linspace(-5,5);plot(x,sin(x.*x)); hold on; plot(x,0,'r') x = plot(x,0,'or')

數值方法 2008 Applied Mathematics, NDHU24 fzero x=linspace(-5,5);plot(x,sin(x.*x)); hold on; plot(x,0,'r') x = plot(x,0,'or')

Exercise 4 due to 10/22 1. Draw a flow chart to illustrate the bisection method for root finding 2. Implement the flow chart 3. Give two examples to verify the matlab function 數值方法 2008 Applied Mathematics, NDHU25