AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD. Mathcad Release 13. Khyruddin Akbar Ansari, Ph.D., P.E.

Similar documents
AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD. Mathcad Release 14. Khyruddin Akbar Ansari, Ph.D., P.E.

TAYLOR S POLYNOMIAL APPROXIMATION FOR FUNCTIONS

Optimization of Geometries by Energy Minimization

JUST THE MATHS UNIT NUMBER DIFFERENTIATION 2 (Rates of change) A.J.Hobson

AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD. Mathcad Release 14. Khyruddin Akbar Ansari, Ph.D., P.E.

Solutions to MATH 271 Test #3H

The derivative of a function f(x) is another function, defined in terms of a limiting expression: f(x + δx) f(x)

The Principle of Least Action

Survey Sampling. 1 Design-based Inference. Kosuke Imai Department of Politics, Princeton University. February 19, 2013

Differentiation ( , 9.5)

Lagrangian and Hamiltonian Mechanics

Lectures - Week 10 Introduction to Ordinary Differential Equations (ODES) First Order Linear ODEs

ECE 422 Power System Operations & Planning 7 Transient Stability

Single Variable Calculus Warnings

Linear and quadratic approximation

1 dx. where is a large constant, i.e., 1, (7.6) and Px is of the order of unity. Indeed, if px is given by (7.5), the inequality (7.

Chapter 2 Lagrangian Modeling

MATH , 06 Differential Equations Section 03: MWF 1:00pm-1:50pm McLaury 306 Section 06: MWF 3:00pm-3:50pm EEP 208

ELEC3114 Control Systems 1

Math 342 Partial Differential Equations «Viktor Grigoryan

Linear First-Order Equations

ECEn 621 Computer Arithmetic. Method Comparisons

2Algebraic ONLINE PAGE PROOFS. foundations

Examining Geometric Integration for Propagating Orbit Trajectories with Non-Conservative Forcing

Calculus of Variations

SYNCHRONOUS SEQUENTIAL CIRCUITS

A Weak First Digit Law for a Class of Sequences

3.2 Differentiability

More from Lesson 6 The Limit Definition of the Derivative and Rules for Finding Derivatives.

New Statistical Test for Quality Control in High Dimension Data Set

1 The Derivative of ln(x)

Derivative of a Constant Multiple of a Function Theorem: If f is a differentiable function and if c is a constant, then

YORK UNIVERSITY. Faculty of Science Department of Mathematics and Statistics. MATH A Test #2. June 25, 2014 SOLUTIONS

Module 2. DC Circuit. Version 2 EE IIT, Kharagpur

Lecture 2 Lagrangian formulation of classical mechanics Mechanics

TIME-DELAY ESTIMATION USING FARROW-BASED FRACTIONAL-DELAY FIR FILTERS: FILTER APPROXIMATION VS. ESTIMATION ERRORS

Table of Common Derivatives By David Abraham

An inductance lookup table application for analysis of reluctance stepper motor model

6 Wave equation in spherical polar coordinates

Fall 2016: Calculus I Final

Euler equations for multiple integrals

d dx But have you ever seen a derivation of these results? We ll prove the first result below. cos h 1

The total derivative. Chapter Lagrangian and Eulerian approaches

The Exact Form and General Integrating Factors

Transmission Line Matrix (TLM) network analogues of reversible trapping processes Part B: scaling and consistency

Chapter 4. Electrostatics of Macroscopic Media

Module FP2. Further Pure 2. Cambridge University Press Further Pure 2 and 3 Hugh Neill and Douglas Quadling Excerpt More information

Least-Squares Regression on Sparse Spaces

Outline. MS121: IT Mathematics. Differentiation Rules for Differentiation: Part 1. Outline. Dublin City University 4 The Quotient Rule

Polynomial Inclusion Functions

LINEAR DIFFERENTIAL EQUATIONS OF ORDER 1. where a(x) and b(x) are functions. Observe that this class of equations includes equations of the form

Average value of position for the anharmonic oscillator: Classical versus quantum results

We G Model Reduction Approaches for Solution of Wave Equations for Multiple Frequencies

Math Chapter 2 Essentials of Calculus by James Stewart Prepared by Jason Gaddis

Section 7.1: Integration by Parts

11.7. Implicit Differentiation. Introduction. Prerequisites. Learning Outcomes

Construction of the Electronic Radial Wave Functions and Probability Distributions of Hydrogen-like Systems

Modeling time-varying storage components in PSpice

Thermal runaway during blocking

MATH2231-Differentiation (2)

State-Space Model for a Multi-Machine System

Mathcad Lecture #5 In-class Worksheet Plotting and Calculus

x f(x) x f(x) approaching 1 approaching 0.5 approaching 1 approaching 0.

Tutorial on Maximum Likelyhood Estimation: Parametric Density Estimation

Solutions to the Exercises of Chapter 9

Exam 2 Answers Math , Fall log x dx = x log x x + C. log u du = 1 3

x f(x) x f(x) approaching 1 approaching 0.5 approaching 1 approaching 0.

Lie symmetry and Mei conservation law of continuum system

Implicit Differentiation

Calculus Math Fall 2012 (Cohen) Lecture Notes

C6-1 Differentiation 2

Qubit channels that achieve capacity with two states

WITH high operating frequencies and scaled geometries,

'HVLJQ &RQVLGHUDWLRQ LQ 0DWHULDO 6HOHFWLRQ 'HVLJQ 6HQVLWLYLW\,1752'8&7,21

February 21 Math 1190 sec. 63 Spring 2017

Implicit Differentiation

Scott E. Grasman 1, Zaki Sari 2 and Tewfik Sari 3

Final Exam Study Guide and Practice Problems Solutions

Adaptive Gain-Scheduled H Control of Linear Parameter-Varying Systems with Time-Delayed Elements

18 EVEN MORE CALCULUS

A Comparison between a Conventional Power System Stabilizer (PSS) and Novel PSS Based on Feedback Linearization Technique

The Sokhotski-Plemelj Formula

Designing of Acceptance Double Sampling Plan for Life Test Based on Percentiles of Exponentiated Rayleigh Distribution

Separation of Variables

Equations of lines in

Chapter 2 Derivatives

The Chain Rule. d dx x(t) dx. dt (t)

Lecture Introduction. 2 Examples of Measure Concentration. 3 The Johnson-Lindenstrauss Lemma. CS-621 Theory Gems November 28, 2012

1 Lecture 13: The derivative as a function.

4. Important theorems in quantum mechanics

Hyperbolic Systems of Equations Posed on Erroneous Curved Domains

Laplace s Equation in Cylindrical Coordinates and Bessel s Equation (II)

MULTIFRACTAL NETWORK GENERATORS

Q(s, t) = S M = S M [ G 1 (t) G 2 (t) G 3 1(t) G 4 (t) ] T

An Analytical Expression of the Probability of Error for Relaying with Decode-and-forward

PARALLEL-PLATE CAPACITATOR

Further Differentiation and Applications

IMPLICIT DIFFERENTIATION

A PAC-Bayesian Approach to Spectrally-Normalized Margin Bounds for Neural Networks

The Press-Schechter mass function

Transcription:

AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD Mathca Release 13 Khyruin Akbar Ansari, Ph.D., P.E. Professor of Mechanical Engineering School of Engineering Gonzaga University SDC PUBLICATIONS Schroff Development Corporation www.schroff.com www.schroff-europe.com

Chapter 2: Introuction to Numerical Methos 43 C H A P T E R 2 INTRODUCTION TO NUMERICAL METHODS 2.1 THE USE OF NUMERICAL METHODS IN SCIENCE AND ENGINEERING Analysis of problems in engineering an the physical sciences typically involves four steps as follows. (1) Development of a suitable mathematical moel that realistically represents a given physical system. (2) Derivation of the system governing equations using physical laws such as Newton's laws of motion, conservation of energy, the laws governing electrical circuits etc. (3) Solution of the governing equations, an (4) Interpretation of the results. Because real worl problems are generally quite complex with the generation of close-form analytical solutions becoming impossible in many situations, there exists, most efinitely, a nee for the proper utilization of computer-base techniques in the solution of practical problems. The avancement of computer technology has mae the effective use of numerical methos an computer-base techniques very feasible, an thus, solutions can now be obtaine much faster than ever before an with much better than acceptable accuracy. However, there are avantages as well as isavantages associate with any numerical proceure that is resorte to, an these must be kept in min when using it. 2.2 COMPARISON OF NUMERICAL METHODS WITH ANALYTICAL METHODS While an analytical solution will be exact if it exists, a numerical metho, on the other han, will generally require iterations to generate a solution, which is only an approximation an which certainly cannot be consiere exact by any means. A isavantage associate with analytical solution techniques is that they are generally applicable only to very special cases of problems. Numerical solutions, on the contrary, will solve complex situations as well. While numerical techniques have several avantages incluing easy programming on a computer an the convenience with which they hanle complex problems, the initial estimate of the solution along with the many number of iterations that are sometimes require to generate a solution can be looke upon as isavantages.

44 AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD 2.3 SOURCES OF NUMERICAL ERRORS AND THEIR COMPUTATION It is inee possible for miscalculations to creep into a numerical solution because of various sources of error. These inclue inaccurate mathematical moeling, wrong programming, wrong input, rouning off of numbers an truncation of an infinite series. Roun-off error is the general name given to inaccuracies that affect the calculation scene when a finite number of igits are assigne to represent an actual number. In a long sequence of calculations, this roun-off error can accumulate, then propagate through the process of calculation an finally grow very rapily to a significant number. A truncation error results when an infinite series is approximate by a finite number of terms, an, typically, upper bouns are place on the size of this error. The true error is efine as the ifference between the compute value an the true value of a number. E True = X Comp X True (2.1) while the relative true error is the error relative to the true value X Comp X True e r = X True (2.2) Expresse as a percentage, the relative true error is written as X Comp X True e r = 1 (%) (2.3) X True 2.4 TAYLOR SERIES EXPANSION The Taylor series is consiere as a basis of approximation in numerical analysis. If the value of a function of x is provie at " x ", then the Taylor series provies a means of evaluating the function at " x + h", where " x " is the starting value of the inepenent variable an " h " is the ifference between the starting value an the new value at which the function is to be approximate ( ) = fx ( ) + h fx + h ( ) fx x + h 2 2 2! 2 x fx ( ) h 3 3 + fx ( 3! 3 ) +... x (2.4) This equation can be use for generating various s of approximations as shown below. The of approximation is efine by the highest erivative inclue in the series. For example, If only terms up to the secon erivative are retaine in the series, the result is a secon approximation.

Chapter 2: Introuction to Numerical Methos 4 First approximation: ( ) = fx ( ) + h fx + h x fx ( ) (2.) Secon approximation: ( ) = fx ( ) + h fx + h x fx ( ) + h 2 2 2! 2 x fx ( ) (2.6) Thir approximation: ( ) = fx ( ) + h fx + h x fx ( ) + h 2 2 2! 2 x fx ( ) + h 3 3 3! 3 x fx ( ) (2.7) It is to note that the significance of the higher terms in the Taylor series increases with the nonlinearity of the function involve as well as the ifference between the " starting x" value an the "x" value at which the function is to be approximate. Thus, the fewer the terms that are inclue in the series, the larger will be the error associate with the computation of the function value. If the function is linear, however, only terms up to the first erivative term nee to be inclue. Example 2.1 Using the Taylor series expansion for f(x) = -.1 x 4 -.17 x 3 -.2 x 2 -.2 x + etermine the zeroth, first, secon, thir, fourth an fifth approximations of f(x + h ) where x = an h = 1,2, 3, 4, an compare these with the exact solutions. h=1.: Put in the function an generate its erivatives: fx ( ) :=.1 x 4.17 x 3.2 x 2.2x + x := h:= 1. fprime( x) :=.6x 3.1x 2.x.2 <--Generate erivatives f2prime( x) := 1.8x 2 1.2x. f3prime( x) := 3.6x 1.2 f4prime( x) := 3.6 fprime( x) :=.

46 AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD h 2 term1 := f( x) term2 := hfprime( x) term3 := f2prime x 2 ( ) h 3 term4 := f3prime x 6 ( ) term h 4 := f4prime x 24 ( ) term6 h := fprime x 12 ( ) ftaylor := term1 <---- one-term or zero- approximation ftaylor1 := term1 + term2 <---- first approximation with two terms ftaylor2 := term1 + term2 + term3 <---secon approximation with 3 terms ftaylor3 := term1 + term2 + term3 + term4 <---thir approximation with 4 terms ftaylor4 := term1 + term2 + term3 + term4 + term <---fourth approximation with terms ftaylor := term1 + term2 + term3 + term4 + term + term6 <----- fifth approximation with 6 terms x := x + h x = 1 ftaylor = ftaylor1 = 1 ftaylor2.7 ftaylor3 =.8 ftaylor4 =.43 ftaylor =.43 = These are the zero- fifth <-- approximations of the given function f(x) using the Taylor series. f1 ( ) =.43 <---EXACT ANSWER USING FUNCTION GIVEN. err := f( x) ftaylor err =.82 err1 := f( x) ftaylor1 err1 =.7 err2 := f( x) ftaylor2 err2 =.32 These are errors ( ifferences between exact <-- values an approximations ) for the above zero - fifth approximations. err3 := f( x) ftaylor3 err3 =.1 err4 := f( x) ftaylor4 err4 = err := f( x) ftaylor err = Similarly, by using h= 2, 3, 4,, the zeroth- fifth approximations for f(2), f(3), f(4), f() an the associate errors can be etermine. These are given in Tables 2.1 an 2.2 Plots of the various Taylor series approximations of the given function an associate errors are generate below an are presente in Figs. 2.1 an 2.2

Chapter 2: Introuction to Numerical Methos 47 x := x :=,.1.. ftaylor( x) := fx ( ) <-- zeroth- approximation ftaylor1( x) := ftaylor( x) + ( x x) fprime( x) <---first- approximation ( x x) 2 ftaylor2( x) := ftaylor1( x) + f2prime( x) <--secon- approximation 2 ( x x) 3 ftaylor3( x) := ftaylor2( x) + f3prime( x) <---thir- approximation 6 ( x x) 4 ftaylor4( x) := ftaylor3( x) + f4prime( x) <---fourth- approximation 24 ( x x) ftaylor ( x) := ftaylor4( x) + fprime( x) <---fifth- approximation 12 Errors generate with the various approximations are as follows Zero approximation: err( x) := fx ( ) ftaylor( x) First approximation: err1( x) := fx ( ) ftaylor1( x) Secon approximation: err2( x) := fx ( ) ftaylor2( x) Thir approximation: err3( x) := fx ( ) ftaylor3( x) Fourth approximation: err4( x) := fx ( ) ftaylor4( x) Fifth approximation: err ( x) := fx ( ) ftaylor ( x) The various approximations generate by the above calculations an the associate errors are compare in Table 2.1.

48 AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD Taylor series approx of given function Function approximate by Taylor series ftaylor( x) ftaylor3( x) ftaylor( x) 1 Zeroth approx Thir approx Fifth approx/ given function 1 1 2 3 4 x x- value Figure 2.1. Taylor series approximation of given function x :=,.1.. Errors gen ue to Taylor-series approx errors as function of x err( x) err3( x) err( x) 1 Zero approx Thir approx Fifth approx 1 1 2 3 4 x x- value Figure 2.2. Errors associate with the various Taylor series approximations

Chapter 2: Introuction to Numerical Methos 49 The various approximations generate by the above calculations an the associate errors are compare in the following tables. Table 2.1 h := 1.. x :=, 1.. Various s of approximation generate by Taylor series approach versus true values of given function zeroth first secon thir fourth fifth True Value h = 1 2 3 4 x = ftaylor( x) 1 2 3 4 ftaylor1 = ( x) 1.7..2 =ftaylor2( x).7 -.2-1.7-3.7-6.2 ftaylor3 = ( x).8-1.61-6.34-14.63-27. =ftaylor4( x).43-4.1-18.49-3.3-12 =ftaylor ( x).43-4.1-18.49-3.3-12 =f( x) =.43-4.1-18.49-3.3-12 Table 2.2 Errors associate with the ifferent s of approximation zeroth first secon thir fourth fifth h = 1 2 3 4 x = err( x) 1 2 3 4 -.82 -.26-19.74-4.28-122. = err1( x) -.7-4.76-18.99-3.28-12 = err2( x) -.32-3.76-16.74-49.28-11 = err3( x) -.1-2.4-12.1-38.4-93.7 = err4( x) = err ( x) = PROBLEMS 2.1. Using the Taylor series expansion for cos x, which is given as f(x) = cos x = 1- x 2 / 2 + x 4 / 24, etermine the one-term, two-term an three-term approximations of f(x + h ), where x =

AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD ra an h =. 1,.2...1. ra, an compare these with the exact solution. Using Mathca, generate plots of the various Taylor series approximations an associate errors as functions of the inepenent variable x. 2.2 Develop a Taylor series expansion of the following function: f(x) = x - 6 x 4 + 3x 2 + 9. Use x =3 as the base an h as the increment. Using Mathca, evaluate the series for h=.1,.2...1., aing terms incrementally as in Problem 2.1. Compare the various Taylor series approximations obtaine with true values in a table. Generate plots of the approximations an associate errors as functions of x. 2.3 Given the following function: f(x) = x 3-3 x 2 + x + 1, etermine f ( x + h ) with the help of a Taylor series expansion, where x = 2 an h =.4. Compare the true value of f ( 2.4 ) with estimates obtaine by resorting to (a) one term only (b) two terms (c) three terms an () four terms of the series. 2.4 Given the following function fx ( ) = 3x 3 6x 2 + 1 x + 2 use a Taylor series expansion to etermine the zeroth, first, secon an thir approximations of f(x +h) where x = 2 an h =.. Compare these with the exact solution. 2. By eveloping a Taylor series expansion for f(x) = e x about x =, etermine the fourth- approximation of e 2. an compare it with the exact solution. 2.6. By eveloping a Taylor series expansion for f(x) = ln(2-x) about x =, etermine the fourth- approximation of ln (.) an compare it with the exact solution

Chapter 2: Introuction to Numerical Methos 1 2.7. By eveloping a Taylor series expansion for f(x) = x 3 e - x about x = 1, etermine the thir- approximation of f(1.2) an compare it with the exact solution. 2.8. By eveloping a Taylor series expansion for f(x) = e cos x about x =, etermine the fourth- approximation of f (2π) an compare it with the exact solution.. 2.9. By eveloping a Taylor series expansion for f(x) = (x - 2) 1/2 about x = 3, etermine the thir- approximation of f (2.2), that is, (.2) 1/2, an compare it with the exact solution. 2.1. Given the function f(x) = x 2 - x. + 6, use a Taylor series expansion to etermine the first, secon, thir an fourth approximations of f (2. ) by resorting to x = 2 an h =.. Compare these with the exact solution. 2.11. Given the function f(x) = 6 x 3-9 x 2 +2 x + 4, use a Taylor series expansion to etermine the zeroth, first, secon an thir approximations of f (x + h ) where x = 3 an h = 1. Compare these with the exact solution. 2.12. Given the function f(x) = 4 x 4-7 x 3 + x 2-6 x + 9 use a Taylor series expansion to etermine the zeroth, first, secon, thir an fourth

2 AN INTRODUCTION TO NUMERICAL METHODS USING MATHCAD approximations of f (x + h ) ) where x = 3 an h =.. Compare these with the exact solution. Calculate errors an generate calculations to three ecimal places. 2.13. Given the function f(x) = 8 x 3-1 x 2 + 2 x + 4, use a Taylor series expansion to etermine the zeroth, first, secon an thir approximations of f (x + h ) where x = 2 an h = 1. Compare these with the exact solution. 2.14. Given the function f(x) = 1 + x + x 2 / 2! + x 3 / 3! +x 4 / 4! use a Taylor series expansion to etermine the zeroth, first, secon, thir an fourth approximations of f (x + h ) where x = an h =.. Compare these with the exact solution. Generate answers correct to four ecimal places. 2.1. Given the function f(x) = x + x 3 / 3 + 2 x / 1 use a Taylor series expansion to etermine the zeroth, first, secon, thir an fourth approximations of f (x + h ) where x = an h =.8. Compare these with the exact solution by computing percentage errors. Generate answers correct to four ecimal places. 2.16. Given the function f(x) = sin (x) use a Taylor series expansion to etermine the fifth approximation of f (x + h ) where x = an h =.2 raians. Compare your answer with the true value. Generate answers correct to four ecimal places. 2.17. Given the function f(x) = 3 x 2-6 x. + 9, use a Taylor series expansion to etermine the zeroth, first, secon, thir an fourth approximations of f (x + h ) whereo x = 3 an h = 1. Compare these with the exact solution by computing percentage errors. Generate answers correct to four ecimal places.