Dr.Shoeb_ME212_Lec-2-NUMERICAL METHODS_g

ShoebAhmedSyed2 73 views 58 slides Jul 03, 2024
Slide 1
Slide 1 of 58
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58

About This Presentation

vERY GOOD


Slide Content

Introduction to
Numerical
Methods
Numerical Methods (ME 212)
Author:Dr.ShoebAhmed Syed
Papua New Guinea University of Technology
Department of Mechanical Engineering
1

SourcesofError

Twosourcesofnumericalerror
1)
2)
Roundoff error
Truncationerror
3

Round-offError
4

RoundoffError
•Causedby representing
approximately
anumber
1
3
0.333333
1.4142...2
5

GET THESE RULES FOR ROUNDING OFF
NUMBERS
CASE1:
Inroundingoffnumbers,thelastfigurekeptshouldbeunchangedifthe
firstfiguredroppedislessthan5.Forexample,ifonlyonedecimalis
tobekept,then6.422becomes6.4.
CASE2:
Inroundingoffnumbers,thelastfigurekeptshouldbeincreasedby1if
thefirstfiguredroppedisgreaterthan5.Forexample,ifonlytwo
decimalsaretobekept,then6.4872becomes6.49.Similarly,6.997
becomes7.00.
CASE3:
Inroundingoffnumbers,ifthefirstfiguredroppedis5,andallthefigures
followingthefivearezerooriftherearenofiguresafterthe5,thenthe
lastfigurekeptshouldbeunchangedifthatlastfigureiseven.For
example,ifonlyonedecimalistobekept,then6.6500becomes6.6.
Forexample,ifonlytwodecimalsaretobekept,then7.485becomes
7.48.

GET THESE RULES FOR ROUNDING OFF
NUMBERS
CASE4:
Inroundingoffnumbers,ifthefirstfiguredroppedis5,andallthefigures
followingthefivearezerooriftherearenofiguresafterthe5,thenthe
lastfigurekeptshouldbeincreasedby1ifthatlastfigureisodd.For
example,ifonlytwodecimalsaretobekept,then6.755000becomes
6.76.
Forexample,ifonlytwodecimalsaretobekept,8.995becomes9.00.
CASE5:
Inroundingoffnumbers,ifthefirstfiguredroppedis5,andthereareany
figuresfollowingthefivethatarenotzero,thenthelastfigurekept
shouldbeincreasedby1.Forexample,ifonlyonedecimalistobe
kept,then6.6501becomes6.7.
Forexample,ifonlytwodecimalsaretobekept,then7.4852007
becomes7.49.

Problemscreatedby roundoff error
•28Americanswerekilled on February25,
1991by an IraqiScud missilein Dhahran,
SaudiArabia.
•The
and
patriot defensesystemfailedtotrack
intercepttheScud.Why?
6

Problemwith Patriotmissile
•Clockcycleof1/10secondswas
representedin24-bitfixedpoint
registercreatedanerrorof9.5x
10
-8
seconds.
•Thebatterywasonfor100
consecutivehours,thuscausing
aninaccuracyof
s 3600s
1hr
=9.510
−8
=0.342s
100hr
0.1s
7

Problem(cont.)
Theshift calculatedin the rangingsystem
ofthe missilewas 687 meters.

•Thetargetwas consideredto beout of
137rangeat
meters.
adistancegreaterthan
8

Some disasters caused by
numerical errors?
➢Explosion of the Ariane 5
➢EURO page: Conversion Arithmetic's
➢The Vancouver Stock Exchange
➢Rounding error changes Parliament makeup

Explosion of the Ariane 5

Explosion of the Ariane 5

EURO page: Conversion
Arithmetic's

EURO page: Conversion
Arithmetic's

The Vancouver Stock Exchange

Rounding error changes
Parliament makeup

Rounding error changes
Parliament makeup

Effectof CarryingSignificant
DigitsinCalculations
9

RULESFORSIGNIFICANTFIGURES
1.Allnon-zeronumbersAREsignificant.Thenumber33.2hasTHREEsignificantfigures
becauseallofthedigitspresentarenon-zero.
2.Zerosbetweentwonon-zerodigitsAREsignificant.2051hasFOURsignificantfigures.
Thezeroisbetweena2anda5.
3.LeadingzerosareNOTsignificant.They'renothingmorethan"placeholders."The
number0.54hasonlyTWOsignificantfigures.0.0032alsohasTWOsignificantfigures.
Allofthezerosareleading.
4.TrailingzerostotherightofthedecimalAREsignificant.ThereareFOURsignificant
figuresin92.00.
92.00isdifferentfrom92:ascientistwhomeasures92.00millilitersknowshisvalueto
thenearest1/100thmilliliter;meanwhilehiscolleaguewhomeasured92millilitersonly
knowshisvaluetothenearest1milliliter.It'simportanttounderstandthat"zero"does
notmean"nothing."Zerodenotesactualinformation,justlikeanyothernumber.You
cannottagonzerosthataren'tcertaintobelongthere.

RULESFORSIGNIFICANTFIGURES
5.TrailingzerosinawholenumberwiththedecimalshownAREsignificant.Placinga
decimalattheendofanumberisusuallynotdone.Byconvention,however,this
decimalindicatesasignificantzero.Forexample,"540."indicatesthatthetrailingzeroIS
significant;thereareTHREEsignificantfiguresinthisvalue.
6.TrailingzerosinawholenumberwithnodecimalshownareNOTsignificant.Writing
just"540"indicatesthatthezeroisNOTsignificant,andthereareonlyTWOsignificant
figuresinthisvalue.
7.ExactnumbershaveanINFINITEnumberofsignificantfigures.Thisruleappliesto
numbersthataredefinitions.Forexample,1meter=1.00meters=1.0000meters=
1.0000000000000000000meters,etc.
8.Foranumberinscientificnotation:Nx10
x
,alldigitscomprisingNAREsignificantby
thefirst6rules;"10"and"x"areNOTsignificant.5.02x10
4
hasTHREEsignificant
figures:"5.02.""10and"4"arenotsignificant.
Rule8providestheopportunitytochangethenumberofsignificantfiguresinavalueby
manipulatingitsform.Forexample,let'strywriting1100withTHREEsignificantfigures.
Byrule6,1100hasTWOsignificantfigures;itstwotrailingzerosarenotsignificant.Ifwe
addadecimaltotheend,wehave1100.,withFOURsignificantfigures(byrule5.)But
bywritingitinscientificnotation:1.10x10
3
,wecreateaTHREE-significant-figurevalue.

Truncationerror
•Errorcausedbytruncatingor
mathematicalapproximating
procedure.
a

ExampleofTruncationError
Takingonly a fewtermsofaMaclaurinseriesto
e
x
approximate
2 3
x x
e
x
=1+x+++....................
2!3!
Ifonly 3 termsareused,
x
2
 
x
Error=e −1+x+



Truncation
2!

AnotherExampleof Truncation
Error
f(x)xUsingafinite toapproximate
f(x+x)−f(x)
f(x)
x
P
ine
Figure1.Approximatederivativeusing finiteΔx
secant line
tangent l
Q

AnotherExampleof Truncation
Error
Usingfinite
integral.
rectanglestoapproximatean
y
90
y =x
2
60
30
0 x
0 1.5 3 4.5 6 7.5 9 10.5 12

Example1—Maclaurinseries
e
1.2
Calculatethevalueofwithanabsolute
relativeapproximateerroroflessthan1%.
2 3
=1+1.2+
1.2
+
1.2
e
1.2
+...................
2!3!
6termsarerequired.Howmanyarerequiredtoget
atleast1 significantdigitcorrectinyouranswer?
n
e
1.2
E
a

a%
1 1
2 2.2 1.2 54.545
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
5 3.2944 0.0864 2.6226
6 3.3151 0.020736 0.62550

Example2—Differentiation
f(x+x)−f(x)
x
2
f(x)=f(3)Find
and
for usingf(x)
x
x=0.2
f(3+0.2)−f(3)
f
'
(3)=
0.2
f(3.2)−f(3)
2 2
3.2 −3 10.24−9 1.24
0.2
== 6.2= ==
0.2 0.2 0.2
Theactualvalueis
f
'
(x)=2x,f
'
(3)=23=6
Truncationerroristhen,6−6.2=−0.2
Canyou find thetruncationerrorwithx=0.1

Example3—Integration
Usetworectanglesofequalwidthto
approximatethearea underthecurvefor
overtheinterval[3,9]x
2
(x)=f
9

3
x
2
dx
y
90
y=x
2
60
30
0 x
0 3 6 9 12

Integrationexample(cont.)
Choosinga widthof3, wehave
9
x
2
dx=(x
2
)(6−3)+(x
2
)

3
(9−6)
x=3 x=6
=(3
2
)3+(6
2
)3
=27+108=135
Actualvalueisgivenby
9
x
3

9

9
3
−3
3

x
2
dx= = =234 

3 33

3
Truncationerroristhen
234−135=99
Canyou find thetruncationerrorwith4 rectangles
26
?

PropagationofErrors

PropagationofErrors
Innumerical methods,the calculations are not
madewithexactnumbers.How dothese
inaccuraciespropagatethroughthecalculations?

Example1:
Findthebounds for thepropagationin addingtwo
if one is calculating X+Ywhere
X= 1.5 0.05
Y= 3.4 0.04
Solution
numbers.Forexample
Maximumpossiblevalue of X1.55andY= 3.44=
Maximumpossiblevalue of XY=1.55+ 3.44= 4.99+
possiblevalue of X=1.45and Y= 3.36.Minimum
possiblevalue of X+Y= 1.45+ 3.36= 4.81Minimum
Hence
4.81≤ X + Y≤4.99.

Propagationof ErrorsInFormulas
Iff is a functionofseveralvariables
possible value of
X
1,X
2,X
3,.......,X
n−1,
is
X
n
thenthemaximum the errorinf
∂f ∂f ∂f ∂f
∆f≈ ∆X
1+ ∆X
2+.......+ ∆X
n−1+ ∆X
n
∂X
1 ∂X
2 ∂X
n−1 ∂X
n

Example2:
squareThestrain inanaxial member
sectionis given by
ofa cross-
F
∈=
Given
h
2
E
F=72±0.9N
h=4±0.1mm
E=70±1.5GPa
Findthe maximumpossible
strain.
error in themeasured

Example2:
Solution
72
∈=
(4×10
−3
)
2
(70×10
9
)
64.286×10
−6
64.286µ
=
=
∂∈ ∂∈ ∂∈
∆∈= ∆F+∆h+∆E
∂F ∂h ∂E

Example2:
∂∈ 1 ∂∈ ∂∈

F

2F
= ==
h
2
E∂F
Thus
∆E
h
2
E
2
h
3
E ∂E∂h
1
∆F
2F
∆h
F
∆E= + +
h
2
E h
3
E h
2
E
2
2×72
×0.0001
1
×0.9= +
(4×10
−3
)
2
(70×10
9
) (4×10
−3
)
3
(70×10
9
)
72
×1.5×10
9
+
(4×10
−3
)
2
(70×10
9
)
2
=5.3955µ
Hence
∈=(64.286µ±5.3955µ)

Example3:
Subtractionof numbersthat are nearly equalcan create unwanted
inaccuracies.Usingthe formulaforerrorpropagation,showthatthisistrue.
Solution
Let
z=x−y
Then
∂z
∆z=∆x+∆y
∂x
=
=
(1)∆x+
∆y
(−1)∆y
∆x+
Sotherelativechangeis
∆x+∆y∆z
z
=
x−y
∂z
∂y
(−

Example3:
Forexample if
x=2±0.001
y=2.003±0.001
0.001+0.001∆z
z
=
|2−2.003|
0.6667
66.67%
=
=

MeasuringErrors

Whymeasureerrors?
1)Todetermine the accuracyof
numericalresults.
2)Todevelop stoppingcriteriafor
iterativealgorithms.

TrueError
◼Definedasthedifferencebetweenthetrue
valuein acalculationandtheapproximate
valuefoundusinganumericalmethodetc.
TrueError=TrueValue–ApproximateValue

Example—TrueError
can bef′(x)Thederivative, ofa functionf(x)
approximatedby theequation,
f(x+h)−f(x)
f'(x)≈
h
h=0.3and7e
0.5x
f(x)=
a)
b)
c)
If
Findthe approximatevalueoff'(2)
True
True
value of
error for
f'(2)
part (a)

Example(cont.)
Solution:
a)For andx=2 h=0.3
f(2+0.3)−f(2)
f'(2)≈
0.3
f(2.3)−f(2)
=
0.3
7e
0.5(2.3)
−7e
0.5(2)
=
0.3
22.107−19.028
=10.263=
0.3

Example(cont.)
Solution:
b)The exactvalue of can be foundbyusingf'(2)
ourknowledge ofdifferentialcalculus.
7e
0.5x
f(x)=
f'(x)=7×0.5×e
0.5x
3.5e
0.5x
=
So thetrue value of is
f'(2)
3.5e
0.5(2)
f'(2)=
=9.5140
Trueerror is calculatedas
E
t =TrueValue –ApproximateValue
=9.5140−10.263=−0.722

RelativeTrueError
◼Defined astheratio betweenthetrue
error,and thetrue value.
TrueError

t)=RelativeTrueError(
TrueValue

Example—RelativeTrueError
Followingfromthe previousexample fortrue error,
findthe relative true error for atf'(2)7e
0.5x
f(x)=
withh=0.3
Fromtheprevious example,
E
t =−0.722
Relative True Error is definedas
TrueError
∈=
t
TrueValue
−0.722
= =−0.075888
9.5140
as a percentage,

t=−0.075888×100%=−7.5888%

ApproximateError
◼Whatcan be done
knownor are very
◼Approximate error
iftrue values are not
difficulttoobtain?
isdefined asthe
difference between the present
approximationand theprevious
approximation.
ApproximateError(E
a)=PresentApproximation–PreviousApproximation

Example—ApproximateError
For at findthe following,x=27e
0.5x
f(x)=
f′(2)
f′(2)
a)
b)
c)
using
using
h=0.3
h=0.15
f′(2)approximateerror forthevalueof forpartb)
Solution:
a)For andx=2 h=0.3
f(x+h)−f(x)
f'(x)≈
h
f(2+0.3)−f(2)
f'(2)≈
0.3

Example
Solution:(cont.)
f(2.3)−f(2)
(cont.)
=
0.3
7e
0.5(2.3)
−7e
0.5(2)
=
0.3
22.107−19.028
= =10.263
0.3
andb)Forx=2 h=0.15
f(2+0.15)−f(2)
f
'
(2)≈
0.15
f (2.15)−f (2)
=
0.15

Example
Solution:(cont.)
(cont.)
7e
0.5(2.15)
−7e
0.5(2)
=
0.15
20.50−19.028
=9.8800=
0.15
c)So
E
a
the approximateerror,isE
a
=PresentApproximation–PreviousApproximation
=9.8800−10.263
=−0.38300

RelativeApproximateError
◼Defined astheratio between the
approximate error
approximation.
(∈
a)
and the present
ApproximateError
RelativeApproximateError =
PresentApproximation

Example—Relative Approximate Error
7e
0.5x
f(x)=
For at ,findtherelative approximatex=2
errorusingvalues from
Solution:
andh=0.3 h=0.15
f′(2)=10.263From
using
E
a
Example 3,the approximatevalue of
and usingh=0.3 h=0.15f′(2)=9.8800
=PresentApproximation–PreviousApproximation
=9.8800−10.263
=−0.38300

Example
Solution:(cont.)
ApproximateError
(cont.)

a=
PresentApproximation
−0.38300
=−0.038765=
9.8800
as a percentage,

a =−0.038765×100%=−3.8765%
Absoluterelative approximateerrors
becalculated,
may alsoneed to

a=|−0.038765|=0.038765or3.8765
%

HowisAbsoluteRelative Error usedas
stopping criterion?
a
If whereis a pre-specified tolerance,then|∈
a|≤∈
s ∈
s
nofurtheriterationsare necessaryand the process
stopped.
is
Ifat leastmsignificant digitsarerequiredtobe
correct in the finalanswer,then
0.5×10
2−m
%|∈ |≤
a

TableofValues
7e
0.5x
=f(x)
For at withvaryingstepsize,x=2 h
h
f′(2) ∈
a m
0.3 10.263 N/A 0
0.15 9.8800 3.877% 1
0.10 9.7558 1.273% 1
0.01 9.5378 2.285% 1
0.001 9.5164 0.2249% 2

1. http://numericalmethods.eng.usf.edu
2.
http://numericalmethods.eng.usf.edu/topics/sources_of_err
or.html
3. http://numericalmethods.eng.usf.edu/topics/propagatio
n_of_errors.html
4. http://numericalmethods.eng.usf.edu/topics/measuring
_errors.html
References

THEEND
Tags