University of Florida/Egm6341/s10.Team2/HW3
Problem 1: Proof of tighter error bound for Simpsons Rule (Simple)
editProblem Statement
edit
- Derive the tighter error bound of the simple Simpson's rule on pg.14-2 for the following two cases by changing the function:
Point out where the proof breaks down.
- Find if and follow the same steps as in the proof to see what happens.
Problem Solution
editDerivation of Tighter Error Bound of Simple Simpson's Rule
edit
Shift origin of x axis to point at
Therefore,
By Definition:
Proof breaks down here. Neglects to properly integrate
Proof breaks down here. Neglects to properly integrate
Solution of Tighter Error Bound Function at t=0
edit
Solution for problem 1:Egm6341.s10.team2.patodon 10:05, 17 February 2010 (UTC)
Proofread problem 1:
Problem 2: Composite Simpsons Rule Error
editProblem Statement
editPg. 17-2 Show that the error of the Composite Simpson's Rule is:
where is the maximum of
Problem Solution
editThe error for the Simpson's Composite rule, can be expressed as follows:
This error can be rewritten as follows:
This can be expressed by using the Composite Simpson's rule and dividing the interval 'a' to 'b' into smaller intervals, the error can be expressed as follows:
In this manner the error for simple Simpson's rule can be used to describe the error as follows:
Using this expression the error can then be expressed as follows:
Solution for problem 2: Guillermo Varela
Proofread problem 2: Srikanth Madala 05:22, 18 February 2010 (UTC)
Problem 3: Using Error Analysis to find n for Taylor Series, Composite trapezoidal rule and Composite Simpon's rule such that error is of the order of (10^-6)
editProblem Statement
editSee also HW1-problem 8HW1-problem8
- Using the error estimates of Taylor Series ,Composite Trapezoidal rule and Composite Simpson's rule estimate such that and compare against numerical results of HW1.
- Numerically find the power of the step size h in the error i.e Plot the error vs h on semilog and fit a straight line and measure the slope.
Note: This problem is a logical continuation of problem 8 in HW1. In HW1 it was attempted by iteration to find the value of n. In this problem it is done analytically.All numerical data can be found on the HW1 page linked above and also the corresponding MATLAB codes.
Problem Solution
editSolution: Taylor series
editError is defined as
For the Taylor series, from the discussion on p6-4, we know that the error is nothing but the remainder of the Taylor series integrated over the given interval i.e
where
(1 p2-3)
For the given function the error is
(2)
Using the Integral Mean Value Theorem, we have
(3)
integrating we get,
(4)
This function has a minimum when and maximum when thus we have
(5)
Setting the upper bound of the error to we have
(6)
Solving this equation for we get
(A)
Solution:Composite Trapezoidal rule
editFrom the discussion on page 16-3 we have
(1)
where for
For the given function , we have
(2)
Evaluating over the given interval it is seen that the function has maximum value at
(3)
Setting the error to the and solving for we get
(B)
Solution :Composite Simpson's Rule
editWe have from p 17-2, the error estimate of the Composite Simpson's rule as
(1)
where for
For the given function , we have
(2)
Evaluating over the given interval it is seen that the function has maximum value at
(3)
Setting the error to the and solving for we get
(c)
Part 2:Numerical determination of power of h
editIn order to verify the power of in the error, data from Problem 8 of HW1 is used.
In the case of a Semilog plot [log(y) vs x], a straight line has an equation of the form
such that .From the above equation it is seen that if the plot on a semilog graph is a straight line then the relationship between the two variables is exponential.
A log-log plot(log(y) vs log(x)) is a similar plot, for which the equation is of the form
such that, .It is readily seen that the slope of the line in the log-log graph is the power of the x variable.
Further reference on the theory of semilog and log plots and methods to fit curves is given below:
- Semilog plot [[[w:Semi-log_graph]]]
- Log-Log plot [[[w:Log-log_graph]]]
- Methods of fitting curves in MATLAB for power and exponential series [[1]]
This discussion is used in the interpretation of the graphs given below.
Composite trapezoidal Rule
editGiven below is the data from the numerical evaluation of the given function using Composite Trapezoidal Rule.[[[Egm6341.s10.Team2/HW1#Solution_1]]]
Composite Trapezoidal Rule
| ||
No. of terms |
Absolute Error |
|
2 |
1.3282917278 |
0.5 |
4 |
1.3205046195 |
0.25 |
8 |
1.3185530869 |
0.125 |
16 |
1.3180649052 |
0.0625 |
32 |
1.3179428411 |
0.03125 |
64 |
1.3179123240 |
0.015625 |
128 |
1.3179046946 |
0.0078125 |
256 |
1.3179027872 |
0.00390625 |
512 |
1.3179023104 |
0.001953125 |
1024 |
1.3179021912 |
0.000976563 |
First we plot a semilog graph for the data. The graph is shown below:
The graph is not a straight line which implies that the relationship between and is not exponential. Hence we plot a log-log graph as below:
This is seen to be linear. A straight line if fitted to the data the equation of which is given above. From the discussion above, we see that the slope of line is 2.1447 which is very close to the analytical value of 2.
Composite Simpson's Rule
editGiven below is the data obtained from HW1 for the Composite Simpsons Rule.[[[Egm6341.s10.Team2/HW1#Solution_1]]]
Composite Simpson's Rule
| ||
No. of terms |
Absolute Error |
|
2 |
1.318008666 |
0.5 |
4 |
1.317908917 |
0.25 |
8 |
1.317902576 |
0.125 |
16 |
1.317902178 |
0.0625 |
Plotting a semilog graph of against we see that it is non-linear as in the case of the Composite Trapezoidal Rule.
Thus, plotting the log-log graph as below,
we see that the slope of the line is 4.0881 which is very close to the analytically determined value of 4.
Taylor Series
editGiven below is the data for the Taylor series method. can be defined for the taylor series as but since is not used explicitly in the Taylor series method,it might be of interest to observe how error depends on ,the number of terms of the series. Given below are the plots.Semilog plots and log-log plots can be made of error vs h much like the ones given above, but no linearity is shown in both.
Taylor Series
| ||
No. of terms |
Absolute Error |
|
2 |
1.2500000 |
0.5 |
4 |
1.3159722222 |
0.25
|
8 |
1.3179018152 |
0.125 |
16 |
1.3179021515 |
0.0625 |
32 |
1.3179021515 |
0.03125 |
From this plot it is clearly seen that minimizing the error does not require an infinite series.The error curve is asymptotic and it can be seen that 8 terms gives a very low error.
Solution for problem 3: Niki Nachapa
Proofread problem 3: Guillermo Varela
Problem 4: Illustrations and comparisons of composite Trapezoidal and composite Simpson's rules
editProblem Statement
edita] Replicate the table 5.1, page 255, Atkinson text book using the composite Trapezoidal rule .
b] Replicate the table 5.3, page 258, Atkinson text book using the composite Simpson's rule .
c] Replicate the table 5.4, page 261, Atkinson text book
d] Replicate the table 5.5, page 262, Atkinson text book
e] Replicate the table 5.6, page 262, Atkinson text book
f] Replicate the table 5.7, page 263, Atkinson text book
Problem Solution
editSolution for Part (a):
Here our given Integral is:
where is the integrand and . We use composite Trapezoidal rule to obtain the following tabulated results:
n-value |
Numerical Integral (In) |
True Error (En) |
Ratio of successive errors (R) |
Corrected Error (En2)
|
2 | -1738925933/100000000 | 531891301/100000000 | 62046637/12500000
| |
4 | 266720457/20000000 | 126567653/100000000 | 4.2 | 62046637/50000000
|
8 | -1238216243/100000000 | 31181611/100000000 | 4.06 | 31023319/100000000
|
16 | -121480041/10000000 | 3882889/50000000 | 4.02 | 775583/10000000
|
32 | -302243553/25000000 | 96979/5000000 | 4.00 | 1938957/100000000
|
64 | -120751941/10000000 | 242389/50000000 | 4.00 | 484739/100000000
|
128 | -1207155819/100000000 | 121187/100000000 | 4.00 | 24237/20000000
|
256 | -37720779/3125000 | 3787/12500000 | 4.00 | 3787/12500000
|
512 | -603521103/50000000 | 3787/50000000 | 4.00 | 3787/50000000
|
MATLAB Code:
%Code for evaluating the numerical integrals- 'In' for n=2,4,8,...512, Error values- 'En', Corrected Error Values- 'En2' and ratio of successive errors- 'R' %
syms x;
f=(exp(x)*cos(x));
g=diff(f);
F0=(exp(0)*cos(0));
Fpi=(exp(pi)*cos(pi));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(pi/n(i)));
F=(exp(X).*cos(X));
G=sum(F);
In(i)=((pi/n(i))*(sum(F)-(0.5*(F0+Fpi))));
end
I(i)=int(f,0,pi);
En(i)=I(i)-In(i);
En2(i)=-((((pi/n(i))^2)/12)*(subs(g,x,pi)-subs(g,x,0)));
end
round(En*100000000)/100000000;
round(En2*100000000)/100000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Solution for Part (b):
Here our given Integral is:
where is the integrand and . We use composite Simpson's rule to obtain the following tabulated results:
Simpson's rule for evaluating a function- Table 5.3, Atkinson text pg.258
| ||||
n-value |
Numerical Integral (In) |
True Error (En) |
Ratio of successive errors (R) |
Corrected Error (En2) |
2 | -407886780413711/35184372088832 | -477506763/1000000000 | -7354387343260823/4503599627370496 | |
4 | -6746923677694755/562949953421312 | -427011483/5000000000 | 55913/10000 | -7354387342810463/720575940379 |
8 | -1697886467632563/140737488355328 | -7671699/1250000000 | 8697/625 | -3677193678610991/576460752303423488 |
16 | -1698694633809107/140737488355328 | -3949931/10000000000 | 155379/10000 | -7354386665469079/18446744073709551616 |
32 | -849373362683185/70368744177664 | -248603/10000000000 | 31777/2000 | -3677188721048521/147573952589676412928 |
64 | -6795000020382587/562949953421312 | -3113/2000000000 | 39931/2500 | -7354613560421185/4722366482869645213696 |
128 | -3397500420910727/281474976710656 | -973/10000000000 | 159931/10000 | -918972517566433/9444732965739290427392 |
MATLAB Code:
%Code for evaluating the numerical integrals for n=2,4,8,...128, Error values 'Enr', Corrected Error Values 'En2r' and ratio of successive errors- 'Rr' %
clc;
clear;
syms x;
f=(exp(x)*cos(x));
g=diff(f,3);
F0=(exp(0)*cos(0));
Fpi=(exp(pi)*cos(pi));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(pi/n(i)));
F=(exp(X).*cos(X));
G=sum(F);
if (mod(k,2)==0)
O(k)=F(k);
E(k)=0;
else
O(k)=0;
E(k)=F(k);
end
end
In(i)=((pi/(3*n(i)))*((4*sum(O))+(2*sum(E))-(F0+Fpi)));
I(i)=int(f,0,pi);
En(i)=I(i)-In(i);
En2(i)=-((((pi/n(i))^4)/180)*(subs(g,x,pi)-subs(g,x,0)));
end
Enr=round(En*10000000000)/10000000000;
En2r=round(En2*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
Solution for Part (c):
Here our given Integral is:
where is the integrand and . We use both composite Trapezoidal and Simpson's rules to obtain the following tabulated results:
Trapezoidal and Simpson's rule for evaluating a function- Table 5.4, Atkinson text pg.261
| ||||
n-value |
Trapezoidal rule True Error (En) |
Trapezoidal rule Ratio of successive errors (Rr) |
Simpson's rule True Error (En) |
Simpson's rule Ratio of successive errors (Rr) |
2 | -0.0720 | 3.9618 | -0.0034 | 14.5578 |
4 | -0.0182 | 3.9898 | -0.0002 | 15.0027 |
8 | -0.0046 | 3.9973 | -1543/100000000 | 15.3142 |
16 | -0.0011 | 3.9993 | -2519/2500000000 | 15.5267 |
32 | -0.0003 | 3.9998 | -649/10000000000 | 15.6715 |
64 | -0.0001 | 4.0000 | -41/10000000000 | 15.7709 |
128 | -0.000003 | 4.0000 | -3/10000000000 | 15.8396 |
MATLAB Code:
%Code for Composite Trapezoidal rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors- 'Rr' %
clc;
clear;
syms x;
f=((x^3)*sqrt(x));
g=diff(f);
F0=((0^3)*sqrt(0));
F1=((1^3)*sqrt(1));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(1/n(i)));
F(k)=((X(k))^(3.5));
G=sum(F);
In(i)=((1/n(i))*(sum(F)-(0.5*(F0+F1))));
end
I(i)=int(f,0,1);
En(i)=I(i)-In(i);
En2(i)=-((((1/n(i))^2)/12)*(subs(g,x,1)-subs(g,x,0)));
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
En2r=round(En2*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
%Code for Composite Simpson's rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors: 'Rr' %
clc;
clear;
syms x;
f=((x^3)*sqrt(x));
g=diff(f,3);
F0=((0^3)*sqrt(0));
F1=((1^3)*sqrt(1));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(1/n(i)));
F(k)=((X(k))^(3.5));
G=sum(F);
if (mod(k,2)==0)
O(k)=F(k);
E(k)=0;
else
O(k)=0;
E(k)=F(k);
end
end
In(i)=((1/(3*n(i)))*((4*sum(O))+(2*sum(E))-(F0+F1)));
I(i)=int(f,0,1);
En(i)=I(i)-In(i);
En2(i)=-((((1/n(i))^4)/180)*(subs(g,x,1)-subs(g,x,0)));
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
En2r=round(En2*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
Solution for Part (d):
Here our given Integral is:
where is the integrand and . We use both composite Trapezoidal and Simpson's rules to obtain the following tabulated results:
Trapezoidal and Simpson's rule for evaluating a function- Table 5.5, Atkinson text pg.262
| ||||
n-value |
Trapezoidal rule True Error (En) |
Trapezoidal rule Ratio of successive errors (Rr) |
Simpson's rule True Error (En) |
Simpson's rule Ratio of successive errors (Rr) |
2 | 1731114401/10000000000 | 2.4348 | -1426645891/5000000000 | -7.6920 |
4 | 710986397/10000000000 | 9.4851 | 370943729/10000000000 | -2.7066 |
8 | 37479089/5000000000 | 3.8373 | -34262807/2500000000 | -129.3779 |
16 | 19534027/10000000000 | 3.9934 | 1059309/10000000000 | 98.0853 |
32 | 4891607/10000000000 | 3.9983 | 27/25000000 | 16.0159 |
64 | 1223407/10000000000 | 3.9996 | 337/5000000000 | 15.9909 |
128 | 305883/10000000000 | 3.9999 | 21/5000000000 | 15.9978 |
MATLAB Code:
%Code for Composite Trapezoidal rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors- 'Rr' %
clc;
clear;
syms x;
f=(1/(1+((x-pi)^2)));
g=diff(f);
F0=(1/(1+((0-pi)^2)));
F5=(1/(1+((5-pi)^2)));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(5/n(i)));
F(k)=(1/(1+((X(k)-pi)^2)));
G=sum(F);
end
In(i)=((5/n(i))*(sum(F)-(0.5*(F0+F5))));
I(i)=int(f,0,5);
En(i)=I(i)-In(i);
En2(i)=-((((5/n(i))^2)/12)*(subs(g,x,5)-subs(g,x,0)));
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
En2r=round(En2*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
%Code for Composite Simpson's rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors: 'Rr' %
clc;
clear;
syms x;
f=(1/(1+((x-pi)^2)));
g=diff(f,3);
F0=(1/(1+((0-pi)^2)));
F5=(1/(1+((5-pi)^2)));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(5/n(i)));
F(k)=(1/(1+((X(k)-pi)^2)));
G=sum(F);
if (mod(k,2)==0)
O(k)=F(k);
E(k)=0;
else
O(k)=0;
E(k)=F(k);
end
end
In(i)=((5/(3*n(i)))*((4*sum(O))+(2*sum(E))-(F0+F5)));
I(i)=int(f,0,5);
En(i)=I(i)-In(i);
En2(i)=-((((5/n(i))^4)/180)*(subs(g,x,5)-subs(g,x,0)));
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
En2r=round(En2*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
Solution for Part (e):
Here our given Integral is:
where is the integrand and . We use both composite Trapezoidal and Simpson's rules to obtain the following tabulated results:
Trapezoidal and Simpson's rule for evaluating a function- Table 5.6, Atkinson text pg.262
| ||||
n-value |
Trapezoidal rule True Error (En) |
Trapezoidal rule Ratio of successive errors (Rr) |
Simpson's rule True Error (En) |
Simpson's rule Ratio of successive errors (Rr) |
2 | 0.0631 | 2.6990 | 0.0286 | 2.8200 |
4 | 0.0234 | 2.7393 | 0.0101 | 2.8267 |
8 | 0.0085 | 2.7667 | 0.0036 | 2.8281 |
16 | 0.0031 | 2.7854 | 0.0013 | 2.8284 |
32 | 0.0011 | 2.7983 | 0.0004 | 2.8284 |
64 | 0.0004 | 2.8073 | 0.00015856 | 2.8284 |
128 | 0.0001 | 2.8136 | 0.000056 | 2.8284 |
MATLAB Code:
%Code for Composite Trapezoidal rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors- 'Rr' %
clc;
clear;
syms x;
f=(x^0.5);
g=diff(f);
F0=(0^0.5);
F1=(1^0.5);
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(1/n(i)));
F(k)=(X(k)^0.5);
G=sum(F);
end
In(i)=((1/n(i))*(sum(F)-(0.5*(F0+F1))));
I(i)=int(f,0,1);
En(i)=I(i)-In(i);
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
%Code for Composite Simpson's rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors: 'Rr' %
clc;
clear;
syms x;
f=(x^0.5);
g=diff(f,3);
F0=(0^0.5);
F1=(1^0.5);
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*(1/n(i)));
F(k)=(X(k)^0.5);
G=sum(F);
if (mod(k,2)==0)
O(k)=F(k);
E(k)=0;
else
O(k)=0;
E(k)=F(k);
end
end
In(i)=((1/(3*n(i)))*((4*sum(O))+(2*sum(E))-(F0+F1)));
I(i)=int(f,0,1);
En(i)=I(i)-In(i);
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
Solution for Part (f):
Here our given Integral is:
where is the integrand and . We use both composite Trapezoidal and Simpson's rules to obtain the following tabulated results:
Trapezoidal and Simpson's rule for evaluating a function- Table 5.7, Atkinson text pg.263
| ||||
n-value |
Trapezoidal rule True Error (En) |
Trapezoidal rule Ratio of successive errors (Rr) |
Simpson's rule True Error (En) |
Simpson's rule Ratio of successive errors (Rr) |
2 | -1.74053505146400 | 0.0051* E+04 | 0.72080057280000 | 0.0001* E+04 |
4 | -0.03439691882200 | 2.7480* E+04 | 0.53431579210000 | 0.0047* E+04 |
8 | -0.00000125170200 | 9.7455* E+04 | 0.01146397070000 | 2.7477* E+04 |
16 | -0.00000000001300 | 0.0001* E+04 | 0.00000041720000 | -3.2488* E+04 |
32 | -0.00000000001300 | 0.0001* E+04 | -0.00000000001300 | 0.0001* E+04 |
64 | -0.00000000001300 | 0.0001* E+04 | -0.00000000001300 | 0.0001* E+04 |
128 | -0.00000000001300 | 0.0001* E+04 | -0.00000000001300 | 0.0001* E+04 |
MATLAB Code:
%Code for Composite Trapezoidal rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors- 'Rr' %
clc;
clear;
syms x;
f=exp(cos(x));
g=diff(f);
F0=exp(cos(0));
F2pi=exp(cos(2*pi));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*((2*pi)/n(i)));
F(k)=exp(cos(X(k)));
G=sum(F);
end
In(i)=(((2*pi)/n(i))*(sum(F)-(0.5*(F0+F2pi))));
I(i)=7.954926521; %from Atkinson text pg.263%
En(i)=I(i)-In(i);
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
%Code for Composite Simpson's rule for n=2,4,8,...128 to evaluate Error values: 'Enr' and ratio of successive errors: 'Rr' %
clc;
clear;
syms x;
f=exp(cos(x));
g=diff(f,3);
F0=exp(cos(0));
F2pi=exp(cos(2*pi));
for i=1:1:9
n(i)=2^i;
for k=1:(n(i)+1)
X(k)=((k-1)*((2*pi)/n(i)));
F(k)=exp(cos(X(k)));
G=sum(F);
if (mod(k,2)==0)
O(k)=F(k);
E(k)=0;
else
O(k)=0;
E(k)=F(k);
end
end
In(i)=(((2*pi)/(3*n(i)))*((4*sum(O))+(2*sum(E))-(F0+F2pi)));
I(i)=7.954926521; %from Atkinson text pg.263%
En(i)=I(i)-In(i);
end
Inr=round(In*10000000000)/10000000000;
Enr=round(En*10000000000)/10000000000;
for i=1:1:8
R(i)=En(i).*(1/En(i+1));
end
Rr=round(R*10000)/10000;
Solution for problem 4: Srikanth Madala 05:22, 18 February 2010 (UTC)
Proofread problem 4:
Problem 5: Romberg Table
editProblem Statement
editPg. 19-2 (cont'd on Pg. 6-5)
a) Modify the code to make the computation of T(2^j) efficient;
b) Add Romber Table and compare with previous results.
Problem Solution
edita) Modified code
function [I1,I2,T1] = trapzoid(f,a,b,n) h=(b-a)/n; x=linspace(a,b,n+1); fx=feval(f,x); I1=h*(fx(1)/2+sum(fx(2:1:n))+fx(n+1)/2); n=2*n; h=(b-a)/n; x=linspace(a,b,n+1); fx=feval(f,x); I2=I1/2+h*sum(fx(2:2:n)); T1=(2^2*I2-I1)/(2^2-1);
%call function %I1=To(4),I2=To(8), and T1=T1(4) format long [I1,I2,T1]=trapzoid(@(x) (exp(x)-1)./x,eps,1,4)
b) Romberg Table
Convergence is achieved much faster than the composite trapezoidal rule.
Solution for problem 5:
Proofread problem 5:
Contributing Authors
editProblem 1 Solution --Patrick O'Donoughue 10:07, 17 February 2010 (UTC)
Problem 2 solution --Guillermo Varela 19:16, 17 February 2010 (UTC)
Problem 3 solution --Niki Nachappa 15:31, 17 February 2010 (UTC)
Problem 4 solution and proof-read problem 2 -- Srikanth Madala 05:22, 18 February 2010 (UTC)
Problem 5 solution -- PENGXIANG JIANG 19:00, 17 February 2010 (UTC)