blob: 9120eacfa771d1224a9c42b94d0a1c141ba384ce (
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
|
// example 7.11
// solve the boundary value problem u''=u'+1;
// u(0)=1; u(x=1)=2(%e-1); h=1/3;
// we know; u''=(u(j-1)-2*u(j)+u(j+1))/h^2;
// we know; u'=(u(j+1)-u(j-1))/2h;
// 1) second order method;
x=0:1/3:1;
u= rand(1,4);;
// hence;
disp('(u(j-1)-2*u(j)+u(j+1))/h^2=((u(j+1)-u(j-1))/2h)+1') // for j=1,2;
disp('for j=1 (7/6)*u0-2*u1+(5/6)*u2=(1/9)')
disp('for j=2 (7/6)*u1-2*u2+(5/6)*u3=(1/9)')
// hence eliminating u1!
// solving for u1,u2,
u0=1;
u3=2*(%e-1);
u1=1.454869;
u2=2.225019;
disp(x);
disp(u);
|