%% Compare Legendre Normalizations
% Calculate the associated Legendre function values with several normalizations.
%
% Calculate the first-degree, unnormalized Legendre function values P_1^m. The first row of values corresponds to m=0, and the second row to m=1.

x = 0:0.2:1;
n = 1;
P_unnorm = legendre(n,x)

%
% Next, compute the Schmidt seminormalized function values. Compared to the unnormalized values, the Schmidt form differs when m>0 by the scaling
% \left( -1\right) ^m \sqrt{\frac{2 (n-m)!}{(n+m)!}}.
% For the first row, the two normalizations are the same, since m=0. For the second row, the scaling constant multiplying each value is -1.

P_sch = legendre(n,x,'sch')
C1 = (-1) * sqrt(2*factorial(0)/factorial(2))

%
% Lastly, compute the fully normalized function values. Compared to the unnormalized values, the fully normalized form differs by the scaling factor
% \left(-1\right)^m \sqrt{\frac{\left(n+\frac{1}{2}\right)(n-m)!}{(n+m)!}}.
% This scaling factor applies for all values of m, so the first and second rows have different scaling factors.

P_norm = legendre(n,x,'norm')
Cm0 = sqrt((3/2))
Cm1 = (-1) * sqrt((3/2)/2)

%
% Copyright 2018 The MathWorks, Inc.