SCILAB ASSIGNMENT (FIRST ALLOTMENT)
SPECIAL FUNCTIONS
SUBMITTED BY:
1) MUKESH SINGH BISHT R (244)
2)ANURAG (124)
3)NGAORAI(266)
AIM: Frobenius method and Special functions:
Orthogonality of Legendre functions and to plot Legendre and Bessel functions
alongwith their recurrence properties
APPARATUS REQUIRED: Scilab 5.5.2 and Microsoft Office Softwares
THEORY:
LEGENDRE FUNCTIONS
The polynomial solution, denoted by Pn(x), of degree n of the given equation below which satisfies
Pn(1) = 1 is called the Legendre polynomial of degree n.
(1 − x ^2 )y’’− 2xy’ + n(n + 1)y = 0
Orthogonality: The following property holds for Legendre polynomials:
Integrate(pm(x)pn(x)dx) with limits -1 to 1 is the Kronecker delta
One of the recurrence relation it obeys is (n+1)Pn+1(x)=(2n+1)xPn(x)-nPn-1(x)
APPLICATION OF LEGENDRE FUNCTIONS
1.In calculating Newtonian potential
2.In studying multipole expansion
3.In Trigonometry
BESSEL FUNCTIONS
Bessel functions, first defined by the mathematician Daniel Bernoulli and then generalized
by Friedrich Bessel, are the canonical solutions y(x) of the differential equation
x^2y’’+xy’+(x^2-a^2)y=0
Bessel ‘s functions which are solutions but of the first kind are finite and will be dealt with here.
Jα+1(x) + Jα−1(x) = 2α x Jα(x) is the recurrence relation for the same
APPLICATION OF BESSEL FUNCTION
Electromagnetic waves in a cylindrical waveguide
Pressure amplitudes of inviscid rotational flows
Heat conduction in a cylindrical object
Modes of vibration of a thin circular (or annular) acoustic membrane (such as a drum or
other membranophone)
Diffusion problems on a lattice
Solutions to the radial Schrödinger equation (in spherical and cylindrical coordinates) for
a free particle
PROGRAMS AND OUTPUTS
1.Orthogonality of Legendre functions
//Legendre polynomials orthogonality verification
x=poly(0,"x")
n=input("enter n:")
m=input("enter m:")
a=integrate('legendre(m,0,x)*legendre(n,0,x)','x',-1,1,0.0001)
mprintf('int(P%i(x))*(P%f(x))dx=%g\n',m,n,a)
output :
-->exec('C:\Users\HP\Desktop\Books\Programs\Scilab programs\Orthogonality legendre.sce', -1)
enter n:1
enter m:3
int(P3(x))*(P1.000000(x))dx=1.17961e-16
-->exec('C:\Users\HP\Desktop\Books\Programs\Scilab programs\Orthogonality legendre.sce', -1)
enter n:3
enter m:3
int(P3(x))*(P3.000000(x))dx=0.285714
2.Plotting Legendre functions
// plot of the 6 first Legendre polynomials on (-1,1)
l = nearfloat("pred",1);
x = linspace(-l,l,200)';
y = legendre(0:5, 0, x);
xgrid(1,1,7)
ylabel("The values of legendre polynomials of different orders from (-1,1)")
xlabel("The values of x")
plot2d(x,y', leg="p0@p1@p2@p3@p4@p5@p6")
xtitle("the 6 th first Legendre polynomials")
Output:
3.Plotting Bessel functions
// bessel functions of 2nd kind
x = linspace(0.01,20,5000)'
plot2d(x,besselj(0:4,x), rect=[0,-0.6,20,1])
legend('K'+string(0:4),1);
xtitle("Some modified Bessel functions of the second kind")
ylabel("The values of bessel functions of different orders")
xlabel("The values of x")
xgrid(1,1,7)
Output:
4.Recurrence relation of Legendre function and to plot them
previousprot = funcprot(0)
function f=leg(n)
//to plot legendre's polynomials using reccurence relations....
x=poly(0,"x")
select n
case 0 then
f=1
case 1 then
f=x
else
f=((2*n-1)/n)*x*leg(n-1)-((n-1)/n)*leg(n-2)
disp(f)
X=[-1:0.01:1]
Y=horner(f,X)
xgrid(1, 1, 7)
xtitle("Plot of the Legendre polynomials using recurrence relation")
ylabel("The values of legendre polynomials of different orders from (-1,1)")
xlabel("The values of x")
plot(X,Y)
end
endfunction
funcprot(previousprot)
Output:
- 0.5 + 1.5x
3
- 1.5x + 2.5x
- 0.5 + 1.5x
2 4
0.375 - 3.75x + 4.375x
- 0.5 + 1.5x
- 1.5x + 2.5x
3 5
1.875x - 8.75x + 7.875x
- 0.5 + 1.5x
- 1.5x + 2.5x
- 0.5 + 1.5x
2 4
0.375 - 3.75x + 4.375x
2 4 6
- 0.3125 + 6.5625x - 19.6875x + 14.4375x
ans =
2 4 6
- 0.3125 + 6.5625x - 19.6875x + 14.4375x
5. Recurrence relation of Bessel function and to plot them
previousprot = funcprot(0)
function f=bes(n)
//to plot legendre's polynomials using reccurence relations....
x=poly(0,"x")
select n
case 0 then
f=1-0.25*(x^2)+0.015625*(x^4)-0.000434*(x^6)+0.0000068*(x^8)-(6.782*(10^-
8))*(x^10)+(4.710*(10^-10))*(x^12)
case 1 then
f=0.5*x-0.0625*(x^3)+0.0026042*(x^5)-0.0000543*(x^7)+0.0000007*(x^9)-(5.651*(10^-
9))*(x^11)+(3.364*(10^-11))*(x^13)
else
f=(2*(n-1)/x)*bes(n-1)-bes(n-2)
disp(f)
X=[-1:0.001:40]
Y=horner(f,X)
xgrid(1, 1, 7)
xtitle("Plot of the bessel functionss using recurrence relation")
ylabel("The values of bessel functions of different orders from (-1,40)")
xlabel("The values of x")
plot2d(X,Y,rect=[0,-1,10,1])
end
endfunction
funcprot(previousprot)
Output:
-->exec('C:\Users\HP\Desktop\Books\Programs\Scilab programs\Bessel recurrence.sce', -1)
-->bes(5)
2 4 6 8 10 12
0.125x - 0.0104166x + 0.0003254x - 0.0000054x + 5.652D-08x - 4.037D-10x
-----------------------------------------------------------------------
3 5 7 9 11 13
0.0208336x - 0.0013026x + 0.0000327x - 0.0000005x + 4.036D-09x - 3.364D-11x
---------------------------------------------------------------------------
2 4 6 8 10 12
0.125x - 0.0104166x + 0.0003254x - 0.0000054x + 5.652D-08x - 4.037D-10x
-----------------------------------------------------------------------
1
2 4 6 8 10 12
0.0000016x + 0.002601x - 0.0001292x + 0.0000026x - 3.230D-08x + 2.019D-10x
--------------------------------------------------------------------------
2 4 6 8 10 12
0.125x - 0.0104166x + 0.0003254x - 0.0000054x + 5.652D-08x - 4.037D-10x
-----------------------------------------------------------------------
3 5 7 9 11 13
0.0208336x - 0.0013026x + 0.0000327x - 0.0000005x + 4.036D-09x - 3.364D-11x
---------------------------------------------------------------------------
3 5 7 9 11 13
0.0000128x - 0.0000256x + 0.000269x - 0.0000122x + 0.0000002x - 2.421D-09x + 3.364D-11x
---------------------------------------------------------------------------------------
ans =
3 5 7 9 11 13
0.0000128x - 0.0000256x + 0.000269x - 0.0000122x + 0.0000002x - 2.421D-09x + 3.364D-11x
---------------------------------------------------------------------------------------