Uploaded by hoseamaka

LECTURE 2 TRAPEZOIDAL AND SIMPSON RULES

advertisement
Trapezoidal Rule
Its mathematically given by;
Tn=Pn(x) + E(n)…………………………………1
β„Ž
2
I= [ f(a) + f(b) ]…………………………………2
Where equation 2 is Pn(x)
And E(X) which is the error term is given by;
β„Ž3
12
f’’(C)…………3
Derivation of Trapezoidal rule
Derivation ctd
• Assuming from the graph between the points a and b, there exists
values x0, x1, x2,x3 to xn for n interval
• Therefore, considering the number of intervals as
• n=1
• Which means we have x0, x1
Derivation ctd
• From our equation 1
I=
π‘₯−π‘₯1
y0[
]
π‘₯0−π‘₯1
+
π‘₯−π‘₯0
y1[
]…………………..4
π‘₯1−π‘₯0
Now we integrate both sides
π‘₯1
𝐼𝑑π‘₯
π‘₯0
= y0
π‘₯1 (π‘₯−π‘₯1)
π‘₯0 (π‘₯0−π‘₯1)
dx + y1
π‘₯1 (π‘₯−π‘₯0)
π‘₯0 (π‘₯1−π‘₯0)
dx
Derivation ctd
• After integrating we will get ;
π‘₯1
𝐼
π‘₯0
𝑑π‘₯ =
𝑦0
2
[1] +
𝑦1
2
[1]
The bracket will give us a constant (let it be h), thus
I=
𝑦0+𝑦1
h(
)
2
giving us the term Pn(x)
Derivation ctd
Where y0 if f(x0) and y1 is f(x1)
Now the error term is got from;
E(x)=
1 π‘₯1
2! π‘₯0
E(x)=
𝑓′′(𝐢) 𝑋1
𝑋0
2
π‘₯ − π‘₯1 π‘₯ − π‘₯0 𝑓 ′′ 𝐢 𝑑π‘₯
π‘₯ − π‘₯1 π‘₯ − π‘₯0 𝑑π‘₯
Derivation ctd
Now substituting the limits we will get the error term as ;
E(x)=
β„Ž3
12
𝑓′′(𝑐) …….
Thus giving us an exact value of the Trapezoid rule from eqn 1;
Tn=
𝑦0+𝑦1
h(
)
2
-
β„Ž3
12
𝑓′′(𝑐)
Improving the Trapezoid rule
The improved Trapezoid rule is given by
β„Ž
2
I= [ f(x0) + 2f(x1) + 2f(x2)+……..+f(xn) ] which is the Pn(x)
The error term remains the same thus the final improved trapezoid rule is
given
β„Ž
2
Tn(f) = = [ f(x0) + 2f(x1) + 2f(x2)+……..+f(xn) ] -
β„Ž3
12
𝑓′′(𝑐)
Note
The interval h is determined by; assuming the lower limit is a and
upper is b
h=
𝑏−π‘Ž
2
Example 1
• Use the trapezoidal rule to approximate the integral below
0.8
𝑖𝑛π‘₯𝑑π‘₯
0
Solution
Determine the h
Which is 0.4
Soln ctd
Now determine Pn(x) which is ;
Pn(x)=
0.4
2
[ in(0) + in(0.4) + in(0.8) ]
Pn(x)=--------------Now we determine the error term
E(x)=
β„Ž3
12
f’’(C)
Soln ctd
Now we first solve for second derivative of the function
f(x) = inx
f’(x)= 1/x
f’’(x)=
1
- 2
π‘₯
f’’(C) =
1
- 2
𝐢
Soln ctd
Where C is value which between the interval 0 and 0.8 that is 0<C<0.8
3
E(x)= -
0.4
12
E(x) ≈
− 0.4
12
Thus E(x) ≈
.
1
- 2
𝐢
3
. 1/1 since is taken a constant value 1
− 0.4
12
3
.
SOLN CTD
• Now combine the two values to obtain the approximation
Note
When you are going to use the improved, simply multiply the mid
values by 2 and starting and the end points remain the same .
The error term also remains the same
Now repeat the example using the improved Trapezoid rule
Trial
1. Use the trapezoid rule to approximate the following integrals
a)
1 π‘₯2
𝑒 𝑑π‘₯
0
b)
21
1 π‘₯
dx
1
SIMPSONS
3
RULE
The simpson rule of integration is given mathematically as;
β„Ž
3
I= [ y0 + 4 𝑓 π‘¦π‘œπ‘‘π‘‘ + 2
𝑓 𝑦𝑒𝑣𝑒𝑛 + 𝑓(𝑦𝑛)]-
β„Ž5
90
Error term
Simpson formular
fiv(C)
Derivation of Simpson’s Rule
Consider the graph having points a and b with intervals of n=2 that is
x0, x1, x2
Derivation ctd
• Then ;
I= y0 L0(x) + y1L1(x) + y2L2(x)
Now we integrate both sides
π‘₯2
𝐼𝑑π‘₯=
π‘₯0
Where ;
y0
π‘₯2
𝐿0
π‘₯0
π‘₯ 𝑑π‘₯ +y1
π‘₯2
𝐿1
π‘₯0
π‘₯ 𝑑π‘₯ + y2
π‘₯2
𝐿2
π‘₯0
π‘₯ 𝑑π‘₯
Derivation ctd
L0(x)=
(π‘₯−π‘₯1)(π‘₯−π‘₯2
(π‘₯0−π‘₯1)(π‘₯0−π‘₯2)
L1(x)=
(π‘₯−π‘₯0)(π‘₯−π‘₯2)
(π‘₯1−π‘₯0)(π‘₯1−π‘₯2)
L2(x) =
(π‘₯−π‘₯1)(π‘₯−π‘₯0)
(π‘₯2−π‘₯1)(π‘₯2−π‘₯0)
Now substitute the values of L0(x), L1(x) and L2(x)
Derivation ctd
• We therefore obtain
π‘₯2
π‘₯2 (π‘₯−π‘₯1)(π‘₯−π‘₯2
𝐼𝑑π‘₯= y0 π‘₯0
𝑑π‘₯
π‘₯0
(π‘₯0−π‘₯1)(π‘₯0−π‘₯2)
π‘₯2 (π‘₯−π‘₯1)(π‘₯−π‘₯0)
y2 π‘₯0
𝑑π‘₯
(π‘₯2−π‘₯1)(π‘₯2−π‘₯0)
+ y1
π‘₯2 (π‘₯−π‘₯0)(π‘₯−π‘₯2)
𝑑π‘₯
π‘₯0 (π‘₯1−π‘₯0)(π‘₯1−π‘₯2)
Giving a constant h on
integration and
substituting the limits
+
Derivation ctd
Which gives us;
β„Ž
3
Pn(x) = [ y0 + 4 𝑓 π‘œπ‘‘π‘‘ + 2
𝑓(𝑦𝑒𝑣𝑒𝑛) + yn ]
Now the ERROR term can be obtained from;
E(x) =
1 π‘₯2
3! π‘₯0
π‘₯ − π‘₯0 π‘₯ − π‘₯1 π‘₯ − π‘₯2 𝑓 𝑖𝑣 𝐢 𝑑π‘₯
On integration substituting the limits will give;
β„Ž5
E(x) = fiv(C)
90
Note
• Some books represent the ERROR term as
• E(x) =
𝑏−π‘Ž β„Ž4
180
fiv C where h =
𝑏−π‘Ž
2
• The error term is also sometimes represented with negative because we
account for some inaccuracies in the approximation of the function.
• You can choose to have negative on the error term or just subtract it during
the calculation
• It is therefore preferable to attach the negative on error term to avoid
difficulty in calculations
Example
Use simpson’s rule to approximate the integral
2
𝑖𝑛π‘₯𝑑π‘₯
1
Solution
From Simpson’s rule
β„Ž
3
I = [ y0 + 4 𝑓 π‘œπ‘‘π‘‘ + 2
h=
2−1
2
= 0.5
𝑓(𝑦𝑒𝑣𝑒𝑛) + yn ]
Soln ctd
• Where y0 = f(x0)= in(1)= --------• y1= f(x1)= in(0.5)=-----------• Y2= f(x2)= in(2)= ----------• now substitute these back to the simpson’s equation
I=
0.5
3
[ ( in 1 + 4in 0.5 + in 2 ]
Now we obtain the ERROR term
Soln ctd
E(x) =
β„Ž5
90
fiv C = −
0.5 5
90
f iv C
Now we obtain the forth derivative of the function f(x)=inx
F’(x) = 1/x
F’’(x) = -1/x2
F’’’(x) = -2/x3
Fiv(x) = -6/x4
Thus Fiv(C) = -6/c4
Now we substitute back to the ERROR term equation
Soln ctd
E(x) = −
0.5 5
6
.− 4
90
𝑐
=−−−−−−−−−−− −
Note
The constant C is approximated to be C=1
Now the simpson’s approximation is then obtained by;
Sn(x) = I + E(x)=--------------
Note
• Sometimes we might be asked to obtain the interval h when the error
term is given;
• It is mathematically obtained by
•
β„Ž5
90
fiv C <0.5x10-n
Where n is number of sub intervals
Example
• Using the previous example, How small does the error theory say that h has to be to get that the
error is less than
10~3? 10~6?
Solution
Starting with 10 ~3
From
β„Ž5
90
fiv C <0.5x10-n
Our n=3 and f^iv(C)= −
β„Ž5
90
fiv C <0.5x10-n
6
𝑐4
Soln ctd
• Substitute the values of n and f^iv(C) and obtain the h
• Repeat for error of 10~6 and obtain h
Note
• It applies to Trapezoidal rule too where the h is obtained given ERROR
value . It is given by
β„Ž3
• - 12 f ii C <0.5x10-n
• Take note that the f’’(C) is second derivative of the function for
trapezoid rule while fiv(C) is forth Derivative of the function for
Simpson’s rule
3
8
THE SIMPSON’S RULE
• This is mathematically given by
I=
3β„Ž
8
( f x0 + 3( f(x1 + f x2 + (f xn
Where h=
𝑏−π‘Ž
3
−1
+ β‹― + f xn )
The Error term
• It is given by
• E(x) =• E(x) =-
3β„Ž5
80
f 1v C = −
𝑏−π‘Ž β„Ž4
80
f iv (C)
3 𝑏−π‘Ž β„Ž4
3
80
f 1v C
Example
• Use the simpson’s 3/8 rule to approximate the integral
0.8
(0.2 + 25π‘₯ − 200π‘₯ 2 + 675π‘₯ 3 − 900π‘₯ 4 + 400π‘₯ 5 )dx
0
Soln
0.8−0
h=
3
=…………………………
Trials
Note
• For trial question 3, we have apply the xpression below to otain the h
in case the error term is given
•
3β„Ž5
80
f i𝑣 C <0.5x10-n
Download