summaryrefslogtreecommitdiff
path: root/50/CH5/EX5.26/ex_5_26.sce
blob: 402f55cb02c5feb7301c1303933191ea9da10e97 (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
// Example 5.26
// caption: 1) composite trapizoidal rule, 2) composite simpsons rule with 2,4 ,8 equal sub-intervals,

// I=integral 1/(1+x) in the range [0,1]

deff('[y]=f(x)','y=1/(1+x)')

// when N=2; 
// 1)composite trapizoidal rule
h=1/2;
x=0:h:1;

 IT=comptrapezoidal(x,h,f)
 
 // 2)composite simpsons rule
 
  [I] = simpson13(x,h,f)
  
  
  // when N=4
 // 1)composite trapizoidal rule
h=1/4;
x=0:h:1;

 IT=comptrapezoidal(x,h,f)
 
 // 2)composite simpsons rule
 
  [I] = simpson13(x,h,f)
  
  
  
    // when N=8
 // 1)composite trapizoidal rule
h=1/8;
x=0:h:1;

 IT=comptrapezoidal(x,h,f)
 
 // 2)composite simpsons rule

  [I] = simpson13(x,h,f)