Professional Documents
Culture Documents
Example
dv(t)
ma=m = FG - FD = m g - FD v(t) = ?
dt
FD = CD v(t)
dv(t) m g - CD v(t)
=
dt m
gm CD
v(t) = 1 - exp m t
CD
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Example
Relax the mathematical model:
1 dv(t) m g - FD
v(t) CD AP
2
FD = =
2 dt m
v(t) = ?
Commands:
Defining variables
-b b-4a c -b b-4a c
x1 x2
2a 2a
Algorithm:
If D ≥ 0, calculate the two real roots using the equations, and write them
Stop
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
COMPUTATIONAL PROCEDURE
Frequently, several methods are available for the numerical solution of a given
mathematical problem. Few relevant criteria for selection of a method:
Accuracy
Efficiency
Numerical stability
Programming simplicity
Versatility
Computer storage requirements
Interfacing with available software
Previous experience with a given method
REVIEW OF CALCULUS
Given: f(x), a real-valued continuous
f(x)
function
Open : (a , b) : in a to b f(a)
x
Closed : [a , b] : in and on a to b a b
Continuous Function
When f(x) is continuous on [a , b] and f '(x) exists for all interior points, then at
some ξ
f(b) - f(a)
f ' ( , a b
ba
f(x)
Slopes are equal
a x
b
ξ
f (x) dx (b - a) f ()
a
, ab
f(x)
Areas are equal
f(ξ)
x
ξ b
a
Similarly, if f (x) and g (x) are continuous and integrable on [a , b], and if g (x)
does not change sign on [a , b], then
b b
Taylor Series
If a function f(x) and all its derivatives exist at a point x = x 0, the function f(x) can
be represented by an infinite power series in powers of (x - x 0).
(x - x 0 )2 (x - x 0 )n (n)
f(x) f(x 0 ) (x - x 0 ) f '(x 0 ) f ''(x 0 ) ... f (x 0 ) R
2! n!
(x - x 0 )n1 (n1)
R f ( ) Remember radius of convergence
(n 1) !
Set x – x0 = x :
(x)n1
R f (n1) ( ) , x0 < < x
(n 1) !
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
English Mathematician
1685 - 1731
h2 hn (n)
f (x) f (x 0 ) h f '(x 0 ) f ''(x 0 ) ... f (x 0 ) R
2! n!
hn1
R f (n1) ( ) , x0 < < x
(n 1) !
h2 hn (n)
f (x 0 h) f (x 0 ) h f '(x 0 ) f ''(x 0 ) ... f (x 0 ) R
2! n!
hn1
R f (n1) ( ) , x0 < < x
(n 1) !
b b
x x
(x - t)n ( n 1) (x - t)n
R= f (t) dt = f ( n 1) ( ) x n! dt
x0
n! 0
(x - x 0 )n 1
R= f ( n 1)
( ) , x0 < < x
(n+1)!
f(x)
f(x)
Three terms
f(x0+h) ≈ f(x0) + h f ’(x0) + h2/2 f ’’(x0)
Two terms
f(x0+h) ≈ f(x0) + h f ’(x0)
One term
f(x0+h) ≈ f(x0)
x0 x = x0+h x
h
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Example 1.
1
Consider the function: f (x) , x 1
1-x
(x - x 0 )2 (x - x 0 )3
f(x) f(x 0 ) (x - x 0 ) f '(x 0 ) f ''(x 0 ) f '''(x 0 ) ...
2! 3!
(x - x 0 )n (n) (x - x 0 )n1 (n1)
... f (x 0 ) f ( ) , x0 x
n! (n 1) !
1 2
Derivatives: f ' (x 0 ) f ' ' (x 0 )
(1 - x 0 ) 2 (1 - x 0 ) 3
Approximations to f(x):
1
One term, f (x) Error (x - x 0 ) f ' ( )
First Order 1- x0
1 (x - x 0 ) (x - x 0 ) 2
Two terms, f (x) Error f ' ' ( )
Second Order 1 - x 0 (1 - x 0 ) 2 2!
Three terms, 1 (x - x 0 ) (x - x 0 ) 2 (x - x 0 ) 3
f (x) 2
Error f ' ' ' ( )
Third Order 1 - x 0 (1 - x 0 ) (1 - x 0 ) 3 3!
Example 2. If x0 = 1.6. Estimate f(2) using two terms in the Taylor series
expansion; Find the true and estimated errors
f(x) - P1(x)
True Relative Error: Etrue (x) *100 in percent
f(x)
(x - x 0 )2
Estimated Error: Eest (x) f ''( )
2!
-0.5
-1
-1.5
-2
-2.5
-3
-3.5
-4 1/(1-x)
-1/0.6
-1/0.6+(x-1.6)/0.6**2
-4.5 -1/0.6+(x-1.6)/(0.6)**2+(x-1.6)**2/(-0.6)**3
-5
-5.5
1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
Example 3.
yn1 = e - (n + 1) yn
n yn ,single
0 1.71828183
1 1.00000000
2 0.71828183
3 0.56343634
4 0.46453647
5 0.39559948
6 0.34468495
7 0.30548718
8 0.27438439
9 0.24882232
10 0.23005863
11 0.18763690
12 0.46663903
13 -3.34802556
14 49.59063967 Why is this happening?
15 -741.14131322
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
n yn ,single yn ,double
0 1.71828183 1.71828183
1 1.00000000 1.00000000
2 0.71828183 0.71828183
3 0.56343634 0.56343634
4 0.46453647 0.46453646 Use double precision
5 0.39559948 0.39559955
all the time
6 0.34468495 0.34468454
7 0.30548718 0.30549004
8 0.27438439 0.27436153
9 0.24882232 0.24902803
10 0.23005863 0.22800152
11 0.18763690 0.21026516
12 0.46663903 0.19509991
13 -3.34802556 0.18198305
14 49.59063967 0.17051906
15 -741.14131322 0.16049585
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Example 4.
The “machine epsilon”, ε, of a computer is the smallest positive number in the form
ε = 2-k such that 1.0 + 1.0 . It is also called the unit of round-off error of the
machine. Use the following algorithm to compute an approximate value of ε for the
computer that you intend to use in this course.
input s == 1.0
for k = 1, 2, … 100 do
s == 0.5 * s
t == s + 1.0
if t ≤ 1.0 then
s == 2.0 * s
output k-1 , s
stop
end if
end
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Example 5.
x
Expand the function f(x) = sin in Taylor series around the point x0 = 0
2
(MacLaurin series). Find the expression for the remainder, and estimate the
number of terms that would be needed to guarantee six significant digit accuracy
Six significant digit accuracy means that the error should be less than or equal to
0.5 10-6.
x x x x
3 5 3 7 5 7
2n+1
x 2n+1
R = sin , -1 < < 1 n = 1, 2, 3, …
2 (2 n + 1)! 2
2n+1
1
R max = < 0.5 10-6 Find n.
2 (2 n + 1)!
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
No of non- Rmax
zero terms
1 6.45964 10-1
2 7.96926 10-2 n = 6 is the required number
3 4.68175 10-3 of non-zero terms
4 1.60441 10-4
5 3.59884 10-6
6 5.69217 10-8
f f
f(x,y) f(x 0,y0 ) (x - x 0 ) (y - y 0 ) +
x x0 ,y 0 y x0 ,y 0
1 2 f
2
2f 2f
(x - x 0 ) (y - y 0 ) 2
+ 2 (x - x 0 ) (y - y0 )
2! x 2 y 2 x y x ,y
x0 ,y 0 x0 ,y 0 0 0
+ ...
Example 6.
The Stefan-Boltzmann law states that the radiative energy, Φ, emitted from an
object is given by the relation
Φ = A ε σ T4
Φ(r, ε, T) = 4 π r2 εσ T4 => = r + + T
r T
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Jožef Štefan
Ludwig Boltzmann
Carinthian Slovene Physicist
Austrian physicist
1835-1893
1844-1906
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Solution of Example 6.
𝜕Φ 𝜕Φ 𝜕Φ
Partial derivatives: = 8 π r ε σ T4 = 4 π r2 σ T4 = 16 π r2 ε σ T3
𝜕𝑟 𝜕ε 𝜕T
𝜕Φ 𝜕Φ 𝜕Φ
= 445.3 = 4453 = 1.781
𝜕ε 𝜕𝑟 𝜕T
= r + + T = (4453) (0.01) + 445.3) (0.05) + (1.781) (20)
r T
= 102.42 W
APPROXIMATING FUNCTIONS
Objectives:
Replace a complicated function f(x) with a simpler function g(x) which is easier
to manipulate, i.e. differentiate, integrate, etc. (Note that transcendental
functions, such as ln(x), sin(x), erf(x), etc., cannot be evaluated by strictly
arithmetic operations without first finding approximating, simpler functions
such as a finite power series.)
Interpolate in tables of functional values
n
Power series: g (x) Pn (x) a i x i
i0
n n
Fourier Functions: g (x) a 0 a k cos (k x) a k sin (k x)
k 1 k 1
n
Exponentials g (x) a i e bi x
i0
Pn (x) a i xi
Rational Functions g (x) i0
m Pade approximation
i
Pm (x) i
c x
i0
French Mathematician
1768 – 1830
_
f ( x ) - f (x) / f (x)
Relative Change in solution
Condition Number _
Relative change in input data
( x - x) / x
Example: Sensitivity
Consider the problem of computing cosine function for arguments near π /2.
Let x ≈ π /2 and let h be a small perturbation to x.
Then, the error in cos(x + h) is given by
Absolute Error = cos(x + h) - cos(x) ≈ - h sin(x) ≈ - h
Relative Error ≈ - h tan(x) ≈ ∞
So, small changes in x near π /2 cause large relative changes in cos(x) regardless
of method for computing it.
x
Relative error in the input
x
Relative error in the functional value can be much larger or smaller than that
(relative error in) the input.
Prof. Dr. Faruk Arınç fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
x
Example 7: Find the condition number, CN, for f(x) =
1-x
(a) When x = 0.93 and
(b) When x = - 0.93
(c) Comment on the results by evaluating f(x) near 0.93 and - 0.93
ACCURACY
PRECISION
ERRORS
ERRORS