 # Numerical Integration Using Matlab

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

2. function [R]=Romberg(f,a,b,n)
%ROMBERG - Romberg integration
% -Input:
%       f       -   function name or function handle
%       a,b    -   integration interval [a,b]
%       n       -   size of the romberg table
% -Output:
%       R       -   an nxn matrix of numerical integrals
%                   R(i,j): h=(b-a)/2^(i-1), order=2*j
%

%% Calculate Romberg integration
R=zeros(n,n);
h=b-a;
R(1,1)=h/2*(feval(f,a)+feval(f,b));
for i=2:n
m=2^(i-2);
h=(b-a)/m;
s=sum(feval(f,a+([1:m]-0.5)*h));%summation at new points
R(i,1)=0.5*(R(i-1,1)+h*s);      %composite trapezoidal rule
for j=2:i
R(i,j)=R(i,j-1)+(R(i,j-1)-R(i-1,j-1))/(4^(j-1)-1); % extrapolation
end
end
%% Output R
for i=1:n
for j=1:i
fprintf(1,'R(%1d,%1d)=%11.4e ',i,j,R(i,j));
end
fprintf(1,'\n');
end
return;...
\$98.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Numerical Analysis Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.