0% found this document useful (0 votes)
27 views39 pages

GS 4353 Numerical Analysis Week 1

Uploaded by

sajid.mhc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views39 pages

GS 4353 Numerical Analysis Week 1

Uploaded by

sajid.mhc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

GS 4353

NUMERICAL ANALYSIS AND


COMPUTER PROGRAMMING

Md. Rifat Hossain Bhuiyan


Lecturer
Department of CEE, IUT
GS 4353 INTRODUCTION TO NUMERICAL
NUMERICAL METHODS AND COMPUTER METHOD
PROGRAMMING

8/4/2022 2
What are Numerical Methods?
Techniques by which mathematical problems are formulated
so that they can be solved with simple arithmetic operations

Addition (+), Subtraction(-), Division (/), Multiplication (*)

This may involve a large number of tedious calculations

Thanks to digital computers!!

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 3
Example:
Newton’s
2nd law of
motion
F = ma
The Bungee Jumper Problem
The change in velocity is determined
by the gravitational forces acting on
the jumper versus the drag force.
cd = drag coefficient
m = mass of the jumper
g = gravitational acceleration
4
Analytical Solution

Considering
m = 68.1 kg
cd = 0.25 kg/m

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 5
Numerical Solution
Need to make some approximation regarding the time rate change
of velocity

𝑑𝑣 Δ𝑣 𝑣(𝑡𝑖+1 ) − 𝑣(𝑡𝑖 )
≈ =
𝑑𝑡 Δ𝑡 𝑡𝑖+1 − 𝑡𝑖

𝑑𝑣 𝑐𝑑 2
=𝑔− 𝑣
𝑑𝑡 𝑚

𝑐𝑑
𝑣 𝑡𝑖+1 = 𝑣 𝑡𝑖 + 𝑔 − 𝑣(𝑡𝑖 )2 (𝑡𝑖+1 − 𝑡𝑖 )
𝑚

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 6
Comparison with Analytical Solution
𝑐𝑑
𝑣 𝑡𝑖+1 = 𝑣 𝑡𝑖 + 𝑔 − 𝑣(𝑡𝑖 )2 (𝑡𝑖+1 − 𝑡𝑖 )
𝑚

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 7
Why learn Numerical Methods?

• Analytical solutions can be derived for only a limited class of


problems.

• A broad spectrum of problems can be solved.


• - complicated, nonlinear problems
• large systems of equations

• Intelligently use commercially available computer programs


(“packages”)

• To make your own customized program to tackle problems which


packages cannot solve

• Bolster your understanding of mathematics


8/4/2022 8
Why do we need to learn these in Civil
Engineering?

• For mathematical modeling and expressing physical observations in


mathematical terms.

• Interpolation is applied in calculating damage analysis of concrete


bridges, optimum speed on a freeway with a given range of frictions,
peak ground acceleration (earthquake acceleration) estimation in
emergency management etc.

• Error analysis is used in comparing approximate value with true


value while working with variable data sets.

• Taylor series is used in calculating Beam deflection analysis.

• Gaussian Elimination is used in determining accurate the ground co-


ordinates on the earth using co-ordinates of 4 satellites.

8/4/2022 9
Differentiation Integration

Model needs
some Simultaneous
mathematical Differential
linear
equations
procedures equations

Curve-fitting by
Non-linear
interpolation
equations
or regression

8/4/2022 10
Mathematical Procedures
𝑥 2 + 𝑦 2 = 34
Non-linear equations
𝑥 2 − 2𝑦 2 = 7

Some non-linear graphs

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 11
Mathematical Procedures
Linear Interpolation
Interpolation (Mostly used in Civil Engineering)
Several types of interpolation:
1) Linear
2) Polynomial
3) Spline
4) Trigonometric

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 12
Mathematical Procedures
Linear

Polynomial (more smooth)

Spline (more more smooth)

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 13
Mathematical Procedures
Curve fitting with regression

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 14
- truncation
Accuracy (all errors
numerical methods
- round-off
introduce errors) errors

Rate of convergence (how


quickly we can arrive at a
Characteristics solution)

of Numerical
Computing Numerical stability

Efficiency (computational
burden)

8/4/2022 GS 4353: Numerical Analysis and Computer Programming 15


GS 4353: Numerical Analysis and Computer Programming

GS 4353 ERRORS IN NUMERICAL METHODS


NUMERICAL METHODS AND COMPUTER
PROGRAMMING

8/4/2022 16
Errors in Numerical Methods
In numerical methods, approximations are used to express exact
mathematical operations

This gives rise to errors


How can we quantify it?

True error (𝐸𝑡 ) = True value - approximation


Percent relative true error (ε𝑡 ) = (True error (𝐸𝑡 ) / True value)*100

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 17
Errors in Numerical Methods
If the problem cannot be analytically solved, the true value will not
be known

We normalize the error with approximate value

Numerical methods use an iterative approach

-Present approximation is made based on previous approximation

Percent relative approximate Error,

𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑥. −𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑎𝑝𝑝𝑟𝑥.


ε𝑎 = × 100%
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑥.

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 18
Errors in Numerical Methods
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑥. −𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑎𝑝𝑝𝑟𝑥.
ε𝑎 = × 100%
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑥.
❑ Use absolute value
❑ Continue computations until a stopping
criterion is satisfied

as ε𝑎 < ε𝑠 A pre-specified tolerance level

The criteria used to ensure that the result is correct upto n


significant figures:

ε𝑎 < ε𝑠 = (0.5 × 102−𝑛 )%

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 19
Example 1.1 —True Error

The derivative, f (x) of a function f (x) can be


approximated by the equation,
f (x + h) − f (x)
f ' (x) 
h
If f (x) = 7e and h = 0.3
0.5x

a) Find the approximate value of f '(2)


b) True value of f '(2)
c) True error for part (a)

13
Example 1.1 (cont.)

Solution:
a) For x = 2 and h = 0.3
f (2 + 0.3) − f (2)
f ' (2) 
0.3
f (2.3) − f (2)
=
0.3
7e0.5(2.3) − 7e0.5(2)
=
0.3
22.107 −19.028
= = 10.263
0.3

14
Example 1.1 (cont.)

Solution:
b) The exact value of f ' (2) can be found by using
our knowledge of differential calculus.
f (x) = 7e0.5x
f ' (x) = 7  0.5  e0.5x
= 3.5e0.5x
So the true value of f ' (2) is
f ' (2) = 3.5e0.5(2)
= 9.5140
True error is calculated as
Et = True Value – Approximate Value
= 9.5140 −10.263 = −0.722
15
Example 1.2—Relative True Error

Following from the previous example for true error,


find the relative true error for f (x) = 7e0.5x at f '(2)
with h = 0.3
From the previous example,
Et = −0.722
Relative True Error is defined as
True Error
t =
True Value
− 0.722
= = −0.075888
9.5140
as a percentage,
t = −0.075888 100% = −7.5888%
16
Example 1.3 —Approximate Error

For f (x) = 7e0.5x at x = 2 find the following,


a) f (2)using h = 0.3
b) f (2) using h = 0.15
c) approximate error for the value of f (2)for part b)
Solution:
a) For x = 2 and h = 0.3
f (x + h) − f (x)
f ' (x) 
h
f (2 + 0.3) − f (2)
f ' (2) 
0.3

17
Example 1.3 (cont.)

Solution: (cont.)
f (2.3) − f (2)
=
0.3
7e0.5(2.3) − 7e0.5(2)
=
0.3
22.107 −19.028
= = 10.263
0.3
b) For x = 2 and h = 0.15
f (2 + 0.15) − f (2)
f ' (2) 
0.15
f (2.15) − f (2)
=
0.15
18
Example 1.3 (cont.)

Solution: (cont.)
7e 0.5(2.15) − 7e 0.5(2)
=
0.15
20.50 −19.028
= = 9.8800
0.15
c) So the approximate error, Ea is
Ea = Present Approximation – PreviousApproximation
= 9.8800−10.263
= −0.38300

19
Example 1.4 —Relative Approximate Error

For f (x) = 7e at x = 2 , find the relativeapproximate


0.5x

error using values from h = 0.3 and h = 0.15


Solution:
From Example 1.3, the approximate value of f (2)= 10.263
using h = 0.3 and f (2)= 9.8800 using h = 0.15
Ea = Present Approximation – PreviousApproximation
= 9.8800−10.263
= −0.38300

20
Example 1.4 (cont.)

Solution: (cont.)
Approximate Error
a =
PresentApproximation
− 0.38300
= = −0.038765
9.8800
as a percentage,
 a = − 0. 03876 5  1 0 0 % = −3.8765%

21
Roundoff Errors
Quantities such as π, 1/3 cannot be expressed by a fixed
number of significant figures

Roundoff errors arise because digital computers cannot


represent some quantities exactly.

- Digital computers have size and precision limits on their ability to represent
numbers.
- Certain numerical manipulations are highly sensitive to roundoff errors

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 29
Truncation Errors
Result from the use of approximations instead of exact
mathematical procedures.

Example: using finite number of terms to estimate the sum of an


infinite series, say
𝑥3 𝑥5 𝑥7
sin 𝑥 = 𝑥 − + − + ⋯
3! 5! 7!
Another example: using discrete steps in the solution of a
differential equation

𝑑𝑣 Δ𝑣 𝑣(𝑡𝑖+1 ) − 𝑣(𝑡𝑖 )
≅ =
𝑑𝑡 Δ𝑡 𝑡𝑖+1 − 𝑡𝑖

8/4/2022 30
Taylor Series
Taylor series is an important series that is used in expressing logarithm,
trigonometric functions into algebraic function.

Applications:

1) Einstein used Taylor series in explaining Brownian motion.


2) One super common example is when you use small angles in Physics. In
that case, you approximated sin(x) = x, x being the first term in the Taylor
series of sin(x).
3) Taylor series is important to derive another series called Maclaurine series.
4) Taylor series is important for approximation a value of a function.
5) In civil engineering, Taylor series is used in the beam deflection analysis.

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 31
Taylor Series
The general form of the Taylor series is given by
f ( x ) 2 f ( x ) 3
f ( x + h ) = f ( x ) + f ( x )h + h + h +
2! 3!
provided that all derivatives of f(x) are continuous and exist in the
interval [x, x+h]

Some examples of Taylor series:


x2 x4 x6
cos(x) = 1 − + − + 
2! 4! 6!
x3 x5 x7
sin( x) = x − + − + 
3! 5! 7!
x2 x3
e = 1+ x +
x
+ +
2! 3!

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 32
Derivation for Maclaurine Series for ex

Derive the Maclaurine series


2 3
x x
ex = 1+ x + + +
2! 3!
The Maclaurin series is simply the Taylor series about the point
x=0
h2 h3 h4 h5
f (x + h ) = f (x ) + f (x )h + f (x ) + f (x ) + f (x ) + f (x ) + 
2! 3! 4 5

h2 h3 h4 h5
f (0 + h ) = f (0) + f (0)h + f (0) + f (0) + f (0) + f (0) + 
2! 3! 4 5

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 33
Derivation for Maclaurine Series for ex

Since f ( x) = e x , f ( x) = e x , f ( x) = e x , ... , f n ( x) = e x and f n (0) = e0 = 1

the Maclaurin series is then


0 0
( e ) ( e ) 3
f ( h) = (e 0 ) + (e 0 ) h + h2 + h ...
2! 3!
1 2 1 3
= 1+ h + h + h ...
2! 3!
So,
x 2 x3
f ( x) = 1 + x + + + ...
2! 3!

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 34
How to quantify truncation error
The Taylor series: any smooth function can be approximated as a
polynomial

❑ The more terms are used the used, smaller the error
❑ smaller the spacing, smaller the error for a given number of terms.
GS 4353: Numerical Analysis and Computer Programming
8/4/2022 35
Truncation errors

Add terms until the approximate value of the approximate error


falls below an error criterion conforming to two significant figures.
GS 4353: Numerical Analysis and Computer Programming
8/4/2022 36
Total Numerical Error
The total numerical error is the summation of the truncation and roundoff errors.
The truncation error generally increases as the step size increases, while the
roundoff error decreases as the step size increases - this leads to a point of
diminishing returns for step size.

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 37
Other Errors
Blunders - errors caused by malfunctions of the computer or human
imperfection.

Model errors - errors resulting from incomplete mathematical


models.

Data uncertainty - errors resulting from the accuracy and/or


precision of the data.

GS 4353: Numerical Analysis and Computer Programming


8/4/2022 38
GS 4353
NUMERICAL METHODS AND COMPUTER
PROGRAMMING

Reference:
Numerical Methods for Engineers by
Steven C. Chapra
Raymond P. Canale

GS 4353: Numerical Analysis and Computer Programming 8/4/2022 39

You might also like