Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 57

Numerical Methods

Numerical Methods
Computational Methods
M. Tech. (Mechanical) All Branches
ME5011S SEM - I
Dept. of Mechanical Engineering
ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Outline

Trapezoidal Rule,

Simpsons 1/3rd Rule,

Simpsons 3/8th Rule,

Newton-Raphson Method (???),

Numerical Differentiation & Integration.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Engineers are required to draw conclusions @ a physical system from analysis of its
Mathematical Model.

To compute Rate of Change of 1 variable w.r.t. the other

DERIVATIVE.

To compute Area Enclosed by Curve

INTEGRAL.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Suppose, f (x) is a function of interest, and a is the point of interest at which the
derivative is desired,

Unlike Explicit Differentiation (i.e. based on formulae from Calculus), Numerical


Differentiation produces an Estimate of the derivative using only the Value of the
function @ selected points.
Less Accurate, But FASTER..!!
e.g. compute acceleration from velocity measurement.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Suppose, f (x) is a function of interest, and defined over interval [a,b],

Unlike Explicit Integration, (i.e. based on formulae from Calculus), only the Values
of the function @ selected points are required.
Less Accurate, But FASTER..!!
e.g. Compute area of irregular piece of land,
Electrical charge of a capacitor,
Work done by moving a mass, etc.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Magnetic Levitation :

A ball of mass m is suspended below an


electromagnet.

Feedback
Control
Unit

Magnetic Force h(y,u)

Magnet

y is ball position.
u is current.

Gravitational Force mg

Optical
Sensor
mg

Applying Newtons Second Law :


. (I)

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Magnetic Levitation :

Feedback
Control
Unit

Suppose, current is constant.

u(t) = u0
u

Magnet

Setting RHS to zero,

h(y,u) = mg

y
Optical
Sensor

Magnetic Force cancelling


mg

ME5011S SEM-I

Gravitational Force

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Magnetic Levitation :

BUT, Equilibrium Point is NOT


STABLE!!

Feedback
Control
Unit

Magnet

If ball drops slightly,

h(y,u) < mg
y

. Ball falls..!!

Optical
Sensor

If ball moves slightly above,

h(y,u) > mg

mg

. Ball sticks to
electromagnet..!!
ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
To make the ball levitate, a Control

Magnetic Levitation :

Engineer must detect the position y, and


adjust
Feedback
Control
Unit

Magnet

current

u,

using

Feedback

Control System.

. , > 0.
Feedback Gain

y
Optical
Sensor

BUT, no simple means to measure


.!!

mg

to be estimated
NUMERICALLY!!!
ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Introduction
Cost Estimation for Dam Construction.

Water Management :

Cross-Sectional Area of the river as a


point!
Depth Measurements w.r.t. position!!

y
Area can be calculated as :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Numerical Differentiation
Let f (x) is a function of interest, having n continuous derivatives in the
neighbourhood of the point x = x0.

Taylor Series Expansion @ x = x0.

denotes the kth derivative of f (x) evaluated @ x = x0.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

First Derivative
Suppose the data samples of the function f (x) are uniformly spaced. Let
h denote the Step-Size between successive values of independent
variable, x.
Taylor Series Expansion @ x = x0, and evaluate the results @ 2 points,
adjacent to x0 :

(I)

(II)
denotes the kth derivative of f (x) evaluated @ x = x0.
ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Two Point Forward Difference


Solving for

from (I) and neglecting 2nd-&-higher order terms,

f (x)

Two Point Forward Difference!!


Uses 2 values of f (x), one @ x0 and other ahead @ x1.

Simple Geometric Interpretation :


Slope of Forward Secant!!

x
x-1

ME5011S SEM-I

Computational Methods

x0

x1

M. Tech. (Mech)

Numerical Methods

Two Point Forward Difference


As a limiting case, when h approaches zero, the expression reduces to
definition of Derivatives :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Two Point Backward Difference


Solving for

from (II) and neglecting 2nd-&-higher order terms,

f (x)

Two Point Backward Difference!!


Uses 2 values of f (x), one @ x0 and other behind @ x1.
Simple Geometric Interpretation :
Slope of Backward Secant!!

ME5011S SEM-I

Computational Methods

x
x-1

x0

x1

M. Tech. (Mech)

Numerical Methods

Two Point Backward Difference

Useful when the independent variable represents time.

Uses only past and present data, and does not rely on further data samples
that may not be available in real time applications.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Two Point Center Difference


If data samples are available on both sides of x0, subtracting (II) from (II)
and neglecting 2nd-&-higher order terms,

f (x)

Two Point Center Difference!!


Uses data points centred @ the point of interest.
Hence, also referred as Three-Point Center Difference.
Third point is x0, even though it does not appear in the
formula.

Simple Geometric Interpretation :


ME5011S SEM-I

Computational Methods

x-1

x0

x1

M. Tech. (Mech)

Numerical Methods

Two Point Center Difference


Two Point Center Difference approximation offer cancellation of 2 nd
Order terms due to symmetry of the points x-1, and x1 @ x0.

Superior to Forward Difference & Backward Difference in terns of


Accuracy!!
Represents Average of Forward Difference & Backward Difference
methods..!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Higher Order Difference


The accuracy of the numerical approximation of Derivatives can be
increased by using additional values of function further away from point of
interest.

By expanding the Taylor Series further,

(III)

(IV)

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Higher Order Difference


Solving for

using (III) 4 X (I) and neglecting higher order terms,

Three Point Forward Difference!!!


Solving for

using (IV) 4 X (II) and neglecting higher order terms,

Three Point Backward Difference!!!


ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Higher Order Difference

Extending the similar logic,

Five Point Central Difference!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Higher Order Difference

Extending the similar logic for Second Order Derivatives, by adding (I)
and (II) , cancelling

and solving for

Three Point Central Difference for Second Order Derivatives!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Effects of Errors
2 parameters to the accuracy of numerical estimates of Derivatives :
1.Number of points, n.
2.Step size, h.

For the n point approximation of the kth derivative, the formula for
Truncation Error, (O) is of the order of :

For n > k, Truncation Error, (O)

ME5011S SEM-I

by

h!!

Computational Methods

M. Tech. (Mech)

Numerical Methods

Effects of Errors
BUT, Total Error = Truncation Error (O) + Round-Off Error (ER)
Suppose,
Ek : Total Error associated with approximating the kth derivative with the
n point formula :

: (O)

: (ER)

.!
.!!

Optimum size of h to
ME5011S SEM-I

Total Error.!!!
Computational Methods

M. Tech. (Mech)

Numerical Methods

Noise Corrupted Data


Let xk : Signal to be measured

yk : Observed Transducer Output @ time, k


In reality :
. nk : Measurement Noise @ time, k

Noise is typically spread over range of frequencies.


Differentiation lead to amplify the high-frequency component of noise!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Noise Corrupted Data

e.g. Velo. measurement by differentiation


of Position measurement.

Amplitude of Derivative of Noise Freq. of Noise..!!


ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Numerical Integration
Let function f (x) be evaluated over an integral [a,b].

Split the interval [a,b] with set of discrete points {x0, x1, x2,..},
where x0 = a and xn = b.
ASSUMPTION : Points are equally spaced with a step size of h = (b a) / n.
APPROACH : To approximate f (x) by a Polynomial Pn (x) of degree n, and then
integrate Pn (x).
If the Polynomial used is Interpolating Polynomial :

Newton Cotes Integration Formulae!!


ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Numerical Integration
Interpolating Polynomial Newtons nth order Forward Difference Formula!!
(V)

k f0 : kth Forward Difference of f (x) evaluated @ x = x0.

ME5011S SEM-I

k f 0

f1 f 0

f2 2 f 1 + f 0

f3 3 f 2 + 3 f 1 f 0

f 4 4 f 3 + 6 f2 4 f 1 + f0

f5 5 f4 + 10 f3 10 f2 + 5 f1 + f0

f6 6 f5 + 15 f4 20 f3 + 15 f2 6 f1 + f0
Computational Methods

M. Tech. (Mech)

Numerical Methods

Trapezoidal Rule
Simplest Newton Cotes Integration Formula for n = 1..!!
Linear Interpolation!!!
Using x = x0 + h and dx = h.d, and Constants as well as Linear Terms in (V) :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Trapezoidal Rule

Integration of f (x) from x0 to x1 is

f (x)
f1

approximated by taking the Area of a


Trapezoid of Width, h and Average Height,
f0

(f0 + f1) / 2.

h
x
x0
ME5011S SEM-I

Computational Methods

x1
M. Tech. (Mech)

Numerical Methods

Trapezoidal Rule
Error in approximation

if h

Accuracy of Approximation

!!
with

h, i.e. Partitioning interval [a,b] into n

steps, where n > 1.


Linear Interpolation over each step and results summed up to give Composite
Piecewise Linear Interpolation..!!
Trapezoidal Rule..!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Trapezoidal Rule

OBSERVATION : Each of the Interior Points are counted TWICE and


hence, has Coefficient 2, except First and Last points!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules
Accuracy by using Higher Order Interpolating Polynomial :
Newton Cotes Integration Formula for n = 2..!!
Quadratic Polynomial over Interval [a,b]!!!
Using x = x0 + h and dx = h.d, and Constants as well as Quadratic Terms
in (V) :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules

Integration of f (x) from x0 to x2 is


approximated by taking the Area under a

f (x)
f2
f1

Quadratic Polynomial.
f0
2h
x
x0
ME5011S SEM-I

Computational Methods

x1

x2

M. Tech. (Mech)

Numerical Methods

Simpsons Rules
Error in approximation

if h

Accuracy of Approximation

!!
with

h, i.e. Partitioning interval [a,b] into n

steps, where n > 2.


Quadratic Interpolation over each step and results summed up to give
Composite Piecewise Quadratic Interpolation..!!
Simpsons 1/3 Rule..!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules

OBSERVATION : Each of the Even Interior Points are counted 4 TIMES,


hence, has Coefficient 4; and Odd Interior Points are
counted 2 Times, hence, has Coefficient 2, except First and
Last points!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules
Extending to Third Degree Polynomial :
Newton Cotes Integration Formula for n = 3..!!
Cubic Polynomial over Interval [a,b]!!!
Using x = x0 + h and dx = h.d, and Constants as well as Cubic Terms in
(V) :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules
Cubic Interpolation over each step and results summed up to give Composite
Piecewise Cubic Interpolation..!!

Simpsons 3/8 Rule..!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Simpsons Rules

OBSERVATION : Each of the Interior Points Multiples of 3i are counted


2 TIMES, hence, has Coefficient 2; and All Other Interior
Points are counted 3 Times, hence, has Coefficient 3,
except First and Last points!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule


Trapezoidal Rule
Evaluation of f (x) @ 2 Endpoints, x0 and xn!!!
Simpsons Rules
Closed Integration Formulae.
Open Integration Formulae require values of f (x) in the interior of the Interval
[a,b].
Forward Difference Expansion of f (x) about the point x1 is required to be used.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule


Taylor Series Forward Difference Expansion of f (x) about the point x1 :

.(VI)

f1 = (f2 f1) : First Order Forward Difference of f (x) @ x = x1.


2 f1 = (f3 2 f2 + f1) : Second Order Forward Difference of f (x) @ x = x1.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule


SIMPLEST CASE : Approximating f (x) over the Interval [x0,x2]
using Interpolating Polynomial of Degree Zero
(i.e. Constant) passing through the Mid-Point..!!

Using x = x1 + h and dx = h.d, and Constants as well as Linear Terms in


(VI) :

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule

Integration of f (x) from x0 to x2 is


approximated by taking the Area of a

f (x)
f2
f1

Rectangle of Width, 2h and Height, f1.


f0
2h
x
x0
ME5011S SEM-I

Computational Methods

x1

x2

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule


Error in approximation

if h

Accuracy of Approximation

!!
with

h, i.e. Partitioning interval [a,b] into n

steps, where n is EVEN and n > 2.


Constant Interpolation over each step and results summed up to give
Composite Piecewise Constant Interpolation..!!
Midpoint / Binary Rule..!!!

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Midpoint / Binary Rule

OBSERVATION : Each of the Odd Interior Points are counted only..!!

An EVEN Degree Polynomial is to be used.


If an mth Degree Interpolating Polynomial is used, then total number of
steps MUST be a multiple of (m+2).

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Convergence Rate
Let

, such that exact value of I (a,b) = 1!!

Applying Midpoint Rule, Trapezoid Rule and Simpsons 1/3 Rule, using a = 0 and
b = 1 for different step sizes h, by varying number of step size n (i.e. h = (b-a) / n) :

ME5011S SEM-I

Midpoint

Trapezoid

Simpsons 1/3

1.0207471

0.9595174

1.0003371

1.0052029

0.9896588

1.0000216

1.0013016

0.9974006

1.0000014

16

1.0003256

0.9993493

1.0000001

32

1.0000815

0.9998373

1.0000000

64

1.0000203

0.9999593

1.0000000

128

1.0000051

0.9999897

1.0000000

256

1.0000011

0.9999974

0.9999996

512

1.0000006

0.9999995

1.0000004

1024

1.0000005

0.9999995.

1.0000004

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
A : Change in Enthalpy :
Clausius Clapeyron Eq. :
T (C)

P (bar)

50

0.1235

60

0.1994

70

0.3119

80

0.4739

90

0.7014

100

1.014

110

1.433

120

1.958

130

2.701

140

3.613

150

4.758

ME5011S SEM-I

NOMENCLATURE :
h : Change in Enthalpy bet. Liq & Gas phase
T : Temp. in Kelvin
vg : Sp. Vol. in Gaseous phase
vf : Sp. Vol. in Liquid phase
GIVEN DATA :
To evaluate enthalpy Change @ 100 C (i.e. 373.15 K)
For vg = 1.63 m3 / kg and vf = 0.00104 m3 / kg.
Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
A : Change in Enthalpy :
OBJECTIVE : to evaluate

@ T = 100 C.

Here, x0 = 100 and h = 10.


Using Three-Point Central Difference :
T (C)

P (bar)

90

0.7014

100

1.014

110

1.433

[bar / C]

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
A : Change in Enthalpy :
OBJECTIVE : to evaluate

@ T = 100 C.

Here, x0 = 100 and h = 10.


Using Five-Point Central Difference :
T (C)

P (bar)

80

0.4739

90

0.7014

100

1.014

110

1.433

120

1.958

[bar / C]
ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
A : Change in Enthalpy :
Clausius Clapeyron Eq. :
Substituting with vg = 1.63 m3 / kg and vf = 0.00104 m3 / kg.
Using Three-Point Central Difference :

Using Five-Point Central Difference :

Actual Thermodynamic Value = 2257 [kJ/kg]!!


ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
B : Rocket Travel :
A rocket is launched from the ground. Its acceleration is measured every
5 seconds and is tabulated below. Find the velocity of the rocket after
40 seconds. Use Trapezoidal as well as Simpsons 1/3 rule. Compare the results.
T (sec)

10

15

20

25

30

35

40

(t)
(m/sec2)

40.00

45.25

48.50

51.25

54.35

59.48

60.50

63.30

68.70

OBJECTIVE : to evaluate velocity of the rocket after 40 seconds.


i.e. To integrate the acceleration data!!
OBSERVATIONS : Here, h = 5, and n = 9.

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
B : Rocket Travel :
T (sec)

10

15

20

25

30

35

40

(t)
(m/sec2)

40.00

45.25

48.50

51.25

54.35

59.48

60.50

63.30

68.70

I. Trapezoidal Rule :

[m/sec]
ME5011S SEM-I

.[ANS]

Computational Methods

M. Tech. (Mech)

Numerical Methods

Applications
B : Rocket Travel :
T (sec)

10

15

20

25

30

35

40

(t)
(m/sec2)

40.00

45.25

48.50

51.25

54.35

59.48

60.50

63.30

68.70

II. Simpsons 1/3 Rule :

[m/sec]
[m/sec]
ME5011S SEM-I

.[ANS]
.[ANS]

Computational Methods

by Simpsons 1/3 Rule..!!


by Trapezoidal Rule..!!
M. Tech. (Mech)

Numerical Methods

Thank You !

ME5011S SEM-I

Computational Methods

M. Tech. (Mech)

You might also like