29
03/22/22 http:// numericalmethods.eng.usf.edu 1 Differentiation- Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati http://numericalmethods.eng.u sf.edu Transforming Numerical Methods Education for STEM Undergraduates

10/11/2015 1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Embed Size (px)

Citation preview

Page 1: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

04/19/23http://

numericalmethods.eng.usf.edu 1

Differentiation-Discrete Functions

Chemical Engineering Majors

Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Page 2: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Differentiation –Discrete Functions

http://numericalmethods.eng.usf.edu

Page 3: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu3

Forward Difference Approximation

x

xfxxf

xxf

Δ

Δ

lim

For a finite

'Δ' x

x

xfxxfxf

Page 4: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu4

x x+Δx

f(x)

Figure 1 Graphical Representation of forward difference approximation of first derivative.

Graphical Representation Of Forward Difference

Approximation

Page 5: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu5

Example 1

A new fuel for recreational boats being developed at the local university was tested at an area pond by a team of engineers. The interest is to document the environmental impact of the fuel – how quickly does the slick spread? Table 1 shows the video camera record of the radius of the wave generated by a drop of the fuel that fell into the pond.

Using the data

a)Compute the rate at which the radius of the drop was changing at seconds.

b)Estimate the rate at which the area of the contaminant was spreading across the pond at seconds.

2t

2t

Page 6: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu6

Example 1 Cont.

Use Forward Divided Difference approximation of the first derivative to solve the above problem. Use a time step of 0.5

sec.

Time 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0

Radius 0 0.236

0.667

1.225

1.886

2.635

3.464

4.365

5.333

Table 1 Radius as a function of time.

s t

m R

Page 7: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu7

Example 1 Cont.

Solution (a)

t

tRtRtR iii

1'

2it

5.0

25.2

1

ii ttt

5.21 it

5.0

25.22' RR

R

5.0

886.1635.2

m/s498.1

Page 8: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Example 1 Cont.

http://numericalmethods.eng.usf.edu8

(b) 2RArea

Time 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0

Area 0 0.17497 1.3977 4.7144 11.175 21.813 37.697 59.857 89.350

t

tAtAtA iii

1'

2it

5.025.2

1

ii ttt

5.21 it

s t

2m A

/sm276.215.0

175.11813.215.0

25.210

2

'

AAA

Page 9: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu9

Direct Fit Polynomials

'1' n nn yxyxyxyx ,,,,,,,, 221100 thn

nn

nnn xaxaxaaxP

1110

12121 12

)( n

nn

nn

n xnaxanxaadx

xdPxP

In this method, given data points

one can fit a order polynomial given by

To find the first derivative,

Similarly other derivatives can be found.

Page 10: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu10

Example 2-Direct Fit Polynomials

A new fuel for recreational boats being developed at the local university was tested at an area pond by a team of engineers. The interest is to document the environmental impact of the fuel – how quickly does the slick spread? Table 2 shows the video camera record of the radius of the wave generated by a drop of the fuel that fell into the pond. Using the data

(a)Compute the rate at which the radius of the drop was changing at seconds. (b)Estimate the rate at which the area of the contaminant was spreading across the pond at seconds.

Time (s) 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0Radius (m)

00.236

0.667 1.225 1.886 2.635 3.464 4.365 5.333

Use the third order polynomial interpolant for radius and area calculations.

Table 2 Radius as a function of time.

2t

2t

Page 11: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu11

Example 2-Direct Fit Polynomials cont.

33

2210 tatataatR

667.0,0.1 oo tRt

(a) For the third order polynomial (also called cubic interpolation), we choose the radius given by

Since we want to find the radius at , and we are using a third order polynomial, we need to choose the four points closest to and that also bracket to evaluate it.

The four points are

(Note: Choosing is equally valid.)

225.1,5.1 11 tRt

886.1,0.2 22 tRt

635.2,5.2 33 tRt

Solution

2t2t 2t

.5.2 and ,0.2 ,5.1 ,0.1 3210 tttt0.3 and ,5.2 ,0.2 ,5.1 3210 tttt

Page 12: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu12

Example 2-Direct Fit Polynomials cont.

33

2210 0.10.10.1667.00.1 aaaaR

33

2210 5.15.15.1225.15.1 aaaaR

33

2210 0.20.20.2886.10.2 aaaaR

33

2210 5.25.25.2635.25.2 aaaaR

635.2

886.1

225.1

667.0

625.1525.65.21

8421

375.325.25.11

1111

3

2

1

0

a

a

a

a

such that

Writing the four equations in matrix form, we have

Page 13: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu13

Example 2-Direct Fit Polynomials cont.

Solving the above four equations gives

0.0800000 a

0.471001 a

0.295992 a

0.0200003 a

33

2210 tatataatR

5.21,020000.029599.047100.0080000.0 32 tttt

Hence

Page 14: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu14

Example 2-Direct Fit Polynomials cont.

Figure 2 Graph of radius vs. time.

Page 15: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu15

Example 2-Direct Fit Polynomials cont.

5.21,020000.029599.047100.0080000.0 32 tttttR

tRdt

dtR '

32 020000.029599.047100.0080000.0 tttdt

d

5.21,060000.059180.047100.0 2 ttt

2' )2(0.060000-0.59180(2)47100.02 R

s/m 1.415

Given that

,

2

' 2

t

tRdt

dR

The derivative of radius at t=2 is given by

Page 16: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu16

Example 2-Direct Fit Polynomials cont.

Time 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0Area 0 0.17497 1.3977 4.7144 11.175 21.813 37.697 59.857 89.350

2RArea

33

2210 tatataatA

(b)

For the third order polynomial (also called cubic interpolation), we choose thearea given by

Since we want to find the area at , and we are using a third order polynomial, we need to choose the four points closest to and that also bracket to evaluate it.

The four points are

(Note: Choosing is equally valid.) 3977.1,0.1 oo tAt

7144.4,5.1 11 tAt

175.11,0.2 22 tAt

813.21,5.2 33 tAt

2m A

s t

2t2t 2t

.5.2 and ,0.2 ,5.1 ,0.1 3210 tttt0.3 and ,5.2 ,0.2 ,5.1 3210 tttt

Page 17: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Example 2-fit Direct Ploynomials cont.

http://numericalmethods.eng.usf.edu17

33

2210 0.10.10.13977.10.1 aaaaA

33

2210 5.15.15.17144.45.1 aaaaA

33

2210 0.20.20.2175.110.2 aaaaA

33

2210 5.25.25.2813.215.2 aaaaA

813.21

175.11

7144.4

3977.1

625.1525.65.21

8421

375.325.25.11

1111

3

2

1

0

a

a

a

a

such that

Writing the four equations in matrix form, we have

Page 18: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Example 2- Direct Fit polynomials cont.

http://numericalmethods.eng.usf.edu18

0.0579000 a

0.120751 a0.0814682 a

1.37903 a

33

2210 tatataatA

5.21,3790.1081468.012075.0057900.0 32 tttt

Solving the above four equations gives

Hence

Page 19: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu19

Example 2-Direct Fit Polynomials cont.

Figure 3 Graph of area vs. time.

Page 20: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Example 2- Direct Fit Polynomial cont

http://numericalmethods.eng.usf.edu20

5.21,3790.1081468.012075.0057900.0 32 tttttA

tAdt

dtA '

32 3790.1081468.012075.0057900.0 tttdt

d

5.21,4.137116294.012075.0 2 ttt

2)2(4.13710.16294(2)12075.02 A

/sm 16.754 2

Given that

,

2

' 2

t

tEdt

dA

The derivative of radius at t=2 is given by

Page 21: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu21

Lagrange Polynomial nn yxyx ,,,, 11 thn 1In this method, given , one can fit a order Lagrangian polynomial

given by

n

iiin xfxLxf

0

)()()(

where ‘ n ’ in )(xf n stands for the thnorder polynomial that approximates the function

)(xfy given at )1( n data points as nnnn yxyxyxyx ,,,,......,,,, 111100 , and

n

ijj ji

ji xx

xxxL

0

)(

)(xLi a weighting function that includes a product of )1( n terms with terms of

ij omitted.

Page 22: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu22

Then to find the first derivative, one can differentiate xfnfor other derivatives.

For example, the second order Lagrange polynomial passing through

221100 ,,,,, yxyxyx is

2

1202

101

2101

200

2010

212 xf

xxxx

xxxxxf

xxxx

xxxxxf

xxxx

xxxxxf

Differentiating equation (2) gives

once, and so on

Lagrange Polynomial Cont.

Page 23: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu23

21202

12101

02010

2

222xf

xxxxxf

xxxxxf

xxxxxf

2

1202

101

2101

200

2010

212

222xf

xxxx

xxxxf

xxxx

xxxxf

xxxx

xxxxf

Differentiating again would give the second derivative as

Lagrange Polynomial Cont.

Page 24: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu24

Example 3

A new fuel for recreational boats being developed at the local university was tested at an are pond by a team of engineers. The interest is to document the environmental impact of the fuel – how quickly does the slick spread? Table 3 shows the video camera record of the radius of the wave generated by a drop of the fuel that fell into the pond. Using the data

(a)Compute the rate at which the radius of the drop was changing at .(b)Estimate the rate at which the area of the contaminant was spreading across the pond at .

Time 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0

Radius 0 0.236 0.667 1.225 1.886 2.635 3.464 4.365 5.333

Use second order Lagrangian polynomial interpolation to solve the problem.

Table 3 Radius as a function of time.

2t

2t

s t

m R

Page 25: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Since we want to find the radius at , and we are using a second order Lagrangian polynomial, we need to choose the three points closest to that also bracket to evaluate it. The three points are

Differentiating the above equation gives

http://numericalmethods.eng.usf.edu25

Example 3 Cont.

)()()()( 212

1

02

01

21

2

01

00

20

2

10

1 tRtt

tt

tt

tttR

tt

tt

tt

tttR

tt

tt

tt

tttR

2

1202

101

2101

200

2010

21' 222tR

tttt

ttttR

tttt

ttttR

tttt

ttttR

2.635

0.25.25.15.2

0.25.1221.886

5.20.25.10.2

5.25.1221.225

5.25.10.25.1

5.20.2222'

R

Solution:(a) For second order Lagrangian polynomial interpolation, we choose the radius given by

m/s 4100.1

. 5.2 and , 0.2 , 5.1 210 ttt

Hence,

2t2t 2t

Page 26: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu26

Example 3 Cont.

Time 0

0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0

Area 0

0.17497

1.3977

4.7144

11.175

21.813

37.697

59.857

89.350

2RArea

)()()()( 212

1

02

01

21

2

01

00

20

2

10

1 tAtt

tt

tt

tttA

tt

tt

tt

tttA

tt

tt

tt

tttA

(b)

For second order Lagrangian polynomial interpolation, we choose the area given by

s t

m A

Page 27: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

http://numericalmethods.eng.usf.edu27

Example 3 Cont.

4.7144

5.25.10.25.1

5.20.2222'

A

11.1755.20.25.10.2

5.25.122

21.8130.25.25.15.2

0.25.122

/sm 17.099 2

Since we want to find the area at , and we are using a second order Lagrangian polynomial, we need to choose the three points closest to that also brackets to evaluate it. The three points are

Differentiating the above equation gives

2t

2t2t

.5.2 and ,0.2 ,5.1 210 ttt

0

2010

21' 2tA

tttt

ttttA

12101

202tA

tttt

ttt

21202

102tA

tttt

ttt

Hence

Page 28: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit

http://numericalmethods.eng.usf.edu/topics/discrete_02dif.html

Page 29: 10/11/2015  1 Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati

THE END

http://numericalmethods.eng.usf.edu