➔ Q1
➔ a:matrix([3,2,0],[2,3,−1],[0,−1,2]);
3 2 0
a 2 3 −1
0 −1 2
➔ b:matrix([4.5],[5],[−0.5]);
4.5
b 5
− 0.5
➔ x:matrix([0],[0],[0]);
0
x 0
➔ GAUSS SIEDEL METHOD
➔ dim:3;
dim 3
➔ for itr:1 thru 3 do(
for i:1 thru dim do(
x[i]:float(1/a[i,i]·(b[i]−(sum(a[i,j]·x[j],j,1,i−1)+sum(a[i,j]·x[j],j,i+1,dim)))))
,
print("the iteration ends"),
for i:1 thru dim do(print("the updated values are",x[i]))
);
the iteration ends
the updated values are [ 1.5 ]
the updated values are [ 0.6666666666666666 ]
the updated values are [ 0.08333333333333331 ]
the iteration ends
the updated values are [ 1.0555555555555556 ]
the updated values are [ 0.9907407407407407 ]
the updated values are [ 0.24537037037037035 ]
the iteration ends
the updated values are [ 0.8395061728395061 ]
the updated values are [ 1.1887860082304527 ]
the updated values are [ 0.34439300411522633 ]
(%o6) done
➔ GAUSS JACOBI METHOD
➔ dim:3;
for itr:1 thru 3 do(
for i:1 thru dim do(
y[i]:float(1/a[i,i]·(b[i]−(sum(a[i,j]·x[j],j,1,i−1)+sum(a[i,j]·x[j],j,i+1,dim)))))
,
for i:1 thru dim do (x[i]:y[i]),
print("the iteration ends"),
for i:1 thru dim do(print("the updated values are",x[i]))
);
dim 3
the iteration ends
the updated values are [ 0.7074759945130316 ]
the updated values are [ 1.2217935528120711 ]
the updated values are [ 0.34439300411522633 ]
the iteration ends
the updated values are [ 0.6854709647919526 ]
the updated values are [ 1.3098136716963877 ]
the updated values are [ 0.36089677640603557 ]
the iteration ends
the updated values are [ 0.6267908855357415 ]
the updated values are [ 1.32998494894071 ]
the updated values are [ 0.40490683584819387 ]
(%o8) done
➔ Q2
➔ kill(all);
(%o0) done
➔ a:matrix([4,0,2],[0,5,2],[5,4,10]);
4 0 2
a 0 5 2
5 4 10
➔ b:matrix([4],[−3],[2]);
4
b −3
➔ x:matrix([0],[0],[0]);
0
x 0
➔ GAUSS SIEDEL METHOD
➔ dim:3;
dim 3
➔ dim:3;
for itr:1 thru 3 do(
for i:1 thru dim do(
x[i]:float(1/a[i,i]·(b[i]−(sum(a[i,j]·x[j],j,1,i−1)+sum(a[i,j]·x[j],j,i+1,dim)))))
,
print("the iteration ends"),
for i:1 thru dim do(print("the updated values are",x[i]))
);
dim 3
the iteration ends
the updated values are [ 1.0 ]
the updated values are [ − 0.6 ]
the updated values are [ − 0.06000000000000001 ]
the iteration ends
the updated values are [ 1.03 ]
the updated values are [ − 0.576 ]
the updated values are [ − 0.08460000000000006 ]
the iteration ends
the updated values are [ 1.0423 ]
the updated values are [ − 0.56616 ]
the updated values are [ − 0.094686 ]
(%o7) done
➔ GAUSS JACOBI METHOD
➔ dim:3;
for itr:1 thru 3 do(
for i:1 thru dim do(
y[i]:float(1/a[i,i]·(b[i]−(sum(a[i,j]·x[j],j,1,i−1)+sum(a[i,j]·x[j],j,i+1,dim)))))
,
for i:1 thru dim do (x[i]:y[i]),
print("the iteration ends"),
for i:1 thru dim do(print("the updated values are",x[i]))
);
dim 3
the iteration ends
the updated values are [ 1.047343 ]
the updated values are [ − 0.5621256 ]
the updated values are [ − 0.094686 ]
the iteration ends
the updated values are [ 1.047343 ]
the updated values are [ − 0.5621256 ]
the updated values are [ − 0.09882125999999994 ]
the iteration ends
the updated values are [ 1.04941063 ]
the updated values are [ − 0.560471496 ]
the updated values are [ − 0.09882125999999994 ]
(%o9) done
➔ Q3
(%i1) kill(all);
(%o0) done
➔ LAGRANGE INTERPOLATION METHOD
(%i1) p(x):= float(1·((x−3)·(x−4)/((1−3)·(1−4)))+27·((x−1)·(x−4)/((3−1)·(3−4)))+64·((x−1)·(x−3)/((4−1)·(4−3
(x−3) (x−4) (x−1) (x−4) (x−1) (x−3)
(%o1) p ( x ) := float 1 + 27 + 64
(1−3) (1−4) (3−1) (3−4) (4−1) (4−3)
(%i2) expand(p(x));
2
(%o2) 7.999999999999998 x − 19.0 x + 12.0
➔ NEWTON DIVIDED DIFFERENCE METHOD
(%i3) f1:1;
f1 1
(%i4) f2:float(27−1)/(3−1);
f2 13.0
(%i5) f3:float(64−27)/(4−3);
f3 37.0
(%i6) f4:float(f3−f2)/(4−1);
f4 8.0
(%i7) p(x):=float(f1+f2·(x−1)+f4·(x−1)·(x−3));
(%o7) p ( x ) := float ( f1 + f2 ( x − 1 ) + f4 ( x − 1 ) ( x − 3 ) )
(%i8) expand(p(x));
2
(%o8) 8.0 x − 19.0 x + 12.0
➔ Q4
➔ x=0,1,2,4,5,6
➔ y=1,14,15,5,6,19
➔ LAGRANGE INTERPOLATION METHOD
(%i9) p(x):=float(1·((x−1)·(x−2)·(x−4)·(x−5)·(x−6)/((0−1)·(0−2)·(0−4)·(0−5)·(0−6)))+
14·((x−0)·(x−2)·(x−4)·(x−5)·(x−6)/((1−0)·(1−2)·(1−4)·(1−5)·(1−6)))+
15·((x−0)·(x−1)·(x−4)·(x−5)·(x−6)/((2−0)·(2−1)·(2−4)·(2−5)·(2−6)))+
5·((x−0)·(x−1)·(x−2)·(x−5)·(x−6)/((4−0)·(4−1)·(4−2)·(4−5)·(4−6)))+
6·((x−0)·(x−1)·(x−2)·(x−4)·(x−6)/((5−0)·(5−1)·(5−2)·(5−4)·(5−6)))+
19·((x−0)·(x−1)·(x−2)·(x−4)·(x−5)/((6−0)·(6−1)·(6−2)·(6−4)·(6−5))));
(x−1) (x−2) (x−4) (x−5) (x−6) (x−0) (x−2) (x−4) (x−5) (x−6)
(%o9) p ( x ) := float ( 1 + 14 + 15
(0−1) (0−2) (0−4) (0−5) (0−6) (1−0) (1−2) (1−4) (1−5) (1−6)
(x−0) (x−1) (x−4) (x−5) (x−6) (x−0) (x−1) (x−2) (x−5) (x−6)
+5 +6
(2−0) (2−1) (2−4) (2−5) (2−6) (4−0) (4−1) (4−2) (4−5) (4−6)
(x−0) (x−1) (x−2) (x−4) (x−6) (x−0) (x−1) (x−2) (x−4) (x−5)
+ 19 )
(5−0) (5−1) (5−2) (5−4) (5−6) (6−0) (6−1) (6−2) (6−4) (6−5)
(%i10) expand(p(x));
−17 5 3 2
(%o10) − ( 1.3877787807814457 10 x ) + 0.9999999999999991 x − 9.0 x + 21.0 x + 1.0
➔ NEWTON DIVIDED DIFFERENCE METHOD
(%i22) x0:0;
x1:1;
x2:2;
x3:4;
x4:5;
x5:6;
f0:1;
f1:14;
f2:15;
f3:5;
f4:6;
f5:19;
x0 0
x1 1
x2 2
x3 4
x4 5
x5 6
f0 1
f1 14
f2 15
f3 5
f4 6
f5 19
(%i27) f01:(f1−f0)/(x1−x0);
f12:(f2−f1)/(x2−x1);
f23:(f3−f2)/(x3−x2);
f34:(f4−f3)/(x4−x3);
f45:(f5−f4)/(x5−x4);
f01 13
f12 1
f23 −5
f34 1
f45 13
(%i31) f012:(f12−f01)/(x2−x0);
f123:(f23−f12)/(x3−x1);
f234:(f34−f23)/(x4−x2);
f345:(f45−f34)/(x5−x3);
f012 −6
f123 −2
f234 2
f345 6
(%i34) f0123:(f123−f012)/(x3−x0);
f1234:(f234−f123)/(x4−x1);
f2345:(f345−f234)/(x5−x2);
f0123 1
f1234 1
f2345 1
(%i36) f01234:(f1234−f0123)/(x4−x0);
f12345:(f2345−f1234)/(x5−x1);
f01234 0
f12345 0
(%i37) f012345:(f12345−f01234)/(x5−x0);
f012345 0
(%i39) p(x):=float(f0
+ f01·(x − x0)
+ f012·(x − x0)·(x − x1)
+ f0123·(x − x0)·(x − x1)·(x − x2));
(%o39) p ( x ) := float ( f0 + f01 ( x − x0 ) + f012 ( x − x0 ) ( x − x1 ) + f0123 ( x − x0 ) ( x − x1 ) ( x − x2 ) )
(%i40) expand(p(x));
3 2
(%o40) x − 9.0 x + 21.0 x + 1.0