0% found this document useful (0 votes)
45 views

b−a n π h f x x x …+2 f x f x π f (0) +2 f π f (π) π f (0) +2 f π π f (π) π

1. Both the Trapezoidal and Simpson's methods converge almost linearly for this problem, with Simpson's method converging slightly faster. 2. For a given tolerance, the number of iterations needed for the Trapezoidal and Simpson's rules were calculated. Simpson's rule achieved the same accuracy as Trapezoidal with significantly fewer iterations. 3. A 1-point Gauss quadrature approximation was derived and its error calculated. Higher order Gauss quadrature approximations were also derived and their errors decreased with each additional point.

Uploaded by

Carlo Karam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

b−a n π h f x x x …+2 f x f x π f (0) +2 f π f (π) π f (0) +2 f π π f (π) π

1. Both the Trapezoidal and Simpson's methods converge almost linearly for this problem, with Simpson's method converging slightly faster. 2. For a given tolerance, the number of iterations needed for the Trapezoidal and Simpson's rules were calculated. Simpson's rule achieved the same accuracy as Trapezoidal with significantly fewer iterations. 3. A 1-point Gauss quadrature approximation was derived and its error calculated. Higher order Gauss quadrature approximations were also derived and their errors decreased with each additional point.

Uploaded by

Carlo Karam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem 1:

b−a π
a) For n = 2, h= =
n 2
h
T n= f ( x 0 ) +2 f ( x 1) + 2 f ( x2 ) + …+2 f ( x n−1) + f ( x n ) ]
2[

π π
T 2=
2 [
f ( 0 )+2 f
2()
+ f ( π ) =0
]
π π π 3π
For n = 4, T 4=
8 [
f ( 0 ) +2 f
4 () () ( )
+2 f
2
+2 f
4
+f (π )
]
π
¿ ¿
8
Using MATLAB, T 8=−5.6859, T 16=−6.3690, T 32=−6.6192, T 64=−6.7092,
T 128=−6.7413, T 256 =−6.7527, T 512=−6.7567, T 1024=−6.7582.
b−a π
b) For n = 2, h= =
n 2
h
Sn = f ( x ) + 4 f ( x 1 ) +2 f ( x 2 ) +…+ 4 f ( x n−1 ) + f ( xn ) ]
3[ 0

π π
S2 =
6 [
f ( 0 ) +4 f
2 ()
+ f ( π ) =0
]
π π π 3π
For n = 4, S4 =
12[f ( 0 )+ 4 f
4 () () ( )
+2 f
2
+4 f
4
+f ( π)
]
π
¿ ¿
12
Using MATLAB, S8=−6.2802, S16−6.5967 , S32=−6.7026 , S64=−6.7392,
S128 =−6.7520 , S256 =−6.7565 , S512 −6.7581, S1024 =−6.7586 .

Both methods converge in an almost linear fashion, and it seems like Simpson’s method
converges a bit faster than the Trapezoidal method.
c) The 1-point Gauss quadrature approximation is given by:

I =( b−a ) f ( b+a2 )=πf ( π2 )=0


The corresponding exact error is E=6.75895053542226493775

The 2-point Gauss quadrature approximation is given by:


b−a b−a −1 b +a
I= [ w1 f ( x 1 )+ w2 f ( x 2 ) ] with w 1=w 2=1 and x 1= × + and
2 2 √3 2
b−a 1 b +a
x 2= × +
2 √3 2
π
I = ( 1.200848673732296−7.365634403700572 )=−9.683654196038297
2
The corresponding error is E=2.924703660616032.
Using the 3-point Gauss quadrature approximation with the corresponding values of x
provided, we get:
I =−7.140892288247433
The corresponding error is E=0.381941752825168.
Using the 4-point Gauss quadrature approximation with the corresponding values of x
provided, we get:
I =−6.913978757760276
The corresponding error is E=0.155028222338011.

Problem 2:
For the Trapezoidal rule
3
k ( b−a) b−a
|Error|≤ with k ≤ f ' ' ( x) and n=
12n 2
h

k (b−a)3 k h2 (b−a)
|Error|≤ =
12n 2 12

The maximum value of f ' ' ( x) on the given interval is f ' ' (1)=70.9183 which will be the
value of k for our upper bound.

k h2 (b−a) 70.9183× 2h 2 141.8366 h2


= =
12 12 12
We use the above upper bound to determine n for the given tolerance.
141.8366 h2 −10
=10 ; h=2.908683498× 10−6
12
b−a 2
Therefore, n= = =687597
h 2.908683498 ×10−6
Using the MATLAB code to find the value of the Trapezoidal rule approximation, we get that
the corresponding absolute error is 2.436584267684339× 10−11

For Simpson’s rule

k ( b−a)5 b−a
|Error|≤ with k ≤ f (4) (x ) and n=
180 n 4
h
5 2
k (b−a) k h (b−a)
|Error|≤ =
180 n 4 180

The maximum value of f (4 ) (x) on the given interval is f ' ' (0.893)=395.9 which will be the
value of k for our upper bound.

k h4 ( b−a) 395.9 ×2 h4 791.8 h 4


= =
180 180 180
We use the above upper bound to determine n for the given tolerance.

791.8 h4 −10
=10 ; h=2.183555585× 10−3
180
b−a 2
Therefore, n= = =915.937=916
h 2.183555585 ×10−3
Using the MATLAB code to find the value of the Trapezoidal rule approximation, we get that
the corresponding absolute error is 4.87812423345189981 ×10−11 .
We notice that Simpson’s rule achieves the same accuracy as the Trapezoidal rule with a
significantly fewer number of iterations.
Problem 3:
Let f ( x )=ax+ b
1 1

∫ √ x f ( x )=∫ √ x ( a x+ b )
0 0

1
x5 / 2 x 3 /2
I =∫ ( a x 3 /2 +b x 1/ 2) dx =a×
0 5 /2
+b ×
3 /2 |
⟹ I= ( 25 a+ 23 b )= 23 ( 35 a+ b)=w f ( x )
1 1

2 3
Therefore, w 1= and x 1=
3 5
2 3
⟹I≈ f
3 5 ()
For f ( x )=cos x ≈ 1 (linear polynomial)
1
2
⟹ I =∫ √ x f ( x ) ≈
0 3
1

{ 2
} 2
error = ∫ √ x cos x − =0.5312− =0.1355
0 3 3

You might also like