summaryrefslogtreecommitdiff
path: root/50/CH7/EX7.5/ex_7_5.sce
blob: 8d6eed3f7ddfa52d9dfce569e1b5825535c4ffca (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
// example 7.5
// solve the boundary value problem      u''=u+x;
// u(x=0)=u(0)=0;   u(x=1)=u(4)=0;          h=1/4;


// we know;     u''=(u(j-1)-2*u(j)+u(j+1))/h^2;

// 1) second order method;
 x=0:1/4:1;                                  
 u0=0;
 u4=0;
 u=[u0 u1 u2 u3 u4];
// hence;
disp('(u(j-1)-2*u(j)+u(j+1))/h^2=u(j)+x(j)')           // for j=1,2,3;

disp('for j=1            -16*u0+33*u1-16*u2=-.25')

disp('for j=2            -16*u1+33*u2-16*u3=-.50')

disp('for j=3            -16*u2+33*u3-16*u4=-.75')

// hence solving for u1,u2,u3)   , 
u1=-.034885;
u2=-.056326;
u3=-.050037;

disp(x);
disp(u);

// 2) numerov method;
 x=0:1/4:1;                                  
 u0=0;
 u4=0;
 u=[u0 u1 u2 u3 u4];
// since according to numerov method we get the following system of equations;
disp('(191*u(j-1)-394*u(j)+191*u(j+1)=x(j-1)+10*x(j)+x(j+1)')           // for j=1,2,3;

disp('for j=1            191*u0-394*u1+191*u2=3')

disp('for j=2            191*u1-394*u2+191*u3=6')

disp('for j=3            191*u2-394*u3+191*u4=9')

// hence solving for u1,u2,u3   , 
u1=-.034885
u2=-.056326
u3=-.050037


disp(x);
disp(u);