Thursday, October 31, 2019

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


No comments:

Post a Comment