Chapter 14: Numerical Methods

Slides:



Advertisements
Similar presentations
計算機程式語言 Lecture 14-1 國立臺灣大學生物機電系 14 Numerical Methods.
Advertisements

Lecture 5 Newton-Raphson Method
Roundoff and truncation errors
CSE 330: Numerical Methods
Open Methods Chapter 6 The Islamic University of Gaza
Open Methods Chapter 6 The Islamic University of Gaza
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Chapter 4 Roots of Equations
Roots of Equations Open Methods (Part 2).
INFINITE SEQUENCES AND SERIES
APPLICATIONS OF DIFFERENTIATION Newton’s Method In this section, we will learn: How to solve high-degree equations using Newton’s method. APPLICATIONS.
Lecture 1: Numerical Solution of Non-linear equations.
Open Methods Chapter 6 The Islamic University of Gaza
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.
NUMERICAL METHODS WITH C++ PROGRAMMING
Roots of Equations Open Methods Second Term 05/06.
Chapter 3 Root Finding.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Graph quadratic equations. Complete the square to graph quadratic equations. Use the Vertex Formula to graph quadratic equations. Solve a Quadratic Equation.
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.
I. Finding Roots II. Integrating Functions
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
Techniques of Integration
Solving Non-Linear Equations (Root Finding)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 Roots of Equations Why? But.
1 Preliminaries Precalculus Review I Precalculus Review II
Chapter 6 Finding the Roots of Equations
Introduction This chapter gives you several methods which can be used to solve complicated equations to given levels of accuracy These are similar to.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
INTEGRALS Areas and Distances INTEGRALS In this section, we will learn that: We get the same special type of limit in trying to find the area under.
INTEGRALS 5. INTEGRALS In Chapter 2, we used the tangent and velocity problems to introduce the derivative—the central idea in differential calculus.
Integrals  In Chapter 2, we used the tangent and velocity problems to introduce the derivative—the central idea in differential calculus.  In much the.
Lecture 3 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Chapter 5-The Integral Calculus, 2ed, by Blank & Krantz, Copyright 2011 by John Wiley & Sons, Inc, All Rights Reserved.
1 Solution of Nonlinear Equation Dr. Asaf Varol
In section 11.9, we were able to find power series representations for a certain restricted class of functions. Here, we investigate more general problems.
Chapter 3 Roots of Equations. Objectives Understanding what roots problems are and where they occur in engineering and science Knowing how to determine.
Chapter 8 Integration Techniques. 8.1 Integration by Parts.
Numerical Methods for Engineering MECN 3500
Numerical Methods.
CHAPTER 3 NUMERICAL METHODS
Time velocity After 4 seconds, the object has gone 12 feet. Consider an object moving at a constant rate of 3 ft/sec. Since rate. time = distance: If we.
Newton’s Method, Root Finding with MATLAB and Excel
MECN 3500 Inter - Bayamon Lecture 6 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 5 Bracketing Methods.
Solving Non-Linear Equations (Root Finding)
Numerical Methods Solution of Equation.
Today’s class Numerical differentiation Roots of equation Bracketing methods Numerical Methods, Lecture 4 1 Prof. Jinbo Bi CSE, UConn.
4 Numerical Methods Root Finding Secant Method Modified Secant
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
In Chapters 6 and 8, we will see how to use the integral to solve problems concerning:  Volumes  Lengths of curves  Population predictions  Cardiac.
INTEGRALS We saw in Section 5.1 that a limit of the form arises when we compute an area. We also saw that it arises when we try to find the distance traveled.
Java for Engineers and Scientists 1 st Edition Gary J. Bronson.
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.
INTEGRALS 5. INTEGRALS In Chapter 3, we used the tangent and velocity problems to introduce the derivative—the central idea in differential calculus.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
NUMERICAL DIFFERENTIATION Forward Difference Formula
Chapter 7 Numerical Differentiation and Integration
Numerical Methods and Analysis
SKTN 2393 Numerical Methods for Nuclear Engineers
Numerical Integration
Copyright © Cengage Learning. All rights reserved.
MATH 1910 Chapter 3 Section 8 Newton’s Method.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

Chapter 14: Numerical Methods

Objectives In this chapter, you will learn about: Root finding The bisection method Refinements to the bisection method The secant method Numerical integration The trapezoidal rule Simpson’s rule Common programming errors C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding Root finding is useful in solving engineering problems Vital elements in numerical analysis are: Appreciating what can or can’t be solved Clearly understanding the accuracy of answers found C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Examples of the types of functions encountered in root-solving problems: C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) General quadratic equation, Equation 14.1, can be solved easily and exactly by using the following equation: C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Equation 14.2 can be solved for x exactly by factoring the polynomial Equations 14.4 and 14.5 are transcendental equations Transcendental equations Represent a different class of functions Typically involve trigonometric, exponential, or logarithmic functions Cannot be reduced to any polynomial equation in x C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Irrational numbers and transcendental numbers Represented by nonrepeating decimal fractions Cannot be expressed as simple fractions Responsible for the real number system being dense or continuous Classifying equations as polynomials or transcendental and the roots of these equations as rational or irrational is vital to traditional mathematics Less important to the computer where number system is continuous and finite C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) When finding roots of equations, the distinction between polynomials and transcendental equations is unnecessary Many theorems learned for roots and polynomials don’t apply to transcendental equations Both Equations 14.4 and 14.5 have infinite number of real roots C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Potential computational difficulties can be avoided by providing: Best possible choice of method Initial guess based on knowledge of the problem This is often the most difficult and time consuming part of solution Art of numerical analysis consists of balancing time spent optimizing the problem’s solution before computation against time spent correcting unforeseen errors during computation C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Sketch function before attempting root solving Use graphing routines or Generate table of function values and graph by hand Graphs are useful to programmers in: Estimating first guess for root Anticipating potential difficulties C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Figure 14.1 Graph of e-x and sin(½πx) for locating the intersection points C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Because the sine oscillates, there is an infinite number of positive roots Concentrate on improving estimate of first root near 0.4 Establish a procedure based on most obvious method of attack Begin at some value of x just before the root Step along x-axis carefully watching magnitude and sign of function C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) Notice that function changed sign between 0.4 and 0.5 Indicates root between these two x values C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) For next approximation use midpoint value, x = 0.45 Function is again negative at 0.45 indicating root between 0.4 and 0.45 Next approximation is midpoint, 0.425 C++ for Engineers and Scientists, Fourth Edition

Introduction to Root Finding (continued) In this way, proceed systematically to a computation of the root to any degree of accuracy Key element in this procedure is monitoring the sign of function When sign changes, specific action is taken to refine estimate of root C++ for Engineers and Scientists, Fourth Edition

The Bisection Method Root-solving procedure previously explained is suitable for hand calculations A slight modification makes it more systematic and easier to adapt to computer coding Modified computational technique is known as the bisection method Suppose you already know there’s a root between x = a and x = b Function changes sign in this interval Assume Only one root between x = a and x = b Function is continuous in this interval C++ for Engineers and Scientists, Fourth Edition

The Bisection Method (continued) Figure 14.2 A sketch of a function with one root between a and b C++ for Engineers and Scientists, Fourth Edition

The Bisection Method (continued) After determining a second time whether the left or right half contains the root, interval is again replaced by the left or right half-interval Continue process until narrow in on the root at previously assigned accuracy Each step halves interval After n intervals, interval’s size containing root is (b – a)/2n C++ for Engineers and Scientists, Fourth Edition

The Bisection Method (continued) If required to find root to within the tolerance, the number of iterations can be determined by: C++ for Engineers and Scientists, Fourth Edition

The Bisection Method (continued) Program 14.1 computes roots of equations Note the following features: In each iteration after the first one, there is only one function evaluation Program contains several checks for potential problems along with diagnostic messages along with diagnostic messages Criterion for success is based on interval’s size C++ for Engineers and Scientists, Fourth Edition

Refinements to the Bisection Method Bisection method presents the basics on which most root-finding methods are constructed Brute force is rarely used All refinements of bisection method attempt to use as much information as available about the function’s behavior in each iteration In the ordinary bisection method, the only feature of the function that is monitored is its sign C++ for Engineers and Scientists, Fourth Edition

Regula Falsi Method Essentially same as bisection method, except it uses interpolated value for root Root is known to exist in interval ( x1 ↔ x2 ) In drawing, f1 is negative and f3 is positive Interpolated position of root is x2 Length of sides is related, yielding: Value of x2 replaces the midpoint in bisection C++ for Engineers and Scientists, Fourth Edition

Regula Falsi Method (continued) Figure 14.3 Estimating the root by interpolation C++ for Engineers and Scientists, Fourth Edition

Regula Falsi Method (continued) Figure 14.4 Illustration of several iterations of the regula falsi method C++ for Engineers and Scientists, Fourth Edition

Modified Regula Falsi Method Perhaps the procedure can be made to collapse from both directions from both directions The idea is as follows: C++ for Engineers and Scientists, Fourth Edition

Modified Regula Falsi Method (continued) Figure 14.5 Illustration of the modified regula falsi method C++ for Engineers and Scientists, Fourth Edition

Modified Regula Falsi Method (continued) Using this algorithm, slope of line is reduced artificially If root is in left of original interval, it: Eventually turns up in the right segment of a later interval Subsequently alternates between left and right C++ for Engineers and Scientists, Fourth Edition

Modified Regula Falsi Method (continued) Table 14.1 Comparison of Root-Finding Methods Using the Function f(x)=2e-2x -sin(πx) C++ for Engineers and Scientists, Fourth Edition

Modified Regula Falsi Method (continued) Relaxation factor: Number used to alter the results of one iteration before inserting them into the next Trial and error shows that a less drastic increase in the slope results in improved convergence Using a convergence factor of 0.9 should be adequate for most problems C++ for Engineers and Scientists, Fourth Edition

Summary of the Bisection Methods Success based on size of interval Slow convergence Predictable number of iterations Interval halved in each iteration Guaranteed to bracket a root C++ for Engineers and Scientists, Fourth Edition

Summary of the Bisection Methods (continued) Regula falsi Success based on size of function Faster convergence Unpredictable number of iterations Interval containing the root is not small C++ for Engineers and Scientists, Fourth Edition

Summary of the Bisection Methods (continued) Modified regula falsi Success based on size of interval Faster convergence Unpredictable number of iterations Of three methods, most efficient for common problems C++ for Engineers and Scientists, Fourth Edition

The Secant Method Identical to regula falsi method except sign of f(x) doesn’t need to be checked at each iteration C++ for Engineers and Scientists, Fourth Edition

Introduction to Numerical Integration Integration of a function of a single variable can be thought of as opposite to differentiation, or as the area under the curve Integral of function f(x) from x=a to x=b will be evaluated by devising schemes to measure area under the graph of function over this interval Integral designated as: C++ for Engineers and Scientists, Fourth Edition

Introduction to Numerical Integration (continued) Figure 14.7 An integral as an area under a curve C++ for Engineers and Scientists, Fourth Edition

Introduction to Numerical Integration (continued) Numerical integration is a stable process Consists of expressing the area as the sum of areas of smaller segments Fairly safe from division by zero or round-off errors caused by subtracting numbers of approximately the same magnitude Many integrals in engineering or science cannot be expressed in any closed form C++ for Engineers and Scientists, Fourth Edition

Introduction to Numerical Integration (continued) Trapezoidal rule approximation for integral Replace function over limited range by straight line segments Interval x=a to x=b is divided into subintervals of size ∆x Function replaced by line segments over each subinterval Area under function is then approximated by area under line segments C++ for Engineers and Scientists, Fourth Edition

The Trapezoidal Rule Approximation of area under complicated curve is obtained by assuming function can be replaced by simpler function over a limited range A straight line, the simplest approximation to a function, lead to trapezoidal rule Trapezoidal rule for one panel, identified as T0 C++ for Engineers and Scientists, Fourth Edition

The Trapezoidal Rule (continued) Figure 14.8 Approximating the area under a curve by a single trapezoid C++ for Engineers and Scientists, Fourth Edition

The Trapezoidal Rule (continued) Improve accuracy of approximation under curve by dividing interval in half Function is approximated by straight-line segments over each half Area in example is approximated by area of two trapezoids C++ for Engineers and Scientists, Fourth Edition

The Trapezoidal Rule (continued) Figure 14.9 Two-panel approximation to the area C++ for Engineers and Scientists, Fourth Edition

The Trapezoidal Rule (continued) Two-panel approximation T1 can be related to one-panel results, T0, as: Result for n panels is: C++ for Engineers and Scientists, Fourth Edition

Computational Form of the Trapezoidal Rule The result for n panels was derived assuming that the widths of all panels is the same and equal to ∆xn Equation can be generalized to a partition of the interval into unequal panels By restricting panel widths to be equal and number of panels to be a power of 2, This results in: C++ for Engineers and Scientists, Fourth Edition

Computational Form of the Trapezoidal Rule (continued) Figure 14.10 Four-panel trapezoidal approximation, T2 C++ for Engineers and Scientists, Fourth Edition

Computational Form of the Trapezoidal Rule (continued) C++ for Engineers and Scientists, Fourth Edition

Computational Form of the Trapezoidal Rule (continued) Procedure using Equation 14.11 to approximate an integral by the trapezoidal rule is: Compute T0 by using Equation 14.6 Repeatedly apply Equation 14.11 for: k = 1, 2, . . . until sufficient accuracy is obtained C++ for Engineers and Scientists, Fourth Edition

Example of a Trapezoidal Rule Calculation Given the following integral: Trapezoidal rule approximation to the integral with a = 1 and b = 2 begins with Equation 14.6 to obtain T0 C++ for Engineers and Scientists, Fourth Edition

Example of a Trapezoidal Rule Calculation (continued) Repeated use of Equation 14.11 then yields: C++ for Engineers and Scientists, Fourth Edition

Example of a Trapezoidal Rule Calculation (continued) Continuing the calculation through k = 5 yields: C++ for Engineers and Scientists, Fourth Edition

Simpson’s Rule Trapezoidal rule is based on approximating the function by straight-line segments To improve the accuracy and convergence rate, another approach is approximating the function by parabolic segments This is known as Simpson’s rule Specifying a parabola uniquely requires three points, so the lowest order Simpson’s rule has two panels C++ for Engineers and Scientists, Fourth Edition

Simpson’s Rule (continued) Figure 14.11 Area under a parabola drawn through three points C++ for Engineers and Scientists, Fourth Edition

Simpson’s Rule (continued) C++ for Engineers and Scientists, Fourth Edition

Simpson’s Rule (continued) Figure 14.12 The second-order Simpson’s rule approximation is the area under two parabolas C++ for Engineers and Scientists, Fourth Edition

Simpson’s Rule (continued) Generalization of Equation 14.12 for n = 2k panels C++ for Engineers and Scientists, Fourth Edition

Example of Simpson’s Rule as an Approximation to an Integral Consider this integral: Using Equation 14.13 first for k = 1 yields: C++ for Engineers and Scientists, Fourth Edition

Example of Simpson’s Rule as an Approximation to an Integral (continued) Repeating for k = 2 yields: C++ for Engineers and Scientists, Fourth Edition

Figure 14.2 Trapezoidal and Simpson’s rule results for integral Example of Simpson’s Rule as an Approximation to an Integral (continued) Continuing the calculation yields: Figure 14.2 Trapezoidal and Simpson’s rule results for integral C++ for Engineers and Scientists, Fourth Edition

Common Programming Errors Two characteristics of this type of computation: Round-off errors occur when the values of f(x1) and f(x3) are nearly equal Prediction of exact number of iterations is not available Excessive and possibly infinite iterations must be prevented Excessive computation time might be a problem Occurs if number of iterations exceeds fifty C++ for Engineers and Scientists, Fourth Edition

Summary All root solving methods described in chapter are iterative Can be categorized into two classes Starting from an interval containing a root Starting from an initial estimate of a root Bisection algorithms refine initial interval by: Repeated evaluation of function at points within interval Monitoring the sign of the function and determining in which subinterval the root lies C++ for Engineers and Scientists, Fourth Edition

Summary (continued) Regula falsi uses same conditions as bisection method Straight line connecting points at the ends of the intervals is used to interpolate position of root Intersection of this line with x-axis determines value of x2 used in next step Modified regula falsi same as regula falsi except: In each iteration, when full interval replaced by subinterval containing root, relaxation factor used to modify function’s value at the fixed end of the subinterval C++ for Engineers and Scientists, Fourth Edition

Summary (continued) Secant method replaces the function by: Secant line through two points Finds point of intersection of the line with x-axis Algorithm requires two input numbers: x0 and ∆x0 Pair of values then replaced by pair (x1, and ∆x1) where x1 = x0 + ∆x0 and C++ for Engineers and Scientists, Fourth Edition

Chapter Summary (continued) Secant method processing continues until ∆x is sufficiently small Success of a program in finding the root of function usually depends on the quality of information supplied by the user Accuracy of initial guess or search interval Method selection match to circumstances of problem Execution-time problems are usually traceable to: Errors in coding Inadequate user-supplied diagnostics C++ for Engineers and Scientists, Fourth Edition

Summary (continued) Trapezoidal rule results from replacing the function f(x) by straight-line segments over the panels ∆xi Approximate value for integral is given by following formula C++ for Engineers and Scientists, Fourth Edition

Summary (continued) If panels are equal size and the number of panels is n = 2k where k is a positive integer, the trapezoidal rule approximation is then labeled Tk and satisfies the equation where C++ for Engineers and Scientists, Fourth Edition

Summary (continued) In next level of approximation Function f(x) is replaced by n/2 parabolic segments over pairs of equal size panels, ∆x = (b - a)/n Results in formula for the area known as Simpson’s rule: C++ for Engineers and Scientists, Fourth Edition