Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

//Name - Dikshant

//Roll No. - 3942


clc
clear

function k=legendre_poly_gamma(n, var) // n referes


to the order, var is for variable in terms of which the
expression is to be written
if n==0 then
cc=[1] // since P(0)=1
elseif n==1 then
cc=[0 1]

// cc list stores the coefficinets of the powers


of x (incresing)

else
if modulo(n,2)==0 then
M=n/2
else
M=(n-1)/2
end
// M=order/2 if order odd

j=1
for m=0:M
cc($+j)=(-1)^m*gamma(2*n-
2*m+1)/(2^n*gamma(m+1)*gamma(n-m+1)*gamma(n-2*m+1))
j=2
// m k cc(k+1)=coefficient power
of x
// 0 4 4.375 4
// 1 2 -3.75 2
// 2 0 0.375 0
end

end

k= poly(flipdim(cc,1), var, 'coeff')

endfunction

for i=1:5
disp(legendre_poly_gamma(i, 'x'))
end

Output :-

-0.5 +1.5x²

-1.5 +2.5x²

0.375 -3.75x² +4.375x⁴

1.875 -8.75x² +7.875x⁴

You might also like