You are on page 1of 1

0001 //End Sem Exam

0002 //NAME: PUSHPENDRA YADAV (025)


0003 //APP NO : 210810015913
0004
0005 //QUESTION-2(a) GAUSS LEGENDRE
INTEGRATION
0006
0007 clc;
0008 clear;
0009
0010 n=6 //number of points"
0011
0012 //Values of u and weight factors
0013
u(1)=0.23861919; u(2)=-u(1); u(3)=0.66120939; u(4)=-u(3); u(5)=0.93246951;u(
0014
w(1)=0.46791393; w(2)=w(1); w(3)=0.36076157; w(4)=w(3); w(5)=0.17132449; w(6
0015
0016 //Defining given function for INTEGRATION
0001 function y=f(x)
0002 y=1/(1+x*x)
0003 endfunction
0020
0021 //Limits of integration
0022 a=0 //lower limit
0023 b=1 //Upper limit
0024
0025 //Implementing GAUSS LEGENDRE formula
0026 Sum=0
0027 for i=1:1:n
0028 x=((b-a)*(u(i))/2) + ((a+b)/2)
0029 Sum = Sum + (w(i))*(f(x))
0030 end
0031 I= (b-a)*Sum/2
0032 disp("value of integration is =",I)

You might also like