You are on page 1of 2

Quiz 1 – Numerical Integration

Given is the equation x2 – 2x – 1. You are kindly requested

a. To compute integral between x = 1 and x = 3 according to Gauss Quadratur


formula using 3 points !
b. To compare the result with the analytical solution !
c. To build the MatLab Script !
d. To solve using the MatLab toolbox !

Answer :

a. Gauss Quadratur 3-21 (using 3 Point)

Integran 1
zi wi (zi(b-a)+b+a)/2 F(zi) wi x F(zi) Volume

a= 1 0.000000000000000 0.888888888888889 2.000 -1.000 -0.89


b= 3 n=2 0.774596669241483 0.555555555555556 2.775 1.149 0.64
-0.774596669241483 0.555555555555556 1.225 -1.949 -1.08
-1.333 -1.333

b. Analytical Solution
Equation x2 – 2x – 1
3
𝐼 = ∫ (𝑥^2 – 2𝑥 – 1)𝑑𝑥
1
𝐼 = [1/3𝑥^2 – 𝑥^2 – 𝑥]13
1
𝐼 = [9 − 9 − 1] − [( ) − 1 − 1]
3
4
𝐼=
3
I=1,333

c. Build Matlab Script


>> z=[0.774596669241483,0,-0.774596669241483];
>> w=[0.555555555555556,0.8888888888888889,0.5555555555555556];
>> a=1;
>> b=3;
>> c=(b-a)*w/2;
>> xi=(b-a)/2*z+(b+a)/2;
>> f=(xi.^2)-(2*xi)-1;
>> Gauss_quadrature=sum(c.*f)

Gauss_quadrature =

-1.3333

d. Solve Using Matlab Toolbox