Numerical Integration

advertisement
Numerical Integration
Lesson 5.6
News from Space
• A new species has been trapped …
the rare zoid
• Math students
have long
known of
efforts of
"trapezoid" expeditions
• Trapezoids were so effective, zoids were
thought to be extinct!
Trapezoidal Rule
• Instead of calculating
approximation rectangles
we will use trapezoids
 More accuracy
• Area of a trapezoid
a
•
x
xi
b
• Which dimension is the h?
b2
• Which is the b1 and the b2
1
A   b1  b2   h
2
h
b1
Trapezoidal Rule
• Trapezoidal rule
approximates the integral
f(xi-1)
f(xi)
dx
b

a
dx
f ( x)dx   f ( x0 )  2 f ( x1 )  2 f ( x2 )  ...2 f ( xn 1 )  f ( xn ) 
2
ba
where dx 
n
• Calculator function for f(x)
((2*f(a+k*(b-a)/n),k,1,n-1)+f(a)+f(b))*(b-a)/(n*2)
trap(a,b,n)
Trapezoidal Rule
• Entering the trapezoidal rule into the
calculator
• f(x) must be defined for this to work
Trapezoidal Rule
2
• Try
5
2
x
 dx n  8
using the trapezoidal rule
0
• Check with integration
Simpson's Rule
• As before, we divide
the interval into n parts
Snidly Fizbane
Simpson
 n must be even
• Instead of straight lines we
•
a
xi
draw parabolas through
each group of three consecutive points
b
 This approximates the original curve for finding
definite integral – formula shown below
b

a
f ( x)dx 
dx
[ f ( x0 )  4 f ( x1 )  2 f ( x2 )  4 f ( x3 )  2 f ( x4 )
3
 ...  2 f ( xn2 )  4 f ( xn1 )  f ( xn )]
Simpson's Rule
• Our calculator can do this for us also
• The function is more than a one liner
 We will use the program editor
 Choose APPS,
7:Program Editor
3:New
• Specify Function,
name it simp
Simpson's Rule
• Enter the parameters a, b, and n between
the parentheses
Local variables
discarded when
function finishes
Initialize dx
Initialize total with the
twoEnter
end values
commands
shown between
One for
loop
for the
Func
and
endFunc
4* values, one for the
2* values
Return the value
Simpson's Rule
• Specify a function for f(x)
• When you call simp(a,b,n),
 Make sure n is an even number
• Note the accuracy of the approximation
Assignment A
• Lesson 5.6
• Page 350
• Exercises 1 – 23 odd
Error Estimation
• Trapezoidal error
for f on [a, b]
En
b  a


12n
3
M
2
 Where M = max value of |f ''(x)| on [a, b]
• Simpson's error
for f on [a, b]
En
b  a


180n
4
5
K
 Where K = max value of |f (4)(x)| on [a, b]
Using Data
• Given table of data, use trapezoidal rule to
determine area under the curve
x
2.00 2.10 2.20 2.30 2.40 2.50 2.60
y
4.32 4.57 5.14 5.78 6.84 6.62 6.51
 dx = ?
b

a
dx
f ( x)dx   f ( x0 )  2 f ( x1 )  2 f ( x2 )  ...2 f ( xn 1 )  f ( xn ) 
2
Using Data
• Given table of data, use Simpson's rule to
determine area under the curve
b

a
x
2.00 2.10 2.20 2.30 2.40 2.50 2.60
y
4.32 4.57 5.14 5.78 6.84 6.62 6.51
dx
f ( x)dx  [ f ( x0 )  4 f ( x1 )  2 f ( x2 )  4 f ( x3 )  2 f ( x4 )
3
 ...  2 f ( xn2 )  4 f ( xn1 )  f ( xn )]
Assignment B
• Lesson 5.6
• Page 350
• Exercises 27 – 39 odd
49, 51, 53
Download