36
7- 1 Chapter 7 Differentiation and Integration • Finite-difference differentiation x x x f x x f dx x df x x x f x f dx x df x x f x x f dx x df 2 ) ( ) ( ) ( method step - two ) ( ) ( ) ( difference backward ) ( ) ( ) ( difference forward

7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

  • View
    258

  • Download
    3

Embed Size (px)

Citation preview

Page 1: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 1

Chapter 7 Differentiation and Integration

• Finite-difference differentiation

x

xxfxxf

dx

xdfx

xxfxf

dx

xdfx

xfxxf

dx

xdf

2

)()()( method step-two

)()()( difference backward

)()()( difference forward

Page 2: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 2

Table: Saturation Vapor Pressure (es) in

mm Hg as a Function of Temperature (T) in °C

T(°C) es(mm Hg)

20 17.53

21 18.65

22 19.82

23 21.05

24 22.37

25 23.75

Example: Evaporation Rates

Page 3: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 3

The slope of the saturation vapor pressure curve at 22°C (3 methods) :

The true value is 1.20 mm Hg/°C, so the two-step method provides the most accurate estimate.

CHg/ mm 20.12

65.1805.21

2123

)21()23( step-two

CHg/ mm 17.11

65.1882.19

2122

)21()22( backward

CHg/ mm 23.11

82.1905.21

2223

)22()23( forward

sss

sss

sss

ee

dT

de

ee

dT

de

ee

dT

de

Page 4: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 4

Example: Finite-difference Table for Specific Enthalpy (h) in Btu/lb and Temperature (T) in ºF

T h Δh Δ2h Δ3h Δ4h

800 1305

155

1000 1460 -30

125 25

1200 1585 -5 -20

120 5

1400 1705 0

120

1600 1825

Differentiation Using a Finite-difference Table

Page 5: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 5

• For example, at a temperature of 1200 ºF, the forward, backward, and two-step methods yield:

• The rate of change of cp at T= 1200 ºF is

FBtu/lb/ 6.0200

120

12001400

15851705

T

hcp

FBtu/lb/ 625.0200

125

10001200

14601585

T

hcp

FBtu/lb/ 6125.0400

245

10001400

14601705

T

hcp

22

2

F) Btu/lb/(025.0200

5

T

h

Page 6: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 6

Differentiating an Interpolating Polynomial

012

21

1 ...)( bxbxbxbxbxf nn

nn

nn

12

11 ...)1(

)(bxbnxnb

dx

xdf nn

nn

)])(())((

))([()]()[()(

2131

3241232

xxxxxxxx

xxxxaxxxxaadx

xdf

The derivative:

xxxxxxa

xxxxaxxaaf(x)

))()((

))(()(

3214

213121

Gregory-Newton interpolation polynomial:

It is more difficult to evaluate the derivative:

Page 7: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 7

Differentiation Using Taylor Series Expansion

.difference-finite forward theas same theisIt

)()()()('

get weThen,

)()()(

: sderivativehigher and derivative second the with termsTruncating

...!3

)()(

!2

)()()()()(

3

3

32

2

2

x

xfxxf

dx

xdfxf

xdx

xdfxfxxf

x

dx

xfdx

dx

xfdx

dx

xdfxfxxf

Page 8: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 8

• The second-order approximation:

The second-order approximation of the first derivative with forward difference:

2

2

2

2

2

)(

)()(2)2(

)(')(')(

:difference forward With!2

)()()()(

x

xfxxfxxfx

xfxxf

dx

xfd

x

dx

xfd

x

xfxxf

dx

xdf

x

xfxxfxxf

dx

xdf

2

)(3)(4)2()(

Page 9: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 9

• The second-order approximation of the second derivative with forward difference:

• The first-order and second-order approximation of the first derivative with backward difference:

22

2

)(

)(2)(5)2(4)3()(

x

xfxxfxxfxxf

dx

xfd

x

xxfxxfxf

dx

xdfx

xxfxf

dx

xdf

2

)2()(4)(3)(

)()()(

Page 10: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 10

• The first-order and second-order approximation of the second derivative with backward difference:

• How to derive

(for reference only)

22

2

22

2

)(

)3()2(4)(5)(2)(

)(

)2()(2)()(

x

xxfxxfxxfxf

dx

xfd

x

xxfxxfxf

dx

xfd

221

2

229

)()('')(')()(

)(2)(''2)(')()2(

)()(''3)(')()3(

xxfxxfxfxxf

xxfxxfxfxxf

xxfxxfxfxxf

)(''

)](2)('')()('5)(5-

)('')(8)('8)(4

)('')()('3)([)(

1

)](2)(5)2(4)3([)(

1

225

2

229

2

2

xf

xfxfxxxfxf

xfxxxfxf

xfxxxfxfx

xxfxxfxxfxxfx

Page 11: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 11

• The first-order and second-order approximation of the first derivative with the two-step method:

• The first-order and second-order approximation of second derivative with the two-step method:

x

xxfxxfxxfxxf

dx

xdfx

xxfxxf

dx

xdf

12

)2()(8)(8)2()(2

)()()(

22

2

22

2

)(12

)2()(16)(30)(16)2()(

)(

)()(2)()(

x

xxfxxfxfxxfxxf

dx

xfd

x

xxfxfxxf

dx

xfd

Page 12: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 12

Example: Evaporation Rates

The true value at T = 22ºC is 1.2 mm Hg/ºC

CHg/ mm 19667.1)1(12

)53.17()65.18(8)05.21(8)37.22(

)1(12

)20()21(8)23(8)24()(

CHg/ mm 195.1)1(2

53.17)65.18(4)82.19(3

)1(2

)20()21(4)22(3)(

CHg/ mm 185.1)1(2

)82.19(3)05.21(437.22

)1(2

)22(3)23(4)24()(

ssss

sss

sss

eeee

dx

xdf

eee

dx

xdf

eee

dx

xdf

Second-order with forward, backward, two-step:

Page 13: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 13

Numerical Integration

• Example: the volume rate of flow (Q) of water in a channel or through a pipe is the integral of the velocity (V) and the incremental area (dA):

b

adxxf )( integral

VdAQ

• The area under the curve f(x) between x=a and x=b:

Page 14: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 14

Interpolation Formula Approach

cxbxn

bx

n

bdxxf

bxbxbxf

n

aaa

xxxxxxa

xxxxaxxaaxf

nnn

nnn

n

nn

1211

11

21

121

211

213121

...1

)(

:follows asly analytical integrated be canit Then,

...)(

:polynomialorder -th an form it to

rearrange can we,determined are ,,After

))...()((

...))(()()(

The Gregory-Newton interpolation polynomial:

Page 15: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 15

Trapezoidal Rule

1

1

11 2

)()()()(

1

n

i

iiii

x

x

xfxfxxdxxf

n

Page 16: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 16

• Another way to get the trapezoidal formula The linear polynomial passing the data points:

)()()(

)()(1

1i

ii

iii xx

xx

xfxfxfxf

)]()())()((2

)([)(

get we, and points twobetween )( gIntegratin

1111

iiiiiiii

b

axfxxfxxfxf

ab

xx

abdxxf

baxf

)]()([2

)(

get we, and Let

11

1

1

iiii

x

x

ii

xfxfxx

dxxf

xa xb

i

i

Page 17: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 17

• The absolute value of the upper bound on the error for the Trapezoidal rule is:

)(''max)('' where

)(''12

)(error

1

31

xfxf

xfxx

ii xxxj

jii

Page 18: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 18

Example: Trapezoidal Rule for Integration

• n = 4

• The trapezoidal rule provides

345)( 23 xxxxf

10)2(1

)]3(3[2

34)]3(1[

2

23)]1(3[

2

12)(

4

1

dxxf

Page 19: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 19

Page 20: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 20

Example: Flow Rate• The flow rate (Q) of an incompressible fluid is given by th

e integral.

in which V is the velocity and A is the area.

• For a circular pipe of radius r, the incremental area dA is equal to 2πrdr.

VdAQ

0

02

rrdr)V(Q

Page 21: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 21

• Table 6: The Data for Estimating the Flow Rate of a Fluid in a Circular Piple

i ri (ft) Vi (fps)

1 0 10.000

2 1/12 9.722

3 1/6 8.889

4 1/4 7.500

5 1/3 5.556

6 5/12 3.056

7 1/2 0.

Page 22: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 22

• For a pipe of diameter of 1 ft

trapezoidal rule:

/secft 818.3

}2

10

12

5056.3

12

5056.3

3

1556.5

3

1556.5

4

15.7

4

15.7

6

1889.8

6

1889.8

12

1722.9

12

1722.9010{

12

π

][2

)121

(π2

3

6

111

Q

rVrVQi

iiii

6

111 )]π2()π2([

2 iiiii rVrV

rQ

Page 23: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 23

Simpson’s Rule

• Simpson’s rule:

where

• Simpson’s rule can only be applied when there are an even number of subintervals:

)]()(4)([3

)( bfxafafx

dxxfb

a

2

5,3,121

1 )]()(4)([3

)(1

n

iiii

iix

xxfxfxf

xxdxxf

n

2

abx

Page 24: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 24

• Proof of Simpson’s Rule

Using a second-order polynomial:

lhxkxxf 2)(

Page 25: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 25

Passing through the three data points:

Then, we can obtain the Simpson’s formula.

lhbkbbf

lxahxakxaf

lhakaaf

2

2

2

)(

)()()(

)(

)(2

)(

3

)(

)(

:polynomialorder -second thegIntegratin

2233

2

ablabhabk

dxlhxkxb

a

Page 26: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 26

• The absolute value of the upper bound on the error for the Simpson’s rule is estimated by

4

4

4

4

4

451

)(max

)( where

)(

90

)(error

1 dx

xfd

dx

xfd

dx

xfdxx

ii xxx

j

jii

Page 27: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 27

Example: Flow Rate Problem

• Applying Simpson’s rule to the data of Table.6

/secft 927.3)]2

1(0)

12

5)(056.3(4)

3

1(556.5[)]

3

1(556.5

)4

1)(5.7(4)

6

1(889.8[)]

6

1(889.8)

12

1)(722.9(4)0(10[

18

π

]4[3

)(π2π2

3

5

3,12211

12

1

0

0

r

iiiiii

rrVrVrVrdrVQ

Page 28: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 28

Romberg Integration

• Denoting the trapezoidal estimate as I01

where a and b are the start and end of an interval.

• A second estimate I11:

))()((201 bfaf

abI

22 where

))(2

1)()(

2

1(

211

aba

bam

bfmfafab

I

)]2

()([2

1 :rewritten be canIt 0111

abafabII

Page 29: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 29

• A third estimate I21 can be obtained using three equally spaced intermediate points m1, m2, and m3

and it can be rewritten as

)](4

1)(

2

1)(

2

1)(

2

1)(

4

1[

2 32121 bfmfmfmfafab

I

3

2

11121 )

4(

22

1

k

k

kab

afab

II

Page 30: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 30

• Continuing this subdividing of the interval leads to the following recursive relationship

• The general extrapolation formula in recursive form is

2,... 1, for )2

(22

1 12

5,3,111,11

ik

abaf

abII

i

kiiii

14

41

1,1,11

j

jijij

ij

III

Page 31: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 31

• The values of Iij can be presented in the following upper-triangular matrix form:

I01 I02 I03 I04 … I0,N-1 I0,N I0,N+1

I11 I12 I13 . … I1,N-1 I1,N

I21 I22 . . … I2,N-1

I31 . . .

. . .

. . IN-2,3

. IN-1,2

IN1

Page 32: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 32

Example: Romberg Method for Integration

• For the function f(u) = ueku, the integral is

• Let k = 2, we want to calculate

The true value of the integral is 2.097264 (seven significant digits).

ckuk

eduue

kuku )1(

2

duue u1

0

2

Page 33: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 33

20678.2

)]75.025.0(5.052683.2[5.0

))]4

3()4

()((5.0[5.0

2 For

52683.2)]5.0)(01(69453.3[5.0

)]2

()([5.0

1 For

69453.3)10)(01(5.0

))()()((5.0

0 For

75.0225.02

1121

5.02

0111

1202

01

ee

abaf

abafabII

i

e

abafabII

i

ee

bfafabI

iWe have a=0, b=1.

Page 34: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 34

12478.2

))]8

)(7()

8

)(5(

)8

)(3()

8()((25.0[5.0

3 For

2131

abaf

abaf

abaf

abafabII

i

10415.2

))]16

)(15()

16

)(13()

16

)(11(

)16

)(9()

16

)(7()

16

)(5(

)16

)(3()

16()((125.0[5.0

4 For

3141

abaf

abaf

abaf

abaf

abaf

abaf

abaf

abafabII

i

Page 35: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 35

Table.7 Computations According to the Romberg Method

i j = 1 2 3 4 5 6

0 3.69453 2.13760 2.09759 2.09727 2.09726 2.09726

1 2.52683 2.10009 2.09727 2.09726 2.09726

2 2.20678 2.09745 2.09726 2.09726

3 2.12478 2.09728 2.09726

4 2.10415 2.09727

5 2.09899

Page 36: 7- 1 Chapter 7 Differentiation and Integration Finite-difference differentiation

7- 36

• Similarly for i = 5, I51=2.09899

• I02 is computed as following:

• I03 is computed as following:

• The Romberg method yields an exact value to six significant digits for the integral of 2.09726

13760.214

69453.3)52683.2(412

12

02

I

09759.214

13760.2)10009.2(413

13

03

I