0% found this document useful (0 votes)
81 views8 pages

Scilabs Tutorial Maths

The document describes solving various equations using different numerical methods: 1) Regula Falsi Method is used to find the root of an equation, iteratively converging on the solution. 2) Jacobi method is used to solve a system of 3 linear equations. 3) Gauss-Seidel iterative method is used to solve another system of 3 linear equations. 4) Newton-Raphson method is used to find a root of an equation involving sine and cosine.

Uploaded by

roshanajith7911
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views8 pages

Scilabs Tutorial Maths

The document describes solving various equations using different numerical methods: 1) Regula Falsi Method is used to find the root of an equation, iteratively converging on the solution. 2) Jacobi method is used to solve a system of 3 linear equations. 3) Gauss-Seidel iterative method is used to solve another system of 3 linear equations. 4) Newton-Raphson method is used to find a root of an equation involving sine and cosine.

Uploaded by

roshanajith7911
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Regula Falsi Method

Solve by Regula Falsi Method, y=2x3-2.5x-5

INPUT

clc
clear
deff('[y]=f(x)','y=2*(x^3)-2.5*x-5');
a=1;b=2;c=0;c1=1;
i=0;
eps=0.0001;
disp('Regula Falsi Method')
disp('Roots')
while(abs(c-c1)>eps)
c=(a*f(b)-b*f(a))/(f(b)-f(a));
if(f(a)*f(c)<0)
b=c;
end
if(f(b)*f(c)<0)
a=c;
end
c1=(a*f(b)-b*f(a))/(f(b)-f(a));
i=i+1
disp(c);
end
disp('No.of iterations:');
disp(i);
OUTPUT

"Regula Falsi Method"


"Roots"
1.4782609
1.6198575
1.6517157
1.6583765
1.6597469
1.6600279

"No. of iterations:"
6
Jacobi method
Solve 20x+y-2z=17,3x=20y-z=-18,2x-3y+ 20z=25, by Jacobi method

INPUT

clc
A=[20 1 -2 17;
3 20 -1 -18;
2 -3 20 25]
x(1)=0;
y(1)=0;
z(1)=0;
for j=2:5
x(j)=(17-y(j-1)+2*z(j-1))/20;
y(j)=(-18.3*x(j-1)+z(j-1))/20;
z(j)=(25-2*x(j-1)+3*y(j-1))/20;
disp(x(j));
disp(y(j));
disp(z(j));
disp('A')
end
OUTPUT

0.85
0.
1.25
"A"
0.975
-0.7152500
1.165
"A"
1.0022625
-0.8338750
1.0452125
"A"
0.996215
-0.8648096
1.0246925
"A"
GAUSS SEIDEL ITERATIVE METHOD
SOLVE
10X-5Y-2Z=3
4X-10Y+3Z=-3
X+6Y+1 0Z=-3

INPUT

clc
clear
A=[10 -5 -2;4 -10 3;1 6 10]
B=[3 -3 -3]'
disp('(A B)=')
disp([A B])
n=9
xold=0
yold=0
zold=0
for i=0:n
x(i+1)=((B(1)-A(4)*yold-A(7)*zold))/A(1)
y(i+1)=((B(2)-A(2)*x(i+1)-A(8)*zold))/A(5)
z(i+1)=((B(3)-A(3)*x(i+1)-A(6)*y(i+1)))/A(9)
xold=x(i+1)
yold=y(i+1)
zold=z(i+1)
end
disp('x=');
disp(xold)
disp('y=');
disp(yold)
disp('z=')
disp(zold)
OUTPUT
"(A B)="
10. -5. -2. 3.
4. -10. 3. -3.
1. 6. 10. -3.
"x="
0.3414864
"y="
0.2850423
"z="
-0.5051740
Newton-Raphson Method

Use the Newton-Raphson method to find a root of the equation


xsinx + cosx = 0

INPUT
clc;
deff('[y]=f(x)','y=x*sin(x)+cos(x)');
deff('[y]=fd(x)','y=x*cos(x)');
x=3.1416;
xx=0;
i=0;
eps=0.0001;
disp('By using Newton Raphson Method');
disp('x:');
while(abs(x-xx)>=eps)
y=x-(f(x)/fd(x));
disp(y);
xx=x;
x=y;
i=i+1;
end
disp('No of iteration;');
disp(i);
OUTPUT

By using Newton Raphson Method"


"x:"
2.8232835
2.7985999
2.7983861
2.7983860

"No of iteration;"
4.

You might also like