Thursday, October 31, 2019
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 |
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 |
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 |
Subscribe to:
Posts (Atom)