Professional Documents
Culture Documents
Lang Sci12
Lang Sci12
2^n )
n=1:5000
f=0.2^n
s=sum(f)
disp("The sum of 0.2^n = ",s)
output:
s=sum(f)
s = 0.25
n=input("Enter n=")
x=poly(0,"x");
p=x^n+1
rt=roots(p)
mprintf("The %d-th root of unity are\n",n)
disp(rt)
x=-5+12*(-1)^(1/2)
y=sqrt(x);
disp (y);
output :
disp (y);
2. + 3.i
Program 10 : (Integral transform FFT )
output :
diracdelta function
x0=-100;x1=100;
sig=input("Enter sigma=");
function II=f(x), II=1/sqrt(2*%pi*sig^2)*exp(-((x-
2)^2)/(2*sig^2))*(x+3),endfunction
X=intg(x0,x1,f);
disp("The integration is= "+string(X))
Output :
Enter n:3
Enter m:3
∫P3(x)*P3(x)dx= 0.285714
Plot of Pn(x)
// example 1 : plot of the 6 first Legendre polynomials on (-1,1)
x = linspace(-1,1,200)';
y = legendre(0:5, 0, x);
clf()
plot2d(x,y', leg="p0@p1@p2@p3@p4@p5@p6")
xtitle("the 6 th first Legendre polynomials")
output :
Plot Jv(x)
//Bessel Functions of the First Kind
//Plotting some Bessel Functions
clf;
x=[0:0.01:20]';
alpha=0:9;
y=besselj(alpha,x);
plot2d(x,y,leg='J0@J1@J2@J3@J4@J5@J6@J7J8@J9');
xlabel('x');
ylabel('Ja(x)');
xtitle('Some Bessel Functions of the first kind');
output :