Question

Check the file: Questions.pdf

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;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Numerical Analysis Questions
Homework Solution
$8.00
Numerical Analysis
Functions
Polynomials
Proofs
Theorems
Functions
Points
Symmetry
Constants
Statements
Sums
Numerical Analysis Using Matlab
Homework Solution
$85.00
Advanced Mathematics
Numerical Analysis
Matlab
Endpoint Conditions
Cubic Spline
Natural Boundary Conditions
Tables
Scripts
Interpolation
Points
Polynomials
Numerical Orders
Errors
Methods
Compressed Sensing
Homework Solution
$200.00
Compressed Sensing
Numerical Analysis
Mathematics
Image Models
Equations
Reconstruction Theorems
Minimization
Signal Recovery
Isometry
Linear Systems
Sparse Sampling
Pixels
Inner Products
Translation Vectors
Voxels
Algorithms
Numerical Analysis Using Matlab
Homework Solution
$35.00
Mathematics
Numerical Analysis
Taylor Series
Matlab
Graphs
Roundoff Error
Tables
Labels
Range
Script
Codes
Plotting
Trigonometry
Variables
Expressions
Single Precision
Sampling
Absolute Values
Mathematics Questions
Homework Solution
$90.00
Mathematics
Single Precision Standard
Double Precision Standard
Matrices
Equations
Matlab
Signs
Convergence
Iterations
Comparison
Errors
Curves
Jacobi
Gauss Seidel
Eigenvectors
Get help from a qualified tutor
Live Chats