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 |
are bhai run naHI HO RAHA HAI
ReplyDeleteclear;clc
ReplyDeletedeff('y=f(x)','y=1/(1+x*x)');
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)
while p~=0
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)
clear;clc
ReplyDeletedeff('y=f(x)','y=1/(1+x*x)');
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)
3/8 rule
rank
ReplyDeleteA=input("Enter the Matrix A: ")
[r,c]=size(A)
for i=1:r-1
if A(i,i)~=0
alpha=A(i,i)
A(i,:)=A(i,:)/alpha
end
for j=i+1:r
bet=A(j,i)
A(j,:)=A(j,:)-bet*A(i,:)
end
end
disp(A)
Z=zeros(1,r)
Rank=r
for j=r:-1:1
if A(j,:)==Z
Rank=Rank-1
end
end
disp("Rank")
disp(Rank)
rank
ReplyDeleteA=input("Enter the Matrix A: ")
[r,c]=size(A)
for i=1:r-1
if A(i,i)~=0
alpha=A(i,i)
A(i,:)=A(i,:)/alpha
end
for j=i+1:r
bet=A(j,i)
A(j,:)=A(j,:)-bet*A(i,:)
end
end
disp(A)
Z=zeros(1,r)
Rank=r
for j=r:-1:1
if A(j,:)==Z
Rank=Rank-1
end
end
disp("Rank")
disp(Rank)