Professional Documents
Culture Documents
02
clc,
n=input('enter the no. of unknows:');
a=input('enter the coefficient matrix:');
m=input('enter the no. of iteration:');
for i=1:n
x(i)=0;
end;
for k=1:m
for i=1:n
p=0;
for j=1:n
if i~=j
p=p+a(i,j)*x(j);
end;
end;
x(i)=(a(i,n+1)-p)/a(i,i);
fprintf('for %d iteration value of x(%d)=%f\n',k,i,x(i));
end;
end;
OUTPUT
>>
Roll No .02
OUTPUT
the no of values:8
OUTPUT
the no of iteration:3
r=
-2.4909
1.8342
0.6566
>> syms x
r=
.60710164810312263122482837345049
>> fun=’4*x+2’;
l=
36
>> x=1:0.5:4;
l=
36
Roll No .02
>> % Interpolation
Ans=
39.4971
ans =
3.0000
-2.5000
7.0000
ans=
>> x=% save a .m file with name funrk4 and syntax as below
Dy=((y^2)-(x^2))/((y^2)+(x^2));
X=
0.2000
0.4000
Y=
1.0000
1.1960
1.3753