22
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

  • View
    215

  • Download
    1

Embed Size (px)

Citation preview

Page 1: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

ECIV 301

Programming & Graphics

Numerical Methods for Engineers

Lecture 5

Approximations, Errors and

The Taylor Series

Page 2: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Objectives

• Distinguish between algorithm errors and roundoff errors.

• Introduce Taylor Theorem

• Calculate the numerical error of a finite difference formula for derivatives

Page 3: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Significant Figures

Page 4: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Significant Figures

• Designate the reliability of a numerical value

• The significant digits of a number are those that can be used with confidence

Page 5: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Accuracy and PrecisionAccuracy

Pre

cisi

on

Page 6: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Truncation Errors

vi

ti ti+1

vi+1

True Slope

Approximate Slope

ii

ii

tt

tvtv

dt

dv

1

1

Truncation errors due to using approximation in place of exact solution

Page 7: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Roundoff Errors

14.3

141592654.3

A=d2

1415.3

Page 8: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Roundoff Errors

A1=d12 A2=d2

2

d1=1.0 d2=1.000001

A1=3.14

14.3

A2=3.14000628

Page 9: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Error DefinitionTrue Value = Approximation + Error

Numerical Error

0

15

30

45

60

0 5 10 15 20 25

Time (s)

Ve

loc

ity

(m

/s)

Analytic Solution

Numerica Solutionl

Et=true value - approximation

Does not account for order of magnitude

Page 10: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Error DefinitionTrue Value = Approximation + Error

Relative Error = True Error/True Value

t= (True Error/True Value)100%

Page 11: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Approximate Error

Numerical Methods: the true value is not known apriori

%100ionapproximat

erroreapproximata

Page 12: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Approximate ErrorNumerical Methods: approximate procedures

!621

32

n

xxxxe

nx Mclaurin Series

1xe

xex 1

21

2xxex

15.0 e

5.15.0 e

625.15.0 e

648721271.15.0 e Exact

Page 13: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Approximate Error

%100ionapproximatcurrent

ionapproximatpreviousionapproximatcurrenta

Page 14: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

The Taylor Series

vi

ti ti+1

vi+1

vivi

tititi ti+1ti+1

vi+1vi+1

Predict value of a function at one point in terms of the function value and its

derivatives at another point

Page 15: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Taylor’s Theorem

nn

i1ii

n

3i1i

i

2i1i

ii1iii1i

Rxx!n

xf

xx!3

xf

xx!2

xfxxxfxfxf

Page 16: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Taylor’s Theorem

1n

i1i

1n

n xx!1n

fR

Error of Order (xi+1 – xi)n+1

Page 17: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Numerical Differentiation

nn

i1ii

n

3i1i

i

2i1i

ii1iii1i

Rxx!n

xf

xx!3

xf

xx!2

xfxxxfxfxf

Page 18: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Numerical Differentiation

ni1iii1i Rxxxfxfxf

i1i

i1i

i1ii xxO

xx

xfxfxf

First Divided Difference

Page 19: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Forward Difference

vi

ti ti+1

vi+1

True Slope

Approximate Slope

ii

ii

tt

tvtv

dt

dv

1

1

Page 20: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Backward Difference

n1iiii1i Rxxxfxfxf

1ii

1ii

1iii xxO

xx

xfxfxf

Page 21: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Central Difference

2

i1ii

i1iii1i xx!2

xfxxxfxfxf

Forward

2

1iii

1iiii1i xx!2

xfxxxfxfxf

Backward

2i1i1ii h

!3

xf

h2

xfxfxf

Central

Page 22: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series

Homework

• Problems 4.5 and 4.6

• Due Wednesday Sept 10