Monday, 7 November 2011

Integration by Gaussian Integration Method

%% Write a MATLAB program to integrate the equation f(x) = dx/(1+x) within

%% the limits of 0 to 1 with three points using Gaussian Integration Method.

% Given
a= 0;

b = 1;

n = 3;

%% writing x in terms of u ( x = a1*u + b1)with limits of -1 to 1a1 = (b-a)/2;

b1 = (b+a)/2;

dx = a1;

%a1=1; b1=0;

% Using the table for w and x values for n=3

u1 = -0.77460; u2 = 0.0; u3 = 0.77460;

w1 = 0.55555; w2 = 0.88889; w3 = 0.55555;

% fu1 = du/1+(u1)^2 where dx=a1*du

fu1 = a1/(1+(a1*u1+b1));

fu2 = a1/(1+(a1*u2+b1));

fu3 = a1/(1+(a1*u3+ b1));



I = w1*fu1+w2*fu2+w3*fu3;

fprintf (
' The integral by Gaussian integration method is = %2.5f \n',I);

No comments:

Post a Comment