Sie sind auf Seite 1von 13

ERRORS

AND APPROXIMATIONS
Lec. 2.1: Errors in Numerical Methods
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-2

Maclaurin Series for ex

• Maclaurin series until nth order term:

&' &* &-


!" = 1 + & + + + ⋯+
2! 3! .!
• Compute ! /.1 and compare with actual value

• Error: 2 = 3 4567 − 3 "::5;<

• More number of terms è lower error


Machine Precision

• “Least count of a ruler”:


• 0.1 cm is the minimum resolution of the ruler

• A Vernier Caliper also has a “least count”


• Better precision than a ruler

• Just like these devices, real numbers also have a “least count”

• “Machine Precision”: Depends on # of bytes to store a real number

Example

• Decimal example from “Computational Techniques” course


http://nptel.ac.in/courses/103106074/2

n
0. x x x x x ×10
• Floating Point representation of a number:
2
• Example: 23.217 becomes 0. 2 3 2 1 7 ×10

• 23.218 becomes 2
0. 2 3 2 1 8 ×10
• But, 23.2172 remains 2
0. 2 3 2 1 7 ×10
• Thus, the least count of this decimal machine: ~ 0.00001 3
End of Lecture 2.1

ERRORS AND APPROXIMATIONS


Lec. 2.2: Truncation and Roundoff Errors
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-2


The Taylor’s Series

• Taylor’s series:

ℎ' AA ℎ-
? 3+ℎ =? 3 + ℎ? A 3 + ? 3 + ⋯+ ? - 3 + B ℎ-C1
2! .!

• As seen in Computational Techniques (http://nptel.ac.in/courses/103106074/):


Accuracy depends on how many terms used to derive numerical scheme

Maclaurin Series for ex

• Maclaurin series until nth order term:

"
&' &* &-
! = 1+&+ + +⋯+ + B &-C1
2! 3! .!
• The last term implies error in retaining only finite number of terms of the series
MacLaurin Series from 1 to 5
&' &
= & ×
• 1 term: ! " = 1 + & + B &' 2! 2

"D
• 2 terms: ! " = 1 + & + '! + B &* &*
=
&'
×
&
3! 2! 3
"D "F
• 3 terms: ! " ≈ 1 + & + '! + *!

" "D "F "G


• 4 terms: ! ≈ 1+& + '! + *! + H!

"D "F "G "I


• 5 terms: !" ≈ 1 + & + + + +
'! *! H! J!

Truncation Error in ea

-2
10

• More terms è Lower error


-3
10

-4
10

• Smaller & è Lower error 10


-5
error

-6

• log (2) vs. log (&) è Linear rise


10

-7
10

• Slope = . + 1 10
-8

-9
• Slope is the order of accuracy!!
10

-10
10 -2 -1
10 10
step, a
End of Lecture 2.2

ERRORS AND APPROXIMATIONS


Lec. 2.3: Round-Off Errors and Iterative Methods
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-2


Numerical Differentiation

• From definition of ? A 3 :
? 3 +ℎ −? 3 ? 3+ℎ −? 3
? A 3 = lim ⇒ ? A 3 ≈
S→/ ℎ ℎ

• From Taylor’s Series:


ℎ' AA ? 3 +ℎ −? 3 ℎ
? 3 + ℎ = ? 3 + ℎ? A 3 + ? 3 + ⋯ ⇒ ? A 3 = + ? AA V
2 ℎ 2

B ℎ

Truncation vs. Roundoff Errors

• Numerical Differentiation:
? 3+ℎ −? 3
?A 3 = +B ℎ

• Truncation error decreases with ℎ
• However, machine precision may determine how small ℎ we can use
• Roundoff error increases with ℎ
Direct vs. Iterative Methods

• Direct methods:
An algorithm (sequence of operations) to “directly” compute a solution
"D "W
• MacLaurin Series: ! " ≈ 1 + & + '!
+⋯+ -!
X "CS YX "
• Numerical derivative: ?A & ≈ S

• Iterative methods:
Improve an initial guess by repeatedly using computational steps until “convergence”

Iterative Method: Compute 2

• Héron’s Algorithm: One of the first iterative numerical algorithms


• Computes 2 starting with an initial guess and iteratively using the expression:

ZC1
1 Z
2
3 = 3 +
2 3 Z

• When do we stop and say we have a solution?


End of Lecture 2.3

ERRORS AND APPROXIMATIONS


Lec. 2.4: Step-wise Methods & Error Propagation
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-2


Multiple use of Taylor’s Series

• Again consider Taylor’s Series:


A SD AA
? 3 + ℎ = ? 3 + ℎ? 3 + ? 3 +⋯
'

• Multiple use of Taylor’s series:


3 = &, & + ℎ, & + 2ℎ, & + 3ℎ, ⋯ , & + \ℎ

• Use Taylor’s series 10 times with step size of 0.01 to obtain ? 0.1 :
& = 0, ℎ = 0.01, \ = 10

Example: e0.1
Single Term of Taylor’s Series Error decreases as \ increases

• ! <CS ≈ ! < + ℎ! < • Values of ! /.1:


• ! /./1 = ! / 1 + ℎ • With ℎ = 0.1: 1.1

• ! /./' = ! /./1 1 + ℎ • With ℎ = 0.01 (10 steps): 1.1046

• ⋮ • With ℎ = 0.001 (try yourself): 1.1051

• True Value: 1.1052


• ! /.1 = ! /./^ 1 + ℎ
Example: e0.1
Single Term of Taylor’s Series Two Terms of Taylor’s Series

• ! <CS ≈ ! < + ℎ! < • ! <CS ≈ ! < + ℎ! < + _Dℎ' ! <


• ! /./1 = ! / 1 + ℎ • ! /./1 = ! / 1 + ℎ + 0.5ℎ'

• ! /./' = ! /./1 1 + ℎ • ! /./' = ! /./1 1 + ℎ + 0.5ℎ'

• ⋮ • ⋮

• ! /.1 = ! /./^ 1 + ℎ • ! /.1 = ! /./^ 1 + ℎ + 0.5ℎ'

Global Truncation Error

• Local Truncation Error:


• Error in obtaining ? 3 with single application of numerical scheme
• Recall from last lecture for ! < : abc ∝ ℎ-C1

• Global Truncation Error


• ? & + 2ℎ affected by

• error in ? & + ℎ value, and

• error in ? & + ℎ → ? & + 2ℎ

• Multi-application of Taylor’s Series: GTE is error in obtaining ? & + \ℎ ∼ B(ℎ- )


Summary

• Machine precision: “least count”

• Definitions of error:
• True error: 2 Z = 3 4567 −3 Z

• Current error: ! Z = 3 Z −3 ZY1

• Notes:
• We used “true error” to analyze errors and approximations in this module
• We used “current approximation error” for stopping an iterative method

Summary

• Direct Methods
X "CS YX "
• Numerical Derivative: ?A & ≈ S
direct application

• Iterative Methods
ZC1 1 Z '
• Héron’s Algorithm: 3 =' 3 +< f until convergence

• Step-wise Methods
• Multi-step Taylor’s series: ! <f CS ≈ ! <f + ℎ! <f until we reach destination
End of Lecture 2.4

Das könnte Ihnen auch gefallen