3.2 Legendre Polynomials
39
These equations hold for −1 ≤ x ≤ 1, otherwise ln
1+x
1−x becomes ln
x+1
x−1 .
The functions Q hold the same recurrence relations as P , especially Eq. (3.5).
Therefore, again the computation of the polynomial coefficients will be based on
recurrence formula (3.5). Results are shown in Fig. 3.1.
The Class Legendre2poly
The polynomial coefficients necessary to evaluate Eq. (3.6a) can be computed via
[obj, Qln, Qpl] = legendre2poly(n). The class object comes with
the properties “polycoefln” a table of the Legendre polynomial coefficients (Qln),
“polycoefpl” the table of the polynomial coefficients (Qpl) for the additional Wpart, “polyint” a predefined interval [−1, +1], and “info” with the value of the
“Legendre Function of Second Kind.” The class comes in addition with the method
[res, n] = Qvalue(obj,x,n) to compute the functional value at points x.
“obj” is the class object, and all other input variables are optional. “x” is an arbitrary
vector, and default is x ∈ [−1, +1]. “n” is an integer vector at which Q n should be
computed. The method plot(obj,n,x,ax) plots the corresponding functions.
“obj” is the class object. All other input variables are optional. “n” is an integer
vector at which Q n should be plotted; default is all. “x” the region about which the
functions should be plotted with default −1 · · · + 1, and “ax” the axes handle which
should be used for the plot.
Example
The following example lists the code of plot, Fig. 3.1:
% Visualization of Legendre Polynomials
legendrepoly(5).plot
% method of polymeth class
ax1 = gca;
subplot(2,2,1,ax1)
hold on
%
generating the objects
objQ=legendre2poly(5);
objP=legendrepoly(5);
%
visualization
ax2 = subplot(2,2,2);
x = linspace(-1,1);
n = 0:5;
plot(objQ,n,x,ax2) % calling the plot-method
hold on
%
ax3 = subplot(2,2,3:4)
x = linspace(-1,2,200);
n = [0,2,3];
plot(objP,n,x,ax3) % method of polymeth class
hold on
plot(objQ,n,x,ax3) % method of legendre2poly class
ylim([-2,4])
Précédent

- 54/287

Suivant