Jump to content

University of Florida/Egm6341/s10.Team2/HW4

From Wikiversity

Problem 1: Development of higher order Corrected Trapezoidal rules and application

[edit | edit source]

Statement

[edit | edit source]

P. 20-1

Develop higher-order corrected trapezoidal rules for

Then use these new corrected trapezoidal rules to find:

until the error is of order of using


Solution

[edit | edit source]

Higher Order corrected trapezoidal rules are of the form:

where the a coefficient is defined as follows:

and

B are Bernoulli numbers. The first values for are:


These corrected trapezoidal rules define the integral as follows:


This means that higher order corrected trapezoidal rules can be developed as long as the function is continuous and its higher order derivatives can be calculated.


The first three corrected trapezoidal rules are found as follows:



Using matlab to calculate the integrals, yields the results as follows:


Integral Values using Corrected Trapezoidal Rules
n Ct1 Ct2 Ct3 Error Ct1 Error Ct2 Error Ct3
2 1.317875061148223 1.317908476816203 1.317908314863727 2.709080863771973e-005 6.324859342043965e-006 6.162906866391538e-006
4 1.317900452799411 1.317902541278660 1.317902538748152 1.699157449630562e-006 3.893217990214026e-007 3.867912916621918e-007

It can be noticed that the corrected trapezoidal rules yield a solution to the integral much faster than the uncorrected Composite Trapezoidal Rule.


Matlab Code Used for Problem

[edit | edit source]

MATLAB Code: Finding the Corrected Trapezoidal Rules

function [Ct1, Ct2, Ct3, Ect1, Ect2, Ect3] = cortrap (a,b,n)
tic
h=(b-a)/n;
x=linspace(a,b,n+1);

%declare the Function and its derivatives
F=(exp(x) - 1)./x;
F(1)=1;
F1=(exp(x)./x - (exp(x) - 1)./x.^2);
F1(1)=0.5;
F2=(exp(x)./x - (2*exp(x))./x.^2 + (2*(exp(x) - 1))./x.^3);
F2(1)=(1/3);
F3=(exp(x)./x - (3*exp(x))./x.^2 + (6*exp(x))./x.^3 - (6*(exp(x) - 1))./x.^4);
F3(1)=.25;
%singularity values were inserted


%calculating a1, a2, and a3 coefficients
r=n+1;  %finds out the last term of the array
a1=(-1/12)*(F1(r)-F1(1)); %Bernoulli number d1=-1/12
a2=(1/720)*(F2(r)-F2(1)); %Bernoulli number d2=1/720
a3=(-1/30240)*(F3(r)-F3(1)); %Bernoulli number d3=-1/30240

%Calculating Ct0 using composite trapezoidal rule
Ct0=ctrapz(n);
Ct1=Ct0 + (a1*(h^2));
Ct2=Ct1 + (a2*(h^4));
Ct3=Ct2 + (a3*(h^6));

I=quad(@valus,0,1)

Ect1=abs(I-Ct1);
Ect2=abs(I-Ct2);
Ect3=abs(I-Ct3);
toc


MATLAB Code: Calculating the Values of the function

function F= valus(x)
F=(exp(x)-1)./x;



MATLAB Code: Calculating the Composite Trapezoidal Rule

function I=ctrapz(n)
i=0;
Itot=0;
It=0;
It2=0;
h=0;
while i<=n
   if i==0
      Itot1=1;
   else if i<n
        h=1/n;
        It(i)=2*valus(h*i);
       else 
           It2=valus(1);
       end
   end
Itot=Itot1+sum(It)+It2;
i=i+1;
end

I=Itot/(2*n);



solved by--- Egm6341.s10.Team2.GV 21:56, 3 March 2010 (UTC)

checked by---Egm6341.s10.team2.patodon 20:53, 3 March 2010 (UTC)

Problem 2: Higher order error analysis of Trapezoidal rule for periodic functions

[edit | edit source]
For which n does

Statement

[edit | edit source]

To prove that the value of the trapezoidal rule error: for a periodic function and find the effect of (number of intervals or panels in trapezoidal rule) on the convergence of the function.

Solution

[edit | edit source]

Let be a periodic function in the interval

We know that for a periodic function with periodicity of

Differentiating w.r.t  :


similarly,


Therefore the coefficients of the expansion of i.e. becomes zero due the following reason:

We know that:

where


when periodicity of the function is

Therefore, in the case of periodic function with periodicity ,

Hence the error expressed as:

as

The same result is tested by using a Matlab program for trapezoidal rule and it proves to be true that the function converges rapidly for periodic functions using trapezoidal rule as the number of intervals 'n' increases and thus the error term tends to zero.

%As illustrated below in the Matlab code for a periodic function f=sin(x) between the periodicity (b-a)=(2*pi-0), the Error 'E'%
%tends to zero rapidly with the increase in the number of panels-'n'. In the below code the 'n' value varies from 1 through 10.% 

%Error of trapezoidal rule as even power of 'h'%
tic;
clc;
clear;
syms x;
f=sin(x);
a=0;
b=(2*pi);
d=[-1/12;1/720;-1/30240];
for n=1:10
    h=(b-a)/n;
    E1=0;
    for i=1:3
        A(i)=d(i).*(subs(diff(f,2i-1),x,b)-subs(diff(f,2i-1),x,a));
        E1=E1+A(i)*(h^(2*i));
    end
E(n)=E1;
end
toc;



solved by-----Srikanth Madala

checked by---Egm6341.s10.team2.patodon 20:55, 3 March 2010 (UTC)

Problem 3: Discussions of pros and cons of various quadrature methods

[edit | edit source]

Statement

[edit | edit source]

Discuss the pros and cons of the following quadrature methods:

  1. Taylor Series
  2. Composite Trapezoidal rule
  3. Composite Simpson's rule
  4. Romberg table (including Richardson's extrapolation)
  5. Corrected Trapezoidal rule

Solution

[edit | edit source]

Taylor Series:
Pros:

  1. Powerful tool that helps to approximate any type of simple or complex functions into a polynomial form with an error in the form of remainder


Cons:

  1. The function should be differentiable in the given limits 'a' and 'b' in which it is approximated as a polynomial.
  2. The product of two sub-functions in a given function like for example would make it more difficult and more costly (in terms of computation) to evaluate successive derivatives.



Composite Trapezoidal rule:
Pros:

  1. Very intuitive and easy to use
  2. The numerical integral results obtained for periodic functions like trigonometric functions (sinx, cosx, tanx etc) is very accurate owing to the fact that the error is dependent on the difference between the odd derivatives of the limiting points - 'a' and 'b'.
  3. It yields better accuracy than simple trapezoidal rule in calculating the numerical integral of a function.

Pros:

  1. Needs many subintervals to converge and the convergence rate is low for non-periodic functions.
  2. Runge Phenomena.



Composite Simpson's rule:
Pros:

  1. It is still intuitive and easy to use
  2. The convergence rate is OK
  3. Exact for cubic polynomials

Cons:

  1. This rule can be applied to only even number of finite intervals between the limits- 'a' and 'b'. So the value of 'n' in Simpson's rule is always an even number. i.e. n=2i; where (i=1,2,3...)
  2. Runge Phenomena



Romberg table (including Richardson's extrapolation):
Pros:

  1. The successive computation of is cheaper and faster when is already computed.
  2. The accuracy of the numerical integration results obtained are better than other methods. The higher the power of 'h' term in the trapezoidal error, the better the accuracy.



Cons:

  1. The success of Romberg integration is only justified if the integrand-'f' satisfies the hypotheses of the Euler–Maclaurin Theorem.For example, as illustrated in the An Introduction to Numerical Analysis by Suli and Mayers Text Pg.218 The function is not differentiable at , so the required conditions are not satisfied for any extrapolation.

solved by --- --Srikanth Madala

checked by --- --Egm6341.s10.Team2.GV 22:00, 3 March 2010 (UTC)

Problem 4: Transformation of variables in the error expression of HO trapezoidal rule

[edit | edit source]

Statement

[edit | edit source]

Given the expression

(1)


where and ,

Show that by transformation of variables we get

(2)


where

Solution

[edit | edit source]

Given the expression

(1)

we use the transformation to transform the interval from to by introducing .We get


substituting in (1) we get

taking out we get

(2)

solved by---Egm6341.s10.team2.niki 17:46, 27 February 2010 (UTC)

checked by--- --Srikanth Madala

Problem 5: Integration by parts

[edit | edit source]

Statement

[edit | edit source]

Show the following relation via integration by parts

Solution

[edit | edit source]

Integration by Parts

Rearrangement yields

solved by---Egm6341.s10.team2.lee 01:45, 2 March 2010 (UTC)

checked by---Egm6341.s10.team2.niki 05:23, 2 March 2010 (UTC)

checked by---Egm6341.s10.team2.patodon 20:48, 3 March 2010 (UTC)

Problem 6: Derivative of as it relates to the proof to the theorem of higher order trapezoidal rules

[edit | edit source]

Statement

[edit | edit source]

The following is defined:

where,

Proof the following:


Solution

[edit | edit source]

The first step is to state the chain rule for a composite function which is the case in this situation,


The first derivative is found as follows:





By this the first derivative is defined as:


Using the chain rule again to find the second derivative as follows:


Apply the chain rule once more to find the third derivative as follows:


One notices that the value of comes out of the derivative everytime it is applied.

One is able to then conclude a general expression for the derivative of the function as follows:


solved by---Egm6341.s10.Team2.GV 05:03, 27 February 2010 (UTC)

checked by---Egm6341.s10.team2.patodon 21:10, 3 March 2010 (UTC)

Problem 7: Verifying the Error for Higher Order Trapezoidal Rule

[edit | edit source]

Statement

[edit | edit source]

Show the following relation via integration by parts

Solution

[edit | edit source]

Integration by Parts

solved by---Egm6341.s10.team2.patodon 20:59, 3 March 2010 (UTC)

checked by---Egm6341.s10.team2.lee 02:15, 2 March 2010 (UTC)

Problem 8: Installation of chebfun program

[edit | edit source]

Statement

[edit | edit source]

Install Chebfun program (Tefethen et al. 2004)

Solution

[edit | edit source]

Status - Successful

solved by---

checked by---Egm6341.s10.team2.patodon 21:27, 3 March 2010 (UTC)

Problem 9: Comparison of codes

[edit | edit source]

Statement

[edit | edit source]

For the integral

  1. Optimise the code for Romberg table
  2. Compare second column of Romberg table with the results of Simpson's rule and derive any relationship.
  3. Compute to the order of and find the computational time using
  • Code for Composite Trapezoidal Rule
  • Code for Composite Simpson's Rule
  • Code for Romberg table
  • Chebfun "sum" command
  • Built-in MATLAB function "trapz"
  • Built-in MATLAB function "quad"
  • Built-in MATLAB function "clencurt"

Solution

[edit | edit source]

Exact value of the Integral from Mathematica is calculated by teh command "Integrate[((exp(x)-1)/x),+{x,+0,+1}]" the value is

1.3179021514544038948600088442492318379749012457927839928404611969976461077561394826119536468343922075 [[((exp(x)-1)/x),+{x,+0,+1}]]

Part1:Corrected code for Romberg table
[edit | edit source]

MATLAB Code: For Efficient Production of the Romberg Table

function [table] = Rombergg(a,b,n)
tic
table=zeros(6,6);

%Generate 1st column of Romberg Table using built in composite trapezoidal
%function.  Notice it calls the function 'Valus' which obtains the values
%for the function.  The function is also corrected at initial point 0
for j=1:6
    r=n;
    x=linspace(a,b,r+1);
    FX=valus(x);
    FX(1)=1;  %because of 0 start point
    table(j,1)=trapz(x,FX);
    n=2*r;
end

%Generate 2nd column of Romberg Table
for j=1:5
    table(j,2)= ([(2^2)*table(j+1,1)] - [table(j,1)])/(2^2 - 1);
end

%Generate 3rd column of Romberg Table
for j=1:4
    table(j,3) = ([(2^(2*2))*table(j+1,2)] - table(j,2))/(2^(2*2)-1);
end

%Generate 4th column of Romberg Table
for j=1:3
    table(j,4) = ([(2^(2*3))*table(j+1,3)] - table(j,3))/(2^(2*3)-1);
end

%Generate 5th Column of Romberg Table
for j=1:2
    table(j,5) = ([(2^(2*4))*table(j+1,4)] - table(j,4))/(2^(2*4)-1);
end

%Generate 6th column of Romberg Table
table(1,6) = ([(2^(2*5))*table(2,5)] - table(1,5))/(2^(2*5)-1);

toc



Part2:Comaprison of Simpson's rule and Romberg table
[edit | edit source]

The below table shows the values for the given integral computed using Composite Simpsons rule and the second column of the Romberg table for the same. By comparing the values of the Integral (or of the corresponding errors)) for any n, we see that the value from the composite Simpson's rule is the same as the value for n/2 (previous row) of .


Comparison of Integral Values

Number of Terms


Values from


Values from Romberg Table


Error


Error



2

1.3180086656766800

1.3179089166831400

1.06514E-04

6.76523E-06

4

1.3179089166831400

1.3179025760028100

6.76523E-06

4.24548E-07

8

1.3179025760028100

1.3179021780157100

4.24548E-07

2.65613E-08

16

1.3179021780157100

1.3179021531149100

2.65613E-08

1.66051E-09

32

1.3179021531149100

1.3179021515581900

1.66051E-09

1.03790E-10

64

1.3179021515581900

-

1.03790E-10

-


For e.g: Denoting Simpson's as we see that

etc. In general we can write



wkt


(1)

Part3:Codes
[edit | edit source]

Using Code for Composite trapezoidal rule

    I =1.31790215145440389486;        %Exact value of the integral
    n = 1;
    clc
    format long;
    tic                               %clock begins
    while(true)   
        In = ctrapz(n);               %calls ctrapz function which is the code used previously in the homework
        if(abs((I - In)) < (10^(-10)))%check for error   
        break;
        end
        n = 2*n;
        end
    toc%clock stops
    output = In
    number = n                        %number of terms used



Gives n= 32768 ,In =1.31790215149321 and time 4.973 sec

Using Code for Composite Simpson's Rule

   I = 1.31790215145;                 %Exact value of the integral
   n = 1;
   clc
   format long;
   tic%time starts
   while(true)  
      In = simpb(0,1,n);              %calls function simpb which is the code developed 
      if(abs((I - In)) < (10^(-10)))  %check for order of error  
      break;
      end
      n = 2*n;
   end
   toc%clock stops
   output = In                        % integral value calculated
   number = n                         %gives number of terms



Gives n= 128 ,In= 1.31790215146089 and time=0.017sec

Using code for Romberg table

function [table] = Rombergg(a,b,n)
tic
table=zeros(6,6);

%Generate 1st column of Romberg Table using built in composite trapezoidal
%function.  Notice it calls the function 'Valus' which obtains the values
%for the function.  The function is also corrected at initial point 0
for j=1:6
    r=n;
    x=linspace(a,b,r+1);
    FX=valus(x);
    FX(1)=1;  %because of 0 start point
    table(j,1)=trapz(x,FX);
    n=2*r;
end

%Generate 2nd column of Romberg Table
for j=1:5
    table(j,2)= ([(2^2)*table(j+1,1)] - [table(j,1)])/(2^2 - 1);
end

%Generate 3rd column of Romberg Table
for j=1:4
    table(j,3) = ([(2^(2*2))*table(j+1,2)] - table(j,2))/(2^(2*2)-1);
end

%Generate 4th column of Romberg Table
for j=1:3
    table(j,4) = ([(2^(2*3))*table(j+1,3)] - table(j,3))/(2^(2*3)-1);
end

%Generate 5th Column of Romberg Table
for j=1:2
    table(j,5) = ([(2^(2*4))*table(j+1,4)] - table(j,4))/(2^(2*4)-1);
end

%Generate 6th column of Romberg Table
table(1,6) = ([(2^(2*5))*table(2,5)] - table(1,5))/(2^(2*5)-1);

toc



Gives time =0.04sec


Using chebfun - sum:

  tic
  y = chebfun('(exp(x)-1)./x',[eps 1]); 
  I=sum(y)
  toc

I = 1.317902151454404 and time = 0.009175 sec.


Using Trapz function:

    I = 1.31790215145;               %Exact value of integral
    n = 1;
    tic                              %clock begins
    while(true)
    
        X = 0:1/n:1;                 %divides x into n equal parts
        Y = (exp(X) - 1) ./ X;       %given function
        Y(1) = 1;                    %corrects for the singulairty at x=0
        In = trapz(X,Y);             %calls teh built-in function trapz
          if(abs((I - In)) < (10^(-10))) %check order of error   
          break;
          end
          n = 2*n;
    end
    toc                             %clock ends
    output = In
    number = n



n=32768 ,In=1.31790215149321 and time = 0.006879 sec

Using Quad function

   I =1.3179021514544038948600088;  %Exact value of integral
   n = 2;
   clc
   format long;
   tic                              %clock begins
      while(true)
       X = 0:1/n:1;                 %divides the interval into n equal parts
       F=@(X)(exp(X)-1)./X;         %given function as an anonymous function
       In=quad(F,0,1,1.e-10);       %calls the built-in quad function
    
       if(abs((I - In)) < ((10)^(10)))  %check for error 
       break;
       end
       n = n+1;
   end
   toc
   output = In
   number = n



Gives n=2 ,In= 1.31790215145441 and time = 0.004 sec


Using clencurt function

  tic
  [x,w] = clencurt(2^5);
  xx=(1+eps)/2+x.*(1-eps)/2;
  ww=w.*(1-eps)/2;
  yy=(exp(xx)-1)./xx;
  II=ww*yy
  toc

Gives II=1.317902151454404 and time = 0.000308 sec

Part3:Computational times
[edit | edit source]
Computational Times

Composite Trapezoidal

32768

4.93

Composite Simpsons

128

0.017

Romberg Table

32

0.04

Chebfun-sum

NA

0.009175

Trapz

32768

0.006879

Quad

2

0.004

Clencurt

16

0.000308


solved by---Egm6341.s10.team2.niki 18:20, 28 February 2010 (UTC)

checked by---Egm6341.s10.team2.lee 22:20, 2 March 2010 (UTC)

Problem 10: Another comparison of codes

[edit | edit source]

Statement

[edit | edit source]

Repeat Problem 9 for integral

Solution

[edit | edit source]

The exact value of the definite integral is atan(5)-atan(-5)=2.746801533890034...

own code - composite trapezoidal rule
[edit | edit source]

Function Definition

 function I = trapzoid(f,a,b,n)
 h=(b-a)/n;
 x=linspace(a,b,n+1);
 fx=feval(f,x);
 I=h*(fx(1)/2+sum(fx(2:1:n))+fx(n+1)/2);
 

Call Function

 clear;clc
 format long
 f = @(x) 1./(1+x.^2);
 tic
 I = trapzoid(f,-5,5,2^14)
 toc
 e = atan(5)-atan(-5)-I

Result

 I = 2.746801532971545
 Elapsed time is 0.001745 seconds.
 e = 9.184866200939723e-010
own code - composite simpson's rule
[edit | edit source]

Function Definition

 function In = simpson(f,a,b,n)
 % n must be a positive even integer
 h=(b-a)/n; %step size
 x=linspace(a,b,n+1); %(n+1) equally spaced points
 fx=feval(f,x); %function evaluations
 %Composite Simpson
 In=(h/3)*(fx(1)+4*sum(fx(2:2:n))+2*sum(fx(3:2:n-1))+fx(n+1));

Call Function

 clear;clc
 format long
 f = @(x) 1./(1+x.^2);
 tic
 I = simpson(f,-5,5,2^8)
 toc
 e = atan(5)-atan(-5)-I

Result

 I = 2.746801533727021
 Elapsed time is 0.000343 seconds.
 e = 1.630109380812428e-010
Romberg quadrature rule
[edit | edit source]

Function Definition

 function I_romb = rombquad(f,a,b,m)
 h = 2.^((1:m)-1)*(b-a)/2^(m-1);             % intervals used.
 k1 = 2.^((m-2):-1:-1)*2+1;                  % Index into intervals.
 f1 = feval(f,a:h(1):b);                     % Function evaluations.
 R = zeros(1,m);                             % Pre-allocation.
 % Define the starting vector:
 for ii = 1:m
    R(ii) = 0.5*h(ii)*(f1(1)+2*sum(f1(k1(end-ii+1):k1(end-ii+1)-1:end-1)) + f1(end)); 
 end
 % Interpolations:
 for jj = 2:m
    jpower = (4^(jj-1)-1);
   for kk = 1:(m-jj+1)
       R(kk) = R(kk)+(R(kk)-R(kk+1))/jpower;
   end 
 end
 I_romb = R(1);

Call Function

 clear;clc
 format long
 y = @(x) 1./(1+x.^2);
 tic
 I_romb=rombquad(y,-5,5,9)
 toc
 e=atan(5)-atan(-5)-I_romb

Result

 I_romb = 2.746801534346014
 Elapsed time is 0.000356 seconds.
 e = -4.559819188898473e-010
matlab - trapz and quad
[edit | edit source]

Call Function

 clear;clc
 format long
 x=linspace(-5,5,2^14+1);
 y = 1./(1+x.^2);
 I_exact=atan(5)-atan(-5)
 tic;I_ct=trapz(x,y);toc
 I_ct
 e_ct=I_exact-I_ct
 tic;I_cs=quad(@(x) 1./(1+x.^2),-5,5,1e-8);toc
 I_cs
 e_cs=I_exact-I_cs

Result

 I_exact = 2.746801533890032
 Elapsed time is 0.003191 seconds.
 I_ct = 2.746801532971568
 e_ct = 9.184639715442700e-010
 Elapsed time is 0.009436 seconds.
 I_cs = 2.746801534322983
 e_cs = -4.329510083778132e-010


matlab - clencurt
[edit | edit source]

Call Function

 tic
 [xx,ww] = clencurt(2^10);
 xx=xx.*5;
 ww=ww.*5;
 yy=1./(1+xx.^2);
 II=ww*yy
 toc  

Result

 II = 2.746801533890032
 Elapsed time is 0.089293 seconds.
"sum" command of chebfun matlab toolbox
[edit | edit source]

Call Function

 x = chebfun('x',[-5 5]); 
 tic
 I=sum(1./(1+x.^2))
 toc
 e=abs(atan(5)-atan(-5)-I)

Result

 I = 2.746801533890033
 Elapsed time is 0.042520 seconds.
 e = 1.332267629550188e-015


solved by---Egm6341.s10.team2.lee 22:22, 2 March 2010 (UTC)

checked by-----Egm6341.s10.team2.niki 20:45, 6 March 2010 (UTC)

Problem 11: Finding The Arc Length of an Ellipse using Numerical Integration

[edit | edit source]

Statement

[edit | edit source]

Find the Arc Length of the ellipse where:

and

Using:

1)Composite Trapezoidal Rule

2)Composite Simpson's Rule

3)Romberg Table

4)"Sum" Command of the chebfun toolbox

5)"Trapz" Command of Matlab

6)"Quad" Command of Matlab

7)"Clencurt" Command of Matlab

Until the error is less than


Solution

[edit | edit source]
Composite Trapezoidal Rule
[edit | edit source]
Composite Trapezoidal Rule
n Value Error
2 6.283185307 2.E-01
4 6.072738504 4.E-03
8 6.069092055 1.E-06
16 6.06909096 8.E-08



function [I,E]=compostrap(a,b,n)

h=(b-a)/n;
pi2=2*pi();
i=0;
Itot=0;
It=0;
It2=0;

while i<=n
    if i==0
        Itot1=(1/2)*elrad(a);
    else if i<n
            u=h*i;
            It(i)= elrad(u);
        else
            It2=(1/2)*elrad(b);
        end
    end
Itot=Itot1+sum(It)+It2;
i=i+1;
end

I=Itot*(h);

%Error Calculation
Ir=quad(@elrad,0,pi2);

E=Ir-I;



Composite Simpson's Rule
[edit | edit source]
Composite Simpson's Rule
n Value Error
2 5.470081296 6.E-01


4 5.867072234 2.E-01
8 6.000117905 7.E-02
16 5.870432233 2.E-01
32 5.969761779 1.E-01
64 6.101815883 3.E-02
128 6.085453421 2.E-02
256 6.07727219 8.E-03
512 6.062882886 6.E-03
1024 6.071136267 2.E-03
2048 6.067538941 2.E-03
4096 6.06831495 8.E-04
8192 6.069346623 3.E-04
16384 6.068896957 2.E-04
32768 6.069154875 6.E-05
65536 6.069122917 3.E-05
131072 6.069106939 2.E-05
262144 6.069098949 8.E-06
524288 6.069084897 6.E-06
1048576 6.069092957 2.E-06
2097152 6.069091958 1.E-06


MATLAB Code:

function I = msimpb(a,b,w)

q=1;
i=a;
n=0;
Sum=0;
c=0;

e=sin(pi()/12);

while n<w
    n=2^q;
    h=(a+b)/n;
while i<=b
    fx= (1-e^2)/(1-e*cos(i)); %(exp(i)-1)/(i);  Declare Function Here
    if i==a
        Sum=1;
    else if i==b
            Sum=Sum+fx;
        else if i==(b-h)
                Sum=Sum+(4*fx);
            else if rem(c,2)==0
                    Sum=Sum+(2*fx);
                else
                    Sum=Sum+(4*fx);
                end
            end
        end
    end
    c=c+1;
    i=i+h;
end
n;
In=Sum*(h/3);
I=In;
i=a;
c=0;
q=q+1;
Sum=0;
end



Romberg Table
[edit | edit source]

Romberg Table for n=2

   6.2832    6.0026    6.0722    6.0691    6.0691    6.0691
   6.0727    6.0679    6.0692    6.0691    6.0691         0
   6.0691    6.0691    6.0691    6.0691         0         0
   6.0691    6.0691    6.0691         0         0         0
   6.0691    6.0691         0         0         0         0
   6.0691         0         0         0         0         0


Table for Error of Romberg Table

  -0.2141    0.0665   -0.0031   -0.0000    0.0000   -0.0000
  -0.0036    0.0012   -0.0001    0.0000   -0.0000         0
  -0.0000    0.0000   -0.0000   -0.0000         0         0
  -0.0000   -0.0000   -0.0000         0         0         0
  -0.0000   -0.0000         0         0         0         0
  -0.0000         0         0         0         0         0

Romberg Table for n=4

   6.0727    6.0679    6.0692    6.0691    6.0691    6.0691
   6.0691    6.0691    6.0691    6.0691    6.0691         0
   6.0691    6.0691    6.0691    6.0691         0         0
   6.0691    6.0691    6.0691         0         0         0
   6.0691    6.0691         0         0         0         0
   6.0691         0         0         0         0         0


Error for Romberg Table n=4

  -0.0036    0.0012   -0.0001    0.0000   -0.0000   -0.0000
  -0.0000    0.0000   -0.0000   -0.0000   -0.0000         0
  -0.0000   -0.0000   -0.0000   -0.0000         0         0
  -0.0000   -0.0000   -0.0000         0         0         0
  -0.0000   -0.0000         0         0         0         0
  -0.0000         0         0         0         0         0


Romberg Table for n=8

   6.0691    6.0691    6.0691    6.0691    6.0691    6.0691
   6.0691    6.0691    6.0691    6.0691    6.0691         0
   6.0691    6.0691    6.0691    6.0691         0         0
   6.0691    6.0691    6.0691         0         0         0
   6.0691    6.0691         0         0         0         0
   6.0691         0         0         0         0         0


Table for Error when n=8

 1.0e-005 *
  -0.1180    0.0281   -0.0109   -0.0084   -0.0085   -0.0085
  -0.0085   -0.0085   -0.0085   -0.0085   -0.0085         0
  -0.0085   -0.0085   -0.0085   -0.0085         0         0
  -0.0085   -0.0085   -0.0085         0         0         0
  -0.0085   -0.0085         0         0         0         0
  -0.0085         0         0         0         0         0


"Sum" Command of Chebfun Matlab Toolbox
[edit | edit source]




>> chebfun('elrad(x)', [0 pi2])
ans = 
   chebfun column (1 smooth piece)
       interval          length    endpoint values   
(        0,      6.3)       43        1.3       1.3   
vertical scale = 1.3 
 
>> sum(F1)

ans =

   6.069090959564776

>> I=quad(@elrad,0,pi2)

I =

   6.069090874992289

>> Error=I-ans

Error =

   -8.457248767967940e-008



"Trapz" Command of Matlab
[edit | edit source]
Trapz Matlab Command


n-value

Numerical Integral (In)

Error (En)

2 6.283185307 2.E-01
4 6.072738504 4.E-03
8 6.069092055 1.E-06
"Quad" Command of Matlab
[edit | edit source]

The value found using the "Quad" Matlab Command was:



with an error smaller than



solved by--- --Egm6341.s10.Team2.GV 22:04, 3 March 2010 (UTC)

checked by---Egm6341.s10.team2.patodon 21:15, 3 March 2010 (UTC)

Contributing Authors and Assignments

[edit | edit source]

Signatures

[edit | edit source]

solved problems 4 and 9, proofread problems 5 and 10:--Egm6341.s10.team2.niki 18:22, 28 February 2010 (UTC)

solved problems 5 and 10, proofread problems 7 and 9:--Egm6341.s10.team2.lee 22:26, 2 March 2010 (UTC)

solved problems 7, proofread problems 1, 2, 5, 6, 8 and 11 Egm6341.s10.team2.patodon 23:01, 2 March 2010 (UTC)

solved problems 1, 6 and 11. Proofread 3, 9. --Egm6341.s10.Team2.GV 22:06, 3 March 2010 (UTC)

solved problems 3 and 8. Proofread 4, 9--Srikanth Madala

Solution Assignments and Reviewers

[edit | edit source]
Problem Assignments
Problem # Solution Reviewed
Problem 1 GV PO
Problem 2 PO JP
Problem 3 SM GV
Problem 4 NN SM
Problem 5 JP NN
Problem 6 GV PO
Problem 7 PO JP
Problem 8 SM GV
Problem 9 NN,GV SM
Problem 10 JP NN
Problem 11 GV PO