summaryrefslogtreecommitdiff
path: root/3588/CH6/EX6.10/EX6_10.sce
blob: 505d3ca6b094e29fe2c32d5ad6be8a8af8f2a326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//Clearing console
clc
clear

//Intializing variables
r1 = 0
r(1) = sqrt(3)/3
r(2) = -sqrt(3)/3

t(1) = 0
t(2) = 0.7745967
t(3)= -0.7745967

W11 = 2
Wt(1)= 0.8888889
Wt(2) = 0.5555556
Wt(3) = 0.5555556

f(1) = 0.339981043583856
f(2) = -0.339981043583856
f(3) = 0.861136311590453
f(4) = -0.861136311590453

Wf(1) = 0.652145154862526
Wf(2) = 0.652145154862526
Wf(3) = 0.347854845137454
Wf(4) = 0.347854845137454

//Gaussian quadrature Integration one point
I1 = -2*(1/3)

//Not considering weight factors for cubic and quadratic functions as they are 1
//Gaussian quadrature Integration two points
I2 = 0
for i =1:2
    I2 = I2 + (r(i)^2 -1)/((r(i)+3)^2)
end

//Gaussian quadrature Integration three points
I3 = 0
for i =1:3
    I3 = I3 + Wt(i)*(t(i)^2 -1)/((t(i)+3)^2)
end

//Gaussian quadrature Integration three points
I4 = 0
for i =1:4
    I4 = I4 + Wf(i)*(f(i)^2 -1)/((f(i)+3)^2)
end

printf('\nResults')
printf('Integration of given function')
printf('\n One Point Integration I1 =%f',I1)
printf('\n Two Point Integration I2 =%f',I2) 
printf('\n Three Point Integration I3 =%f',I3) 
printf('\n Four Point Integration I4 =%f',I4)