chem 302 - math 252 chapter 4 differentiation & integration

29
Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Upload: jonas-upson

Post on 01-Apr-2015

230 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Chem 302 - Math 252

Chapter 4Differentiation & Integration

Page 2: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Differentiation & Integration

• Experimental data at discrete points

• Need to know the rate of change of the dependent variable with respect to the independent variable

• Need to know area under curve

• Need to integrate an analytic function that is too complicated to do analytically

• Can do interpolation/curvefitting to get an analytic function

Page 3: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Linear Differentiation

0 00 0lim x

f x x f xf x

x

0 00 small (Eqn 1)

f x x f xf x x

x

0 00 small (Eqn 2)

2

f x x f x xf x x

x

Page 4: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Eqn (1) Eqn (2)

x % error % error

Exact value 4.481689 4.481689

0.1 4.713434 5.0 4.489162 0.170.01 4.504172 0.50 4.481764 1.7×10-3

0.001 4.483931 5.0×10-2 4.481690 1.7×10-5

1×10-4 4.481913 5.0×10-3 4.481689 1.7×10-7

1×10-5 4.481711 5.0×10-4 4.481689 2.2×10-9

1×10-6 4.481691 5.0×10-5 4.481689 5.8×10-9

1×10-7 4.481689 5.2×10-6 4.481689 6.4×10-8

1×10-8 4.481689 1.3×10-7 4.481689 1.1×10-6

1×10-9 4.481690 1.4×10-5 4.481689 3.8×10-6

1×10-10 4.481695 1.3×10-4 4.481691 3.4×10-5

1×10-11 4.481748 1.3×10-3 4.481704 3.3×10-4

1×10-12 4.482636 2.1×10-2 4.482192 1.1×10-2

1×10-13 4.485301 8.1×10-2 4.480860 1.8×10-2

1×10-14 4.529710 1.1 4.485301 8.1×10-2

1×10-15 5.329071 19 4.884981 9.0

Linear Differentiation x xf x e f x e 5.1'f 5.1'f

0 00 (Eqn 1)

f x x f xf x

x

1 1

1 1

k kk

k k

f x f xf x

x x

Smaller spacing not necessarily better

0 00 (Eqn 2)

2

f x x f x xf x

x

Page 5: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

3 point Differentiation

• Linear differentiation ignores actual point

0 1 0 1 0 0 1 0 2f x p f x h p f x p f x h

1

2 0

2

3 0

1f x

f x x x

f x x x

• Make exact for

2 2 2 21 0 2 2 1 0 2 0 1

01 2 1 2

h f x h h h f x h f x hf x

h h h h

Maple Sheet

0 00 2

f x h f x hf x

h

Page 6: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Multi-point Differentiation

• Formulae only derived for equal spacing

• Non equal spacing solve equations numerically

0 0 0 0 0

12 8 8 2

2f x f x h f x h f x h f x h

h

Page 7: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Multi-point Differentiation

Coefficient

Demominator -4h -3h -2h -h 0 h 2h 3h 4h Exact to

1st derivative

2h -1 0 1 Quadratic

12h 1 -8 0 8 -1 Quartic

60h -1 9 -45 0 45 -9 1 6th order

840h 3 -32 168 -672 0 672 -168 32 -3 8th order

Page 8: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Multi-point Differentiation

Coefficient

Demominator -4h -3h -2h -h 0 h 2h 3h 4h Exact to

2nd derivative

h2 1 2 1 Quadratic

12h2 -1 16 -30 16 -1 Quartic

540h2 6 -81 810 -1470 810 -81 6 6th order

5040h2 -9 128 -1008 8064 -14350 8086 -1008 128 -9 8th order

Page 9: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Multi-point Differentiation

Coefficient

Demominator -4h -3h -2h -h 0 h 2h 3h 4h Exact to

3rd derivative

2h3 -1 2 0 -2 1 Quartic

48h3 6 -48 78 0 -78 48 -6 6th order

240h3 -7 72 -338 488 0 -488 338 -72 7 8th order

Page 10: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Technique% error % error % error

3-point -0.35635222 0.001 -0.18966826 0.0004

5-point -0.35635566 0 -0.18966907 0 0.20689002 0.002

7-point -0.35635566 0 -0.18966907 0 0.20689365 0

9-point -0.35635566 0 -0.18966907 0 0.20689365 0

Exact value -0.35635566 -0.18966907 0.20689365

Example

sin

0

1 0

xx

f x xx

xf xf xf

01.0

1.256637064.0

h

x

Page 11: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Numerical Integration

Page 12: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Midpoint Formula

• Uses value of function and slope at midpoint of interval

1 2 0w b a w

2 2

1 22 2

b a a bf x x w w b

11f x b a w

1 22 2

ba b a b

a

f x dx w f w f

• Determine w1 & w2

2

ba b

a

f x dx b a f

Page 13: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Composite Midpoint Formula

• n subintervals (equal spacing)

b ah

n

3 5 2 112 2 2 2

1

2

2 1

2

bn

a

n

i

f x dx h f a h f a h f a h f a h f a h f a h

ih f a h

Page 14: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Trapezoidal Integration

• Approximate f(x) by a linear function over interval [a,b]

f b f af x f a x a

b a

2 212

12

12

b b b

a a a

f b f af x dx f a dx x a dx

b a

f b f af a b a b a a b a

b a

f a b a f b f a b a a

f b f a b a

Page 15: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Trapezoidal Integration

• Alternate derivation• Linear combination of endpoints that give best estimate of

integral

1 2

b

a

f x dx w f a w f b

• Determine w1 & w2

1 21f x b a w w

2 2

1 22

b af x x w a w b

1 2 2

b aw w

Page 16: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Composite Trapezoidal Integration

• n subintervals (equal spacing)

b ah

n

1 12 2

2 2 32

2 3

b

a

hf x dx f a f a h f a h f a h f a h f a h f b

h f a f a h f a h f a h f b

Page 17: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Simpson’s Rule• Combines Trapezoidal and Midpoint

• Also referred to as 3 - point

1 3 2

2

6 3

b ab aw w w

2 2

1 2 32 2

b a a bf x x w a w w b

1 2 31f x b a w w w

1 2 32

ba b

a

f x dx w f a w f w f b

• Determine w1 w2 & w3

246

4 23

ba b

a

b af x dx f a f f b

hf a f a h f a h

23 32 2

1 2 33 2

b a a bf x x w a w w b

Package

Page 18: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Composite Simpson’s Rule

• 2n subintervals (equal spacing)

2

b ah

n

1

24 2 2 4 3 4 2

6

2 2 2 2 1 23

b

a

n

i

hf x dx f a f a h f a h f a h f a h f a h f a nh

hf a f a nh f a i h f a ih

Page 19: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Newton-Cotes Formula

• Generalization to use more than 3 points – Trapezoidal exact up to linear – (1st order NC)– Simpson’s exact up to quadratic (by definition but turns out to be

exact for up to cubic) – (2nd order NC)– Equivalent to integration of Lagrangian interpolation functions– 3rd order NC

• Use 4 points and functions up to cubic

– Higher orders can give larger errors

Page 20: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Newton-Cotes Formula

rd

3

3 order

33 3 2 3

8

a h

a

hf x dx f a f a h f a h f a h

th

4

4 order

27 32 12 2 32 3 7 4

45

a h

a

hf x dx f a f a h f a h f a h f a h

Package

Page 21: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

• So far evaluated function at fixed points & optimized coefficients

• Optimize locations also

1

11

n

i ii

z dz w z

• Optimize wi & zi

1

1

2 ( )

b

a

x dx z dz

x b az

b a

Page 22: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

• 1-point

1

1 1

1

z dz w z

• Need two equations

• Make exact for (z) = 1, & (z) = z

1

1 1

1

1

For 1

2

z

z dz w z

w

1

1 1

1

11 2

1 1

1 1

1

For

02

0

z z

z dz w z

zzdz w z

z

1

1

2 0z dz

Page 23: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

• 2-point

1

1 1 2 2

1

z dz w z w z

• Need four equations

• Make exact for (z) = 1, (z) = z, (z) = z2, (z) = z3

• Does not give unique solution

• Make symmetric about 0

1

1 1 1

1

z dz w z z

Gaussian Quadrature.mws

Page 24: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

1

1 1 1

1

1

1

1

1

1

For 1

1 2

2 2

1

z

z dz w z z

dz w

w

w

1

1 1

1

1

1 1

1

For

0 0

z z

z dz z z

zdz z z

2

1

1 1

1

12 2

1

1

1321

1

1

For

2

22

3 3

1

3

z z

z dz z z

z dz z

zz

z

Page 25: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

1

11

( ) ( )n

i ii

z dz w z

Roots (zi) Weight Factors (wi)

Two-Point Formula

±0.57735 02691 89626 1.00000 00000 00000

Three-Point Formula

0 0.88888 88888 88889

±0.77459 66692 41483 0.55555 55555 55556

Four-Point Formula

±0.33998 10435 84856 0.65214 51548 62546

±0.86113 63115 94053 0.34785 48451 37454

Page 26: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

1

11

( ) ( )n

i ii

z dz w z

Roots (zi) Weight Factors (wi)

Five-Point Formula

0±0.53846 93101 05683 ±0.90617 98459 38664

0.56888 88888 88889 0.47862 86704 99366 0.23692 68850 56189

Six-Point Formula

±0.23861 91860 83197±0.66120 93864 66265±0.93246 95142 03152

0.46791 39345 726910.36076 15730 481390.17132 44923 79170

Page 27: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

1

11

( ) ( )n

i ii

z dz w z

Roots (zi) Weight Factors (wi)

Ten-Point Formula

±0.14887 43389 81631±0.43339 53941 29247±0.67940 95682 99024±0.86506 33666 88985±0.97390 65285 17172

0.29552 42247 147530.26926 67193 099960.21908 63625 159820.14945 13491 505810.06667 13443 08688

Fifteen-Point Formula

0±0.20119 40939 97435±0.39415 13470 77563±0.57097 21726 08539±0.72441 77313 60170±0.84820 65834 10427±0.93727 33924 00706±0.98799 25180 20485

0.20257 82419 255610.19843 14853 271110.18616 10001 155620.16626 92058 169940.13957 06779 261540.10715 92204 671720.07036 60474 881080.03075 32419 96117

Page 28: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures

• Other forms

0

ze z dz

2

8

ze z dz

Page 29: Chem 302 - Math 252 Chapter 4 Differentiation & Integration

Gaussian Quadratures - Example

21

0

1

2xe dx

• Simpson’s Rule– Use 100 intervals

• Gaussian Quadrature– 3 and 15 point

Simpsons Gaussian Quadrature Example.mws