Wednesday, December 4, 2019

Gauss seidel




A=input("Enter the matrix A : ")
b=input("Enter the matrix b : ")
c=input("initial approx")
[r,m]=size(A)
l=1

while l~=10
    for i=1:r
        z=0
        for j=1:m
            if i~=j
                z=z+A(i,j)*c(j)
            end
        end
    c(i)=(b(i)-z)/A(i,i)
end
l=l+1
end
disp(c)


Sunday, November 3, 2019

False position method or Regular falsi method

False position method or Regular falsi method

Code is Here

//false position method or regular falsi method
clear;clc;close
deff('y=f(x)','y=x^2.2-69');
printf("The given function is y=x^2.2-69 \n\n");
a=input("Enter first approximation : ");
b=input("Enter second approximation : ");
d=input("Enter accuracy : ");
printf('succesive iterations    \ta\t    b\t    f(a)\t    f(b)\t\  x1\n');
for i=1:25
    x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a));
    if(f(a)*f(x1))>0
        b=x1;
    else
        a=x1;
    end
    if abs(f(x1))<d
        break
    end
    printf('                         \t%f  %f  %f  %f  %f\n',a,b,f(a),f(b),x1);
end
printf('the root of the equation is  %f',x1);



False position method or Regular falsi method
Add False position method or Regular falsi method

Simpson's three by eight rule

Simpson's three by eight rule


Code is Here

clear;clc
fxn=input("Enter the fuction : (eg:y=(x^2+5*x+6)) : ")
deff('y=f(x)',fxn);
printf("The given function is %s\n\n",fxn);
a=input('Inter the lower limit : ')
b=input('Inter the upper limit : ')
n=input('Inter the value of n : ')
h=(b-a)/n
for i=0:n
    X(1,i+1)=a+h*i
    Y(1,i+1)=f(a+h*i)
end
printf("x=")
disp(X)
printf("y=")
disp(Y)
a1=Y(1,1)+Y(1,n+1);
a2=0
for j=3:3:n-1
    a2=a2+Y(1,j+1);
end
a3=0
for k=0:n-1
    p=modulo(k,3)
if p==0
else
    a3=a3+Y(1,k+1);
end
end
i=(3*h/8)*(a1+2*a2+3*a3);
printf("The value of Integral is : ")
disp(i)



Simpson's three by eight rule
Simpson's three by eight rule

Thursday, October 31, 2019

ODE by Modified Euler's Method Scilab code

ODE by Modified Euler's Method Scilab code

Code is Here



ODE by Euler's Method Scilab code

ODE by Euler's Method Scilab code

Code is Here


clear
deff('z=f(x,y)','z=3*x+y/2');
printf("The given function is dy/dx=x+y\n");
X(1,1)=input('Enter the value of x0 : ')
Y(1,1)=input('Enter the value of y0 : ')
b=input('Enter the value of x : ')
n=input('Enter the value of n : ')
h=(b-X(1,1))/n
for i=2:n+1
    X(1,i)=X(1,i-1)+h
end
disp(X,"X=")
for j=2:n+1
    Y(1,j)=Y(1,j-1)+h*f(X(1,j-1),Y(1,j-1))
end
disp(Y,"y=")
printf("\nSo Value of y(%d) is = %f\n",n,Y(n+1))


ODE by Euler's Method Scilab code
ODE by Euler's Method Scilab code

Trapezoidal Method Scilab Code

Trapezoidal Method Scilab code

Code is Here


clear
fxn=input("Enter the fuction : (eg:y=(x^2+5*x+6)) : ")
deff('y=f(x)',fxn);
printf("The given function is %s\n\n",fxn);
a=input('Enter the lower limit : ')
b=input('Inter the upper limit : ')
n=input('Enter the value of n : ')
h=(b-a)/n
for i=0:n
    X(1,i+1)=a+h*i
    Y(1,i+1)=f(a+h*i)
end
printf ("x=")
disp (X)
printf ("y=")
disp (Y)
a1=Y(1,1)+Y(1,n+1);
a2=0
for j=2:n
    a2=a2+Y(1,j)
end
i=(h/2)*(a1+2*a2);
printf('The value of Integral is : ')
disp(i)



Trapezoidal Method Scilab Code
Trapezoidal Method Scilab Code


Simpson's one third (1/3) rule Scilab code

Simpson's one third (1/3) rule Scilab code

Code is Here

clear
fxn=input("Enter the fuction : (eg:y=(x^2+5*x+6)) : ")
deff('y=f(x)',fxn);
printf("The given function is %s\n\n",fxn);
a=input('Enter the lower limit : ')
b=input('Inter the upper limit : ')
n=input('Enter the value of n : ')
h=(b-a)/n
for i=0:n
    X(1,i+1)=a+h*i
    Y(1,i+1)=f(a+h*i)
end
printf ("x=")
disp (X)
printf ("y=")
disp (Y)
a1=Y(1,1)+Y(1,n+1);
a2=0
for j=2:2:n
    a2=a2+Y(1,j)
end
a3=0
for l=3:2:n-1
    a3=a3+Y(1,l)
end
i=(h/3)*(a1+4*a2+2*a3);
printf('The value of Integral is : ')
disp(i)

Simpson's one third (1/3) rule Scilab code
Simpson's one third (1/3) rule Scilab code









Friday, September 20, 2019

Bisection Method Scilab code

Bisection Method code Scilab



Code is Here



clc;clear
deff('y=f(x)','y=x^3-1');
x1=input("Enter first approximation: ");
x2=input("Enter second approximation : ");
d=input("Enter accuracy : ");
c=1;
printf('Succesive approximation: \t   x1\t   \tx2\t   \tm\t   \tf(m)\n');
while abs(x1-x2)>d
    m=(x1+x2)/2;
printf('                          \t%f\t%f\t%f\t%f\n',x1,x2,m,f(m));
    if f(m)*f(x1)>0
        x1=m;
    else
        x2=m; 
end
c=c+1;
end
printf('The solution of equation after %i iteration is %g',c,m);
//done


Bisection Method Scilab code
Bisection Method Scilab code


Secant Method Scilab Code

Secant Method Scilab Code


Code is Here



clc;clear
deff('y=f(x)','y=x^3-2*x-5');
x1=2,x2=3// initial values 
n=1; c=0; 
printf('successive iterations \tx1 \tx2\t x3\t f(x3)\n') 
while n==1 
    x3=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)); 
    printf(' \t%f\t%f\t%f\t%f\n',x1,x2,x3,f(x3)); 
    if f(x3)*f(x1)>0
x2=x3;
else
x1=x3;
end
if abs(f(x3))<0.0001 then
break;
end
c=c+1;
end
printf('the root of the equation after %i iteration is: %f',c,x3 )


Secant Method Scilab Code
Secant Method Scilab Code

LU Decomposition Method Scilab code

LU Decomposition Method Scilab code


Code is here

clear; // Remove clear, clc from code if you want to access existing stored variable from the memory
//LU decomposition method
clc;clear;close;
A=[2,3,1;1,2,3;3,1,2];
B=[9;6;8]
L(1,2)=0,L(1,3)=0,L(2,3)=0;
U(2,1)=0,U(3,1)=0,U(3,2)=0;
for i=1:3
L(i,i)=1;
end
for i=1:3
U(1,i)=A(1,i);
end
L(2,1)=1/U(1,1);
for i=2:3
U(2,i)=A(2,i)-U(1,i)L(2,1); end L(3,1)=A(3,1)/U(1,1); L(3,2)=(A(3,2)-U(1,2)L(3,1))/U(2,2);
U(3,3)=A(3,3)-U(1,3)L(3,1)-U(2,3)L(3,2);
printf(‘The Matrix A in Triangle form\n \n’)
printf(‘Matrix L\n’);
for i=1:3
for j=1:3
printf(‘%.2f ‘,L(i,j));
end
printf(‘\n’);
end
printf(‘\n \n’);
printf(‘Matrix U\n’);
for i=1:3
for j=1:3
printf(‘%.2f ‘,U(i,j));
end
printf(‘\n’);
end
Y=L^-1B; X=U^-1Y;
printf(‘ the values of x=%f,y=%f,z=%f’,X(1,1),X(2,1),X(3,1));

Monday, September 16, 2019

Fees structure of IIT colleges in India

Fees structure of IIT colleges in India

Details of the IITs B.Tech Fee Structure
Name of IITs
Category
Amount in Rs.
Total Fees
Academic Fee
1,22,300
Hostel and Hostel and Mess Charges
3,550
Academic Fee
123500
Hostel and Hostel and Mess Charges
30500*
Academic Fee
125568
Hostel and Hostel and Mess Charges
22,500
Academic Fee
1,16,450
Hostel and Mess Charges
8,000
Academic Fee
1,26,470
Hostel and Mess Charges
15,000
Academic Fee
1,16,750
Hostel and Mess Charges
26,000
Academic Fee
1,34,000
Hostel and Mess Charges
19,000
Academic Fee
1,21,679
Hostel and Mess Charges
17,000
Academic Fee
1,27,650
Hostel and Mess Charges
21,880
Academic Fee
1,24,675
Hostel and Mess Charges
28,275
Academic Fee
1,26,000
Hostel and Mess Charges
16,000
Academic Fee
89,250
Hostel and Mess Charges
45,750
Academic Fee
1,25,400
Hostel and Mess Charges
7,000
Academic Fee
1,13,500
Hostel and Mess Charges
23,400
Academic Fee
1,20,150
Hostel and Mess Charges
28,855
Academic Fee
1,08,450
Hostel and Mess Charges
33,215
Academic Fee
1,66,500
Hostel and Mess Charges
18,500
Academic Fee
1,13,750
Hostel and Mess Charges
27,100
Academic Fee
1,19,250
Hostel and Mess Charges
5,000
Academic Fee
1,16,250
Hostel and Mess Charges
30,250
Academic Fee
1,06,650
Hostel and Mess Charges
20,000
Academic Fee
1,14,800
Hostel and Mess Charges
30,600
Academic Fee
1,21,465
Hostel and Mess Charges
12,000