Romberg Numerical Integration - Matlab Script
Trapezoidal Rule for numerical integration is built upon the trapezoidal and simpsons rule on integration to calculate a more approximate area.
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...
-
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...
-
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...
-
Romberg Numerical Integration - Matlab Script
| By djmcv90 | in College and University
Romberg numerical integration uses trapenzoidal intergration to increase the accuracy of calculating an area. It bu...
-
What is Plagiarism? | By faris_jayz | in College and University
Plagiarism is when writers intentionally or unintentionally present another person's words, ideas, or work as their...
-
Planning your College Courses | By koopalo | in College and University
Knowing what college courses you're going to take ahead of time saves you a lot of time, stress, and sometimes even...
-
How to Choose a College Major | By koopalo | in College and University
Do you feel pressured to choose a college major and don't know how to decide? Deciding on the right one for you can...
-
Exaggerated Claims of Executive Privilege; Archibald Cox – A Man of Uncompromising Integrity | By marie.thomas | in College and University
Just one day after President Nixon refused to comply with a federal appeals court order to surrender the hostage â€...
-
Guide to buying your textbooks cheap. | By luvikavi | in College and University
Buying textbooks for college courses is probably one of the most daunting aspects of our college career. Read this ...
-
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...
-
Romberg Numerical Integration - Matlab Script | By djmcv90 | in College and University
Romberg numerical integration uses trapenzoidal intergration to increase the accuracy of calculating an area. It bu...
-
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...








No comments yet.