Upload
castello31659089
View
210
Download
5
Embed Size (px)
Citation preview
Faculty of Mechanical Engineering
NOOR SYAHADAH BINTI YUSSOFF
2008407362
EMD5M1B
MEC 500: Numerical Method with Application
Assignment 01
Question 01
1a. Briefly describe round-off and truncation errors and measures to reduce these errors in
practice?
Answer: Round-off errors - Originate from the fact that computers retain only a fixed
number of significant figures during a calculation.
- Numbers such as π, e, or √ 7 cannot be expressed by a fixed
number of significant figures. Therefore, they cannot be
represented exactly by the computer.
Truncation errors - are those that result from using an approximation in place
of an exact mathematical procedure.
- was introduced into the numerical solution because the
difference equation only approximates the true value of the
derivatives.
1b. Briefly describe the terms true error, approximate error and stopping criterion.
Answer: i) True Error: True error,Et is the difference between the true value in a
calculation and the approximate value found using a numerical
method etc.
True Error, Et = True Value – Approximate Value (+/-)
ii) Approximate Error: Approximate error,Ea is defined as the difference between
the present approximation and the previous approximation.
Approximate Error (Ea) = Present Approximation – Previous
Approximation
iii) Stopping Criterion: Since an iterative method computes successive
approximations to the solution of a linear system, a practical
test is needed to determine when to stop the iteration. Ideally
this test would measure the distance of the last iterate to the
true solution, but this is not possible. Instead, various other
metrics are used, typically involving the residual.
A good stopping criterion should
1. identify when the error is small enough to stop,
2. stop if the error is no longer decreasing or decreasing too slowly
3. Limit the maximum amount of time spent iterating.
1c. Use zero –through third-order Taylor series expansions to predict f(6) for
f ( x )=x3+12 x2−100 x−6using a base point at x=1 . Compute the true percent relative
error, ε t, for each approximation. Comment on the results.
Answer:
f ( x )=x3+12 x2−100 x−6
x i=0 , h=1, x i+1=1
Zero order, f ( x ) : f ( x i+1 )≅ f ( x i )
f (1 )≅ f (0 )
≈−6 f (0 )=−6 , f (1 )=−93
True Error, Et = True Value – Approximation
= −6−¿(−93¿
= 87
True value, = Approximation + Error
= −93+ (−6 )
= −99
True percent Error, ε t = true errortrue value
× 100
=87
−99 ×100
= 87.7 %
First order, f ' ( x i ) = 3 x2+24 x−100
For n=1,
f ' (0 )=3¿
¿−100
f ( x i+1 )≅ f ( x i )+f ' ( x i ) h
≅−6−100 h
Substituting h=1 f ' (1 ) ≈−106
True Error, Et = True Value – Approximation
= −93−(−106)
= 13
True value, = Approximation + Error
= −106+13
= −93
True percent Error, ε t = true errortrue value
× 100
=1393
×100
= 13.98 %
Second order, f ' ' ( x i ) = 6 x+24
For n=2 ,the second derivative is evaluated at x=0
f ' (0 )=6 (0 )+24
¿24
f ( x i+1 )≅ f ( x i )+f ' ( x i ) h+f ' ' ( x i ) h2
≅−6+ (−100 ) h+12 h2 Substituting
h=1 ≈−94
True Error, Et = True Value – Approximation
= −93−¿(−94 ¿
= 1
True value, = Approximation + Error
= −94+1
= −93
2
True percent Error, ε t = true errortrue value
× 100
=1
−93 ×100
= −1.08 %
Third order, f ' ' ' ( x i ) = 6 x
For n=3 ,the second derivative is evaluated at x=0
f ' ' (0 )=6=6
f ( x i+1 )≅ f ( x i )+f ' ( x i ) h+f ' ' ( x i )
2!h2+
f ' ' ' ( x i )3 !
h3
≅−6+ (−100 )1+ 242 ×1
(1)2+ 63 ×2 ×1
(1 )3
Substituting h=1 ≈−93
True Error, Et = True Value – Approximation
= −93−¿(−93¿
= 0
True value, = Approximation + Error
= −93+0
= −93
True percent Error, ε t = true errortrue value
× 100
=0
−93 ×100
= 0 %
The inclusion of the second and third derivatives results in exactly the same equation we started
with;
f ( x )=−6−100h+12h2 +h3
Where the remainder term;
R3 ¿f 4()4 !
h4=0 because the fourth derivative of a third-order polynomial is zero.
Consequently, the Taylor series expansion to the third derivative yields an exact estimate at
x i+1=1 ;
f (1 )=−6−100 (1 )+12 (1 )2 +(1 )3=−93
1d. Use forward, backward and centered difference approximations to estimate the first
derivative of f ( x )=x3+12 x2−100−6. Evaluate the derivative at x=2 using step size of
h=0.5. Compare the result with the true value of the derivative. Interpret the result on
the basis of the remainder term of the Taylor series expansion.
True Value,f (x) = x3+12 x2−100 x−6
f '( x) = 3 x2+24 x−100
f '(2) =3¿
= −40
Solution:
h=0.5
x i−1=1.5
x i=2
x i+1=2.5
f ( x i−1 )=x3+12 x2−100 x−6
=(1.5)3+12¿
= −125.625
f ( x i )=x3+12 x2−100 x−6
=(2)3+12¿
¿ −150
f ( x i+1 )=x3+12 x2−100 x−6
=(2.5)3+12¿
= −165.375
Forward, f ' ( x i )=f ( x i+1)−f (x i)
h+0(h)
¿(−165.375 )−(−150)
0.5+0 (0.5)
¿ −30.75
True percent Error, |εt| = true errortrue value
× 100
=−40−(−30.75)
40 ×100
= 23.125 %
Backward, f ' ( x i )=f ( x i )−f (x i−1)
h+0 (h)
¿(−150 )−(−125.625)
0.5+0 (0.5)
¿ −48.75
True percent Error,|εt| = true errortrue value
× 100
=−40−(−48.75)
−40 ×100
= 21.875 %
Centered, f ' ( x i )=f ( x i+1)− f (x i−1)
2 h+0(h2)
¿(−165.375 )−(−125.625)
2(0.5)+0¿
¿ −39.75
True percent Error, |εt| = true errortrue value
× 100
=−40−(−39.75)
−40 ×100
= 0.625 %
To estimate the first derivative of f ( x )=x3+12 x2−100−6 , the centered difference
approximation will used to get the value more accurately.
Question 02
2a. In Finding roots of equations, briefly describe, how do we determine all the possible
roots of an equation?
One method to obtain an approximate solution is to plot the function and determine where it
crosses the x axis. This point, which represents the x value for which f(x) = 0, is the roots. Although
the graphical methods are useful for obtaining rough estimates of roots, they are limited because of
their lack of precision. Numerical Method such as fixed point iteration, The Newton-Raphson method,
bisection method and so on, is an alternative approach that be used trial and error.
2b. Roots finding using open methods such as Newton-Raphson and Secant methods may
Sometimes NOT converge to the true values. Describe the procedure for checking of the
possibility of convergence of open methods.
The procedure for checking of the possibility of convergence of open methods can be
depicted graphically. We graphed a function to visualize its structure and behavior. An alternative
graphical approach is to separate the equation into two component parts, can be plotted separately.
The x values corresponding to the intersections of these functions represent the roots of f(x) = 0.
2c. Newton-Raphson formula given below is based on first order Taylor expansion of the
function f(x) about xi . Derive the Newton-Raphson formula using the second order
Taylor expansion of the function f(x) about xi.
Answer:
Let F ( x )=0
For the derivation of the formula used for solving a one-dimensional problem, we simply make a first-
order Taylor series expansion of the function F(x)
F (x)=F (x )+hF ’ (x) eq.1
Use the following notation for the x-values:
xi= x
x i+1=x+h eq.2
Substitute eq.1 in eq.2
F (x)=F (x i)+( x i+1−x i) F ’ (x i)
When x=0 ,
F (0)=F (x i)+( x i+1−x i)F ’( xi)
Then,
x i+1=x i−f (x i)f '(x i)
2d. Using incremental search, prove that function f ( x )=6 x3−26 x2+32 x−10 has
three roots between x=0 andx=3
Initial guess for this function is x i=0 and xu=3
First iteration;
xr 1=x i+xu
2
¿0+3
2
¿1.5
f ( x i 1 )=f (0 )=6 (0 )3−26 (0 )2+32 (0 )−10=−10
f ( xr 1)=f (1.5 )=¿ 6 (1.5 )3−26 (1.5 )2+32 (1.5 )−10=−0.25
f ( x i ) ∙ f ( xr 1 )=2.5 (¿0 ) Root is in upper interval
Second iteration;
xr 2=0+1.5
2
¿0.75
f ( x i 2 )=f (0 )=6 (0 )3−26 (0 )2+32 (0 )−10=−10
f ( xr 2)=f (0.75 )=¿ 6 (0.75 )3−26 (0.75 )2+32 (0.75 )−10=1.90625
f ( x i 2 ) ∙ f ( xr 2 )=−19.0625 (¿0 ) Root is in lower interval
ε a=0.75−1.5
0.75 ×100 %
¿−100 %
Third iteration;
xr 3=0.75+1.5
2
¿1.125
f ( x i 3 )=f (0.75 )=6 (0.75 )3−26 (0.75 )2+32 (0.75 )−10=1.90625
f ( xr 3)=f (1.125 )=¿ 6 (1.125 )3−26 (1.125 )2+32 (1.125 )−10=1.637
f ( x i 3 ) ∙ f ( xr 3 )=3.121 (¿0 ) Root is in upper interval
ε a=1.125−0.75
1.125 ×100 %
¿33.33 %
Fourth iteration;
xr 4=1.125+1.5
2
¿1.3125
f ( x i 4 )=f (1.125 )=¿ 6 (1.125 )3−26 (1.125 )2+32 (1.125 )−10=1.637
f ( xr 4 )=f (1.3125 )=6 (1.3125 )3−26 (1.3125 )2+32 (1.3125 )−10=0.777
f ( x i 4 )∙ f ( xr 4 )=1.2712 (¿0 ) Root is in upper interval
ε a=1.3125−1.125
1.3125 ×100%
¿14.28 %
sign change in calculation, so there is the root between x=0 andx=3.
2e. Use MATLAB to graphically locate all roots of function f ( x )=6 x3−26 x2+32 x−10.
Clearly indicate all roots on the plot of the graph.
2f. Use Bisection method, conduct four iterations with initial guesses of x i=2.0 and xu=3.0
to locate the highest root of the function and compute the percentage approximation relative
error.
Problem statement. Use bisection method with four iterations with initial guesses of x i=2.0
and xu=3.0 to locate the highest root of the function.
First iteration;
xr 1=x i+xu
2
¿2.0+3.0
2
¿2.5
f ( x i 1 )=f (2.0 )=6 (2.0 )3−26 (2.0 )2+32 (2.0 )−10=−2
f ( xr 1)=f (2.5 )=¿ 6 (2.5 )3−26 (2.5 )2+32 (2.5 )−10=1.25
f ( x i ) ∙ f ( xr 1 )=−2.5 (¿0 ) root is in lower interval
Second iteration;
xr 2=2.0+2.5
2
¿2.25
f ( x i 2 )=f (2.0 )=6 (2.0 )3−26 (2.0 )2+32 (2.0 )−10=−2
f ( xr 2)=f (2.25 )=¿ 6 (2.25 )3−26 (2.25 )2+32 (2.25 )−10=−1.28125
f ( x i 2 ) ∙ f ( xr 2 )=2.563 (¿0 ) root is in upper interval
ε a=2.25−2.5
2.25 ×100%
¿−11.1%
Third iteration;
xr 3=2.25+2.5
2
¿2.375
f ( x i 3 )=f (2.25 )=6 (2.25 )3−26 (2.25 )2+32 (2.25 )−10=−1.281
f ( xr 3)=f (2.375 )=¿ 6 (2.375 )3−26 (2.375 )2+32 (2.375 )−10=−0.2773
f ( x i 3 ) ∙ f ( xr 3 )=0.3552 (¿0 ) root is in upper interval
ε a=2.375−2.25
2.375 ×100%
¿5.26 %
Fourth iteration;
xr 4=2.375+2.5
2
¿2.4375
f ( x i 4 )=f (2.375 )=¿ 6 (2.375 )3−26 (2.375 )2+32 (2.375 )−10=−0.2773
f ( xr 4 )=f (2.4375 )=6 (2.4375 )3−26 (2.4375 )2+32 (2.4375 )−10=0.4165
f ( x i 4 )∙ f ( xr 4 )=−0.1155 (¿0 ) root is in lower interval
ε a=2.4375−2.375
2.4375 ×100%
¿2.56%
So, the highest root of the function is x=2.563
2g. Use the Newton-Raphson’s method and with an initial guess ofx0=2.0, try estimate the
highest root f ( x )=6 x3−26 x2+32 x−10. Give your comment on what happens and propose
solution to this problem?
Problem statement. Use the Newton-Raphson method to estimate the highest root of
f ( x )=6 x3−26 x2+32 x−10, employing an initial guess of x0=2.0. The first derivative of the
function can be evaluated as f ' ( x )=18x2−52 x+32 which can be substituted along with the original
function into
equation:
x i+1=x i−f (x i)f ' (x i)
to give:
x i+1=x i−6 x i
3−26 x i2+32 x i−10
18 x i2−52 x i+32
starting with an initial guess of x0=2.0, this iterative equation can be applied to compute:
i=0 , x0=2.0 ;
x1=x0−6 x0
3−26 x02+32 x0−10
18 x02−52 x0+32
x1=2.0−6 (2.0 )3−26 (2.0 )2+32 (2.0 )−10
18 (2.0 )2−52 (2.0 )+32
x1=2.0
i=1 , x1=2.0 ;
x2=x1−6 x1
3−26 x12+32 x1−10
18 x12−52 x1+32
x2=2.0−6 (2.0 )3−26 (2.0 )2+32 (2.0 )−10
18 (2.0 )2−52 (2.0 )+32
x2=2.0
Based on the calculation above, the value of x1and x2 was the same which is 2.0 if we start with initial
guess of 2.0. If we wrongly choose the initial guess, the problem cannot be settled. So, the best
solution to this problem is we start the estimating highest root with initial guess of x0=0.
i=0 , x0=0 ;
x1=x0−6 x0
3−26 x02+32 x0−10
18 x02−52 x0+32
x1=0−6 ( 0 )3−26 (0 )2+32 (0 )−10
18 (0 )2−52 (0 )+32
x1=0.3125
ε t=x1−x0
x1
×100 %
ε t=0.3125−0
0.3125 ×100 %
¿100 %
i=1 , x1=0.3125 ;
x2=x1−6 x1
3−26 x12+32 x1−10
18 x12−52 x1+32
x2=0.3125−6 (0.3125 )3−26 (0.3125 )2+32 (0.3125 )−10
18 (0.3125 )2−52 (0.3125 )+32
x2=0.4471
ε t=x2−x1
x2
×100%
ε t=0.4471−0.3125
0.4471 ×100%
¿30.11%
i=2 , x2=0.4471 ;
x3=x2−6 x2
3−26 x22+32 x2−10
18 x22−52 x2+32
x3=0.4471−6 (0.4471 )3−26 (0.4471 )2+32 ( 0.4471 )−10
18 (0.4471 )2−52 (0.4471 )+32
x3=0.4758
ε t=x3−x2
x3
×100 %
ε t=0.4758−0.4471
0.4758 ×100%
¿6.03%
i=3 , x3=0.4758 ;
x4=x3−6 x3
3−26 x32+32 x3−10
18 x32−52 x3+32
x4=0.4758−6 (0.4758 )3−26 (0.4758 )2+32 (0.4758 )−10
18 (0.4758 )2−52 (0.4758 )+32
x4=0.4770
ε t=x4−x3
x4
×100 %
ε t=0.4770−0.4758
0.4770 ×100%
¿0.25 %
i=4 , x4=0.4770 ;
x5=x4−6 x4
3−26 x42+32 x4−10
18 x 42−52 x 4+32
x5=0.4770−6 (0.4770 )3−26 (0.4770 )2+32 (0.4770 )−10
18 (0.4770 )2−52 (0.4770 )+32
x5=0.4771
ε t=x5−x4
x5
×100 %
ε t=0.4771−0.4770
0.4771 ×100%
¿0.02 %
2h. Use MATLAB’s fzero function to determine all roots of f ( x )=6 x3−26 x2+32 x−10.