Numerical Integration: Trapezoidal, Simpson's, Gauss-Legendre, and Romberg Methods - Prof., Assignments of Computer Science

An assignment from the amsc/cmsc 460 course, given by dr. Wolfe, which covers various methods for numerical integration using matlab. Students are required to write matlab programs to evaluate integrals using the trapezoidal rule, simpson's rule, gauss-legendre integration, and romberg integration. They also need to compare the results and analyze the rate of convergence.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-amx
koofers-user-amx 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AMSC/CMSC 460 Dr. Wolfe ASSIGNMENT #4 Due July 10, 2009
1. Write a MATLAB program to evaluate I=Rb
af(x)dx using the trapezoidal rule
with nsubdivisions, calling the result In. Use the program to calculate the following
integrals with n= 2,4,8,16,...,512.
(a) Z1
0p16 + x2dx (b) Z1
0
x3/8dx
The exact value of the integral in (a) is 4.04128450518694.
Analyze emperically the rate of convergence of Into Iby calculating the ratios
Rn=I2nIn
I4nI2n
and pn=log(Rn)
log(2)
In part (b) compute the extrapolated approximation to I,
I˜=I4n(I4nI2n)2
(I4nI2n)(I2nIn)
for n= 128.
2. Repeat problem 1 using Simpson’s rule.
3. Apply the corrected trapezoidal rule to the integral in problem 1(a). Compare the
results with those of problem 2 for Simpson’s rule.
4. Use Gauss-Legendre integration with n= 2,4,8 nodes to the integrals of problem 1.
Compare the results with those for the trapezoidal and Simpson methods.
5. Find approximate values of the integral in problem 1(a) by computing the Romberg
integral I(5)
32 where I(0)
nis the n-panel trapezoid approximation and
I(k)
n=4kI(k1)
nI(k1)
n/2
4k1
for ndivisible by 2k.
6. Use the MATLAB function QUADL to find approximate values of the integrals 1(a)
and 1(b).
7. Ex. 6.13 p.181 Numerical Computing with MATLAB.
8. The 11 point Newton-Cotes integration rule on [0,1] is
Z1
0
f(x)dx
10
X
i=0
wif(i
10)
pf2

Partial preview of the text

Download Numerical Integration: Trapezoidal, Simpson's, Gauss-Legendre, and Romberg Methods - Prof. and more Assignments Computer Science in PDF only on Docsity!

AMSC/CMSC 460 Dr. Wolfe ASSIGNMENT #4 Due July 10, 2009

  1. Write a MATLAB program to evaluate I =

∫ (^) b a f^ (x)^ dx^ using the trapezoidal rule with n subdivisions, calling the result In. Use the program to calculate the following integrals with n = 2, 4 , 8 , 16 ,... , 512.

(a)

0

16 + x^2 dx (b)

0

x^3 /^8 dx

The exact value of the integral in (a) is 4.04128450518694. Analyze emperically the rate of convergence of In to I by calculating the ratios

Rn =

I 2 n − In I 4 n − I 2 n

and pn =

log(Rn) log(2)

In part (b) compute the extrapolated approximation to I,

I =˜I 4 n −

(I 4 n − I 2 n)^2 (I 4 n − I 2 n) − (I 2 n − In)

for n = 128.

  1. Repeat problem 1 using Simpson’s rule.
  2. Apply the corrected trapezoidal rule to the integral in problem 1(a). Compare the results with those of problem 2 for Simpson’s rule.
  3. Use Gauss-Legendre integration with n = 2, 4 , 8 nodes to the integrals of problem 1. Compare the results with those for the trapezoidal and Simpson methods.
  4. Find approximate values of the integral in problem 1(a) by computing the Romberg integral I 32 (5) where I n(0) is the n-panel trapezoid approximation and

I n(k )=

4 kI n(k −1)− I n/(k− 2 1) 4 k^ − 1

for n divisible by 2k.

  1. Use the MATLAB function QUADL to find approximate values of the integrals 1(a) and 1(b).
  2. Ex. 6.13 p.181 Numerical Computing with MATLAB.
  3. The 11 point Newton-Cotes integration rule on [0, 1] is

∫ (^1)

0

f (x) dx ≈

∑^10

i=

wif (

i 10

with the wi determined by requiring that the rule be exact for f (x) = 1, x, x^2 ,... x^10. (a) Use MATLAB to find the weights wi. (b) Apply the rule to the integrals in 1(a) and 1(b). Note the errors.

  1. We wish to estimate the value of

I =

0

e−x^ cos^2 x dx =. 6

(a) Truncate the integral and use QUAD on the finite part. (b) Try the transformation x = − ln t on this integral and use QUADL on the new integral. (QUADL will complain but will do it). (c) Use the 2, 4 and 8 point Gauss-Laguerre rules to estimate the integral. compare your results with parts (a) and (b) above.

  1. In a standard shell and tube heat exchanger hot vapor condenses on the tube, main- taining a constant temperature Ts. If the input is at temperature T 1 and the output must be at temperature T 2 , then the length of tube required is given by

L =

m πD

∫ T 2

T 1

cρdT h(Ts − T )

(All quantities must be in consistent units.) Here T is the temperature in ◦F. T 1 = 0◦F is the inlet temperature. T 2 = 180◦F is the desired outlet temperature. Ts = 250◦F is the condensate temperature. m is the fluid flow rate = 45, 000 lb/hr. D is the diameter of the tube = 1.032 in. cρ is the specific heat of the fluid = (0.53 + 0. 00065 T ) BTU/(lb◦F). h is the local heat transfer coefficient = 0.^023 D k( (^) πDμ^4 m )^0.^8 ( μcρ k )

k is the thermal conductivity of the fluid = 0.153 BTU/(hr ft◦F). μ is the viscosity of the fluid and has units lb/(ft hr). μ varies with temperature so that T 0 50 100 150 200 μ 242 82.1 30.5 12.6 5. Use spline interpolation to define μ for other values of T and calculate the required length of the heat exchanger. You will need to use the MATLAB functions SPLINE and QUADL. The answer is about 158.7 ft.