Lecture 3 Bisection method Download bisection02.m And ftest2.m From math.unm.edu/~plushnik/375.

Slides:



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

Lecture 5 Newton-Raphson Method
Muller’s Method Dan Heflin Sarah Hare. Muller’s Method What problem does it solve? How is it represented? Where does it come from?
Lecture 14: Newton’s method for system of two nonlinear equations Function newton2d01 Set initial (x,y) point, maximum number of iterations, and convergence.
Optimisation The general problem: Want to minimise some function F(x) subject to constraints, a i (x) = 0, i=1,2,…,m 1 b i (x)  0, i=1,2,…,m 2 where x.
Bisection Method (Midpoint Method for Equations).
Chapter 4 Roots of Equations
Dr. Jie Zou PHY Chapter 2 Solution of Nonlinear Equations: Lecture (III)
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 9 Roots of Equations Open Methods.
Lectures on Numerical Methods 1 Numerical Methods Charudatt Kadolkar Copyright 2000 © Charudatt Kadolkar.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 8 Roots of Equations Open Methods.
FP1: Chapter 2 Numerical Solutions of Equations
Fin500J: Mathematical Foundations in Finance Topic 3: Numerical Methods for Solving Non-linear Equations Philip H. Dybvig Reference: Numerical Methods.
Theorems on continuous functions. Weierstrass’ theorem Let f(x) be a continuous function over a closed bounded interval [a,b] Then f(x) has at least one.
Secant Method Another Recursive Method. Secant Method The secant method is a recursive method used to find the solution to an equation like Newton’s Method.
MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY
MATH 685/ CSI 700/ OR 682 Lecture Notes Lecture 8. Nonlinear equations.
8/30/ Secant Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Solving Non-Linear Equations (Root Finding)
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
9/20/ Secant Method Civil Engineering Majors Authors: Autar Kaw, Jai Paul
Loop Application: Numerical Methods, Part 1 The power of Matlab Mathematics + Coding.
A technique for approximating the real zeros of a Function.
Jeopardy Angle Pairs Bisecting $100 $100 $100 $100 $100 $200 $200 $200
5.1.  When we use the midpoint rule or trapezoid rule we can actually calculate the maximum error in the calculation to get an idea how much we are off.
EE:211 Computational Techniques in Electrical Engineering Lecture#2
Problem of the Day No calculator! What is the instantaneous rate of change at x = 2 of f(x) = x2 - 2 ? x - 1 A) -2 C) 1/2 E) 6 B) 1/6 D) 2.
11/30/ Secant Method Industrial Engineering Majors Authors: Autar Kaw, Jai Paul
Today’s class Roots of equation Finish up incremental search
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
Applications of Loops: The power of MATLAB Mathematics + Coding
Numerical Methods Solution of Equation.
Lecture 11 Rootfinding – Newton’s and secant methods 1 Lecture 11  More root finding methods  Newton’s method  Very fast way to find roots  Requires.
Introduction to Numerical Analysis I MATH/CMPSC 455 Bisection Method.
Finding zeros (also called roots) of a function Overview: Define the problem Methods of solution Graphical Newton’s Bisection Secant.
Recursive Methods for Finding Roots of Functions Bisection & Newton’s Method.
SOLVING NONLINEAR EQUATIONS. SECANT METHOD MATH-415 Numerical Analysis 1.
Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Bracketing Methods Bisection False Position Fixed Point Iteration Local Convergence Methods.
Finding zeros (also called roots) of a function Overview: Define the problem Methods of solution Graphical Newton’s Bisection Secant.
6/13/ Secant Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul
Solution of Nonlinear Equations ( Root Finding Problems ) Definitions Classification of Methods  Analytical Solutions  Graphical Methods  Numerical.
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.
 The equation with one variable. At P(atm) equals 0.5 atm, What is T ? ? ?
MATH342: Numerical Analysis Sunjae Kim.
CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.
Solution of Nonlinear Equations ( Root Finding Problems )
Chapter 5 Numerical Root Findings
3.2 Rolle’s Theorem and the
Solution of Nonlinear Equations (Root finding Problems
Numerical Methods and Analysis
Secant Method.
Newton’s Method for Systems of Non Linear Equations
CS B553: Algorithms for Optimization and Learning
2.2 Polynomial Function of Higher Degrees
Read Chapters 5 and 6 of the textbook
3.2 Rolle’s Theorem and the
Secant Method – Derivation
Computers in Civil Engineering 53:081 Spring 2003
MATH 175: Numerical Analysis II
SOLUTION OF NONLINEAR EQUATIONS
4 Numerical Methods Root Finding.
Chemical Engineering Majors Authors: Autar Kaw, Jai Paul
3.8 Newton’s Method How do you find a root of the following function without a graphing calculator? This is what Newton did.
Finding zeros (also called roots) of a function
3.8: Newton’s Method Greg Kelly, Hanford High School, Richland, Washington.
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.
Some Comments on Root finding
Solutions for Nonlinear Equations
Presentation transcript:

Lecture 3 Bisection method Download bisection02.m And ftest2.m From math.unm.edu/~plushnik/375

%Bisection method to find roots for function ftest2 istep=0;%set initial number of steps to zero a=0.1; %initial value for interval (a,b) b=2; %initial value for interval (a,b) if sign(ftest2(a)*ftest2(b))>=0 error('sign(ftest2(a)*ftest2(b))>=0') end abserr=10^(-15); %stop criterion - desired absolute error while abs(ftest2((a+b)/2))>abserr c=(a+b)/2; %calculate midpoint istep=istep+1; fc=ftest2(c); if fc==0 break %if c is solution then exit end if (ftest2(a)*fc)<0 b=c; else a=c; end disp(['f(c)=',num2str(fc),' x=',num2str(c,10)]);%display value of function f(x) end disp(['number of steps for Bisection algorithm=',num2str(istep)]);

%test function is defined at fourth line; %derivative of function is defined at firth line function [f,fderivative]=ftest2(x) f=exp(2*x)+x-3; fderivative=2*exp(2*x)+1;

>> bisection02 f(c)= x=1.05 f(c)= x=0.575 f(c)= x= f(c)= x= f(c)= x= … f(c)= e-015 x= f(c)=1.8652e-014 x= f(c)=7.9936e-015 x= f(c)=3.1086e-015 x= number of steps for Bisection algorithm=51

It is often good idea to plot function first

Inclass1 Modify bisection02.m and ftest2.m to find root of e^(-x)-x=0 at [0.2,1.5]

Newton’s method Download newton02.m And ftest2.m From math.unm.edu/~plushnik/375

%Newton's method to find roots for function ftest x0=0.5; %starting point abserr=10^(-15); %stop criterion - desired absolute error istep=0; x=x0; %set initial value of x to x0 %main loop to find root disp('Iterations by Newton Method'); while abs(ftest2(x))>abserr istep=istep+1; [f,fder]=ftest2(x); disp(['f(x)=',num2str(f),' x=',num2str(x,15)]);%display value of function f(x) x=x-f/fder; end [f,fder]=ftest2(x); disp(['f(x)=',num2str(f),' x=',num2str(x,15)]);%display value of function f(x) disp(['number of steps for Newton algorithm=',num2str(istep)]);

>> newton02 Iterations by Newton Method f(x)= x=0.5 f(x)= x= f(x)=5.1326e-006 x= f(x)=3.6251e-012 x= f(x)= e-016 x= number of steps for Newton algorithm=4

Inclass2 Modify newton02.m and ftest2.m to find root of e^(-x)-x=0 by Newton’s method starting at x=0.6

Secant method Download secant02.m And ftest2.m From math.unm.edu/~plushnik/375

%Secant method to find roots for function ftest2 x0=0.1; x1=2.0;%starting points abserr=10^(-14); %stop criterion - desired absolute error istep=0; xn1=x0; %set initial value of x to x0 xn=x1; %main loop to find root disp('Iterations by Secant Method'); while abs(ftest2(xn))>abserr istep=istep+1; fn=ftest2(xn); fn1=ftest2(xn1); disp(['f(x)=',num2str(fn),' xn=',num2str(xn,15)]);%display value of function f(x) xtmp=xn-(xn-xn1)*fn/(fn-fn1); xn1=xn; xn=xtmp; end f=ftest2(xn); disp(['f(x)=',num2str(fn),' xn=',num2str(xn,15)]);%display value of function f(x) disp(['number of steps for Secant algorithm=',num2str(istep)]);

%test function is defined at fourth line; %derivative of function is defined at firth line function [f,fderivative]=ftest2(x) f=exp(2*x)+x-3; fderivative=2*exp(2*x)+1;

>> secant02 Iterations by Secant Method f(x)= xn=2 f(x)= xn= f(x)= xn= f(x)= xn= f(x)= xn= f(x)= xn= f(x)=7.5808e-005 xn= f(x)= e-008 xn= f(x)= e-013 xn= f(x)= e-013 xn= number of steps for Secant algorithm=9 >>

Inclass3 Modify secant02.m and ftest2.m to find root of e^(-x)-x=0 by secant method starting at x=0.2 and x=1.5

>> secant02 Iterations by Secant Method f(x)= xn=1.5 f(x)= xn= f(x)= xn= f(x)= xn= f(x)= e-007 xn= f(x)=2.9781e-012 xn= f(x)=2.9781e-012 xn= number of steps for Secant algorithm=6 Answer to inclass3