Romberg Numerical Integration - Matlab Script
Romberg numerical integration uses trapenzoidal intergration to increase the accuracy of calculating an area. It builds up a matrix using the trapenzoidal rule then extends to calculate a more accurate answer.
Romberg numerical integration uses trapenzoidal intergration to increase the accuracy of calculating an area. It builds up a matrix using the trapenzoidal rule then extends to calculate a more accurate answer.
The script i have made for the Trapezoidal Rule is at the following link. The script for romberg integration has the trpezoidal script in built when calculating the first column.
>>> Trapezoidal Rule of Numerical Integration - Matlab Scripts
The first column is calculated using the trapenzoidal rule for integration where the number of areas the function is broken up into increases by 2 each time:
Row 1: n = 1, Row 2: n = 2, Row 3: n = 4, Row 4: n = 8...16...32...
As for the other columns, they are calculated by using the values of the column to the left.
R(i,j) = ((4^j)-R(i,j-1) - R(i-1,j-1))/((4^j)-1)
R(1,1) = (4*R(1,0) - R(0,0))/(4-1)
= (4(0.898904) - 0.888511)/3
= 0.902368
>> romberg('sin(x)/x',1,3,4)
matrix =
0.888510987494519 0 0 0
0.898904207160100 0.902368613715294 0 0
0.901644861268860 0.902558412638446 0.902571065899989 0
0.902337806742469 0.902568788567005 0.902569480295576 0.902569455127252
ans =
0.902569455127252
Continueing down, the most accurate answer is the bottom right one.
Romberg Numerical Integration - Matlab Script
function I = romberg(f_str,a,b,n)
%ROMBERG Romberg Rule integration.
% I = ROMBERG(F_STR, A, B, N) returns the Romberg Integration approximation
% for the integral of f(x) from x=A to x=B, to n layers, where
% F_STR is the string representation of f. Also displays the matrix used to
% calculate the inegral.
matrix = zeros(n);
g = inline(f_str);
if (rem(n,1) == 0)
for ii = 1:n
h = (b-a)/(2^(ii-1));
matrix(ii,1) = matrix(ii,1) + g(a);
for kk = (a+h):h:(b-h)
matrix(ii,1) = matrix(ii,1) + 2*g(kk);
end
matrix(ii,1) = matrix(ii,1) + g(b);
matrix(ii,1) = matrix(ii,1)*h/2;
end
for jj = 2:n
for ii = jj:n
matrix(ii,jj) = ((4^(jj-1))*matrix(ii,jj-1)-matrix(ii-1,jj-1))/((4^(jj-1))-1);
end
end
else
disp('Number of Layers required to be an Integer')
end
matrix = matrix
I = matrix(n,n);
Other Matlab Scripts I have created include:
>>> Simpson's Rule and Trapezoidal Rule of Numerical Integration - Matlab Scripts
>>> Lagrange Method and Newton Divided Difference Method - Matlab Scripts
>>> Newtons Method of finding Roots - Matlab Script
-
Romberg Numerical Integration - Matlab Script
| By djmcv90 | in College and University
Romberg integration uses trapenzoidal intergration to increase the accuracy of calculating an area...
-
Romberg Numerical Integration - Matlab Script
| By djmcv90 | in College and University
Trapezoidal Rule for numerical integration is built upon the trapezoidal and simpsons rule on integration to calcul...
-
What is Chronic Fatigue Syndrome? Part 1
| By Carlitos | in Alternative Medicine
There is a summary of the condition known as Chronic Fatigue Syndrome or ME. There are 3 parts of this article....
-
Secant Method - Matlab Script
| By djmcv90 | in College and University
These are some of my university matlab assignments....
-
What are the down sides of online universities? | By MaxwellPayne | in College and University
Online universities promise access to education any time from any where. But are they worth the money?...
-
Health plans for American college students | By MaxwellPayne | in College and University
How to get health insurance as a college student in the United States....
-
How to complete your FAFSA on the internet | By MaxwellPayne | in College and University
You need to fill out a FAFSA yearly for financial aid for college, why not do it online?...
-
Difference between C and C++ | By ausaus | in College and University
What are different types of polymorphism supported by C++ CA 2 What is Pure Virtual Function? Why and when it is u...
-
How to avoid fees while applying for grants | By MaxwellPayne | in College and University
Never pay fees when applying for certain grants....
-
Simpson's Rule and Trapezoidal Rule of Numerical Integration - Matlab Scripts | By djmcv90 | in College and University
Simpson's Rule and Trapezoidal Rule of Numerical Integration calculates the area under a function by breaking the f...
-
Save money with computers - Build your own (Part 3) | By djmcv90 | in Computers
part 3 of how to build a computer and save money doing it...
-
How to Build your Own Computer Cheap - Save Money | By djmcv90 | in Computers
some tips and ways to build a computer...
-
Increased Obesity Leads to Worlds Largest Joke - Mind the Pun | By djmcv90 | in Humor and Comedy
Fat people are everywhere overconsuming and not letting any starving africans get any food, so to solve the problem...
-
Romberg Numerical Integration - Matlab Script | By djmcv90 | in College and University
Trapezoidal Rule for numerical integration is built upon the trapezoidal and simpsons rule on integration to calcul...








No comments yet.