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

Numerical Derivatives-Mathematical Modeling and Simulation-Lecture Slides, Slides of Mathematical Modeling and Simulation

These lecture slides are delivered at The LNM Institute of Information Technology by Dr. Sham Thakur for subject of Mathematical Modeling and Simulation. Its main points are: Numerical, Derivatives, Differentiation, Integration, Methods, Forward, Difference, Backward, Errors

Typology: Slides

2011/2012

Uploaded on 07/03/2012

jaee
jaee 🇮🇳

4.7

(22)

101 documents

1 / 40

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture Slides
on
Modeling and Simulation
Lecture: Numerical Derivatives
Docsity.com
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

Partial preview of the text

Download Numerical Derivatives-Mathematical Modeling and Simulation-Lecture Slides and more Slides Mathematical Modeling and Simulation in PDF only on Docsity!

Lecture Slides

on

Modeling and Simulation

Lecture: Numerical Derivatives

2

Numerical Differentiation and Integration

  • We known from Calculus the mathematical concepts of

differentiation and integration :

b

a

i i x

i i

I f x dx

x

f x x f x

dx

dy

x

f x x f x

x

y

lim

0

y

x

f(xi)

f(xi+x)

x

Numerical Differentiation

y

x

f(xi)

f(xi+x)

x

Numerical Differentiation

y

x

f(xi)

f(xi+x)

x

Numerical Differentiation

xi

f(xi)

x

Finally, we can

see that the

derivative forms

a slope at a point. x
f x x f x
dx
dy
x
f x x f x
x
y

i i x

i i

lim

0

Numerical Differentiation

Derivatives

  • We generally use Taylor series to evaluate a function in the

neighborhood of xo when the derivatives of all order are known.

  • It can also be used to evaluate approximately the derivatives of f(x)

if the values of function are known at a number of discrete points, { xi } where, i = 1, 2,... N.

  • Let us assume that we know the values of f(xo) and f(xo + h), where

h is a small value.

  • Then the Taylor series expansion of f(xo + h) can be written as

following:

     ( ) 2

( ) ( ) ( )

2 o o o f x o

h f x h f x hf x

Forward Difference as First Derivative

  • When we truncate Taylor’s expansion after the first derivative and

solve for first derivative we obtain an approximation:

  • Thus the first derivative at x = xo is approximately estimated by f(xo+

h) and f(xo). By defining the forward differences on the right side is expressed by

  • It is termed as forward difference formula for the

derivative.

 ( ) ( ) 1 ( (^) o ) f xo h f xo h

fx   

f ( xo ) f ( xoh ) f ( xo )

  o

o o o x

f x f x h f x h

   

( ) ( ) ( ) 1

Errors

  • We see that approximating the first derivatives by

forward or backward difference processes error and the

error is approximately equal to the (h/2)f’’.

  • The error is known as truncation error.
  • Another type of error that can be introduced in numerical

calculations is round-off error.

  • It is error appearing in computing the difference terms

and may be denoted by .

  • The truncation error decreases with h , however the round-off error increases.
  • It has been seen that truncation error is dominant when h is large and absolute error has dominating role of round-off error when h is very small.
  • Both errors have been compared in Figure.
  • For large step size, h, the error in the first derivative is dominated by the truncation error and as h is allowed to reduce, major contribution to the total error becomes due to round-off error.

Errors

 ( 0. 3 ) ( 0. 1 ) 2

1

  1. 2

    

f x f x dx h

df x

  1. 2
dx x 
df

= 18.5 gm/cm

 ( 0. 4 ) ( 0. 2 ) 2

1

  1. 3

    

f x f x dx h

df x

2 ( 0. 1 )

( 7. 2 4. 3 )

  1. 3

  dx x

df = 14.5gm/cm

Let us first calculate the derivative at x = 0.2,

  • Similarly at x = 0.3,

Example 1: derivative

Example 1: Derivative

 ( 0. 1 ) 2 ( 0. 2 ) ( 0. 3 )

2

  1. 2

2

2       

f x f x f x dx h

d f

x

 2. 1 2. 0 4. 3 5. 8  (^70). ( 0. 1 )

2

  1. 2

2

2       dx x

d f

 ( 0. 2 ) 2 ( 0. 3 ) ( 0. 4 ) 10.

1 2

  1. 3

2

2         

f x f x f x dx h

d f

x

and the second derivative at x = 0.2 is given as:

Then the second derivative at x= 0.3 is approximately equal to:

These estimates can also be found using forward and backward difference forms.

Find derivative of polynomial using MATLAB for the

function:

The derivative function is given as following:

Use MATLAB to find the derivative function.

f(x)  2 x^5  2 x^4  5 x^3  10 x  1

( ) 10 8 15 10 4 3 2 f ^ xxxx

Example 3: derivative Using MATLAB

  • Solution:
  • The script file for the MATLAB code is give below where

we first find the solution by polyder function and the

employ diff to find the derivative.

  • The coefficients of polynomial are identified and then

these are used to find the coefficients of derivative

function.

  • Then using polyval command this polynomial is

generated.

  • The diff command approximates the derivative as a ratio

of two differences as

( yi  1  yi)/(xi  1  xi)i  1 , 2 ,

.

Example 3: derivative Using MATLAB