Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Derivatives and Intergration, Lecture notes of Numerical Methods in Engineering

Easy to understand andd apply for the engineering problems

Typology: Lecture notes

2023/2024

Uploaded on 04/29/2024

trung-bui-ba
trung-bui-ba 🇻🇳

1 / 55

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NUM ER IC AL D IFF ER EN TI ATI ON A ND I NT EG RAT IO N
Hoang Hai Ha
2022
HoangHai Ha Numerical differentiationand integration 2022 1/ 29
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37

Partial preview of the text

Download Derivatives and Intergration and more Lecture notes Numerical Methods in Engineering in PDF only on Docsity!

NUMERICAL DIFFERENTIATION AND INTEGRATION

Hoang Hai Ha

CONTENT

1 NUMERICAL DIFFERENTIATION

FINDING DERIVATIVE IN GENERAL

Given a function y = f ( x ) by the table:

xk x 0 x 1 · · · xn yk = f ( xk ) y 0 y 1 · · · yn

To find f ′( ¯ x ), we interpolate it by a function G ( x ) and apply

f ′( ¯ x ) ≈ G ′( ¯ x )

DIFFERENCE FORMULA FOR 2 POINTS

Consider the table of data points for y = f ( x ):

x x 0 x 1 y y 0 y 1 where y 0 = f ( x 0 ) and y 1 = f ( x 1 ) = f ( x 0 + h ). The polynomial interpolation Lagrange is

L ( x ) =

xx 0 h

y 1 −

xx 1 h

y 0 ,

where h = x 1 − x 0. Then, for all ∀ x ∈ [ x 0 , x 1 ] we have

f ′( x ) ≈

y 1 − y 0 h

f ( x 0 + h ) − f ( x 0 ) h

Forward difference formula:

f ′( x 0 ) ≈

y 1 − y 0 h

f ( x 0 + h ) − f ( x 0 ) h

Backward difference formula:

f ′( x 0 ) ≈

f ( x 0 ) − f ( x 0 − h ) h

EXAMPLE 1.

Use forward and backward difference formulas to approximate derivative of f ( x ) = ln x at x 0 = 1.8 with h = 0..

THE CASE OF 3 NODES

Consider the table where nodes are equally spaced x x 0 x 1 x 2 y y 0 y 1 y 2 where y 0 = f ( x 0 ), y 1 = f ( x 1 ) = f ( x 0 + h ), y 2 = f ( x 2 ) = f ( x 0 + 2 h ) Polynomial interpolation Lagrange for this table is

L ( x ) ==

( xx 0 )( xx 1 ) 2 h^2

y 2 −

( xx 0 )( xx 2 ) h^2

y 1 +

( xx 1 )( xx 2 ) 2 h^2

y 0.

L ′( x ) =

xx 0 2 h^2

( y 2 − 2 y 1 ) +

xx 1 h^2

( y 2 + y 0 ) +

xx 2 2 h^2

( y 0 − 2 y 1 )

L ′′( x ) =

y 2 − 2 y 1 + y 0 h^2

The formula

f ′( x 0 ) ≈ L ′( x 0 ) =

− 3 y 0 + 4 y 1 − y 2 2 h

is called forward difference formul, and rewritten by

f ′( x 0 ) =

− 3 f ( x 0 ) + 4 f ( x 0 + h ) − f ( x 0 + 2 h ) 2 h

At x 1 , f ′( x 1 ) ≈ L ′( x 1 ) =

y 2 − y 0 2 h

is called centered difference formula

and written in the form

f ′( x 0 ) ≈

f ( x 0 + h ) − f ( x 0 − h ) 2 h

EXAMPLE 1.

Compute y ′(1) with h = 0.5 for function y = ex^ , using center difference formula, compare to the exact value(take the value found by the pocket calculator as the exact value.)

EXAMPLE 1.

Compute y ′(1) with h = 0.5 for function y = ex^ , using center difference formula, compare to the exact value(take the value found by the pocket calculator as the exact value.)

SOLUTION

f ′(1) =

f (1 + 0.5) − f (1 − 0.5) 2 × 0.

Exact value: −0.367879441171442.

NUMERICAL INTEGRATION

We usually find a definite integral by Newton-Leibniz formula Z (^) b

a

f ( x ) d x = F ( x )

b a

= F ( b ) − F ( a ), F ′( x ) = f ( x ).

But this method does not work in two cases: it is impossible to find F or we don’t know f ( x ) explicitly. ALTERNATIVE METHOD We replace f ( x ) by its interpolation polynomial Pn ( x ) on [ a , b ] and approximate (^) Z b

a

f ( x ) d x ≈

Z (^) b

a

Pn ( x ) d x

TRAPEZOIDAL FORMULA

To derive the approximation for

Z (^) b

a

f ( x ) d x we replace f ( x ) by its polynomial interpolation passing through 2 points ( a , f ( a )) và ( b , f ( b )) Then

P 1 ( x ) = f ( a ) +

f ( b ) − f ( a ) ba

( xa )

TRAPEZOIDAL FORMULA

To derive the approximation for

Z (^) b

a

f ( x ) d x we replace f ( x ) by its polynomial interpolation passing through 2 points ( a , f ( a )) và ( b , f ( b )) Then

P 1 ( x ) = f ( a ) +

f ( b ) − f ( a ) ba

( xa )

Z (^) b

a

P 1 ( x ) d x = f ( a ) x +

f ( b ) − f ( a ) ba

μ x^2 2

ax

b

a

We get the following which is called the Trapezoidal formula

Z (^) b

a

f ( x ) d x

ba 2

f ( a ) + f ( b )

COMPOSITE TRAPEZOIDAL FORMULA

Dividing [ a , b ] into n sub-intervals with step h =

ba n

. Then a = x 0 , x 1 = x 0 + h ,... , xk = x 0 + kh ,... , xn = x 0 + nhyk = f ( xk ), k = 0, 1,... , n Applying the trapezoidal rule for each interval [ xk xk + 1 ]

Z^ b

a

f ( x ) d x =

Z^ x^1

x 0

f ( x ) d x +

Z^ x^2

x 1

f ( x ) d x +... +

Z^ xn

xn − 1

f ( x ) d x

≈ h ·

y 0 + y 1 2

  • h ·

y 1 + y 2 2

+... + h ·

yn − 1 + yn 2

h 2

y 0 + 2 y 1 + 2 y 2 + .... + 2 yn − 1 + yn