1 @c -*- mode: texinfo -*-
3 * Introduction to orthogonal polynomials::
4 * Functions and Variables for orthogonal polynomials::
7 @node Introduction to orthogonal polynomials, Functions and Variables for orthogonal polynomials, Package orthopoly, Package orthopoly
8 @section Introduction to orthogonal polynomials
10 @code{orthopoly} is a package for symbolic and numerical evaluation of
11 several kinds of orthogonal polynomials, including Chebyshev,
12 Laguerre, Hermite, Jacobi, Legendre, and ultraspherical (Gegenbauer)
13 polynomials. Additionally, @code{orthopoly} includes support for the spherical Bessel,
14 spherical Hankel, and spherical harmonic functions.
16 For the most part, @code{orthopoly} follows the conventions of Abramowitz and Stegun
17 @i{Handbook of Mathematical Functions}, Chapter 22 (10th printing, December 1972);
18 additionally, we use Gradshteyn and Ryzhik,
19 @i{Table of Integrals, Series, and Products} (1980 corrected and
20 enlarged edition), and Eugen Merzbacher @i{Quantum Mechanics} (2nd edition, 1970).
22 @c INSTALLATION INSTRUCTIONS NO LONGER RELEVANT
23 @c BUT MAYBE SOME OF THESE FILES SHOULD BE MENTIONED IN ANOTHER CONTEXT
24 @c This will create a directory @code{orthopoly_x} (again x is the release
25 @c identifier) that contains the source file @code{orthopoly.lisp}, user
26 @c documentation in html and texi formats, a sample maxima initialization file
27 @c @code{orthopoly-init.lisp}, a README file, a testing routine
28 @c @code{test_orthopoly.mac}, and two demonstration files.
30 @c Start Maxima and compile orthopoly. To do this, use the command
32 @c (c1) compile_file("orthopoly.lisp");
34 Barton Willis of the University of Nebraska at Kearney (UNK) wrote
35 the @code{orthopoly} package and its documentation. The package
36 is released under the GNU General Public License (GPL).
38 @opencatbox{Categories:}
39 @category{Orthogonal polynomials}
40 @category{Share packages}
41 @category{Package orthopoly}
44 @subsection Getting Started with orthopoly
46 @code{load ("orthopoly")} loads the @code{orthopoly} package.
48 To find the third-order Legendre polynomial,
54 (%i1) legendre_p (3, x);
57 (%o1) - ---------- + ----------- - 6 (1 - x) + 1
61 To express this as a sum of powers of @var{x}, apply @var{ratsimp} or @var{rat}
64 @c CONTINUING PREVIOUS EXAMPLE HERE
66 @c [ratsimp (%), rat (%)];
69 (%i2) [ratsimp (%), rat (%)];
72 (%o2)/R/ [----------, ----------]
76 Alternatively, make the second argument to @code{legendre_p} (its ``main'' variable)
77 a canonical rational expression (CRE).
80 @c legendre_p (3, rat (x));
83 (%i1) legendre_p (3, rat (x));
90 For floating point evaluation, @code{orthopoly} uses a running error analysis
91 to estimate an upper bound for the error. For example,
94 @c jacobi_p (150, 2, 3, 0.2);
97 (%i1) jacobi_p (150, 2, 3, 0.2);
98 (%o1) interval(- 0.062017037936715, 1.533267919277521E-11)
101 Intervals have the form @code{interval (@var{c}, @var{r})}, where @var{c} is the
102 center and @var{r} is the radius of the interval. Since Maxima
103 does not support arithmetic on intervals, in some situations, such
104 as graphics, you want to suppress the error and output only the
105 center of the interval. To do this, set the option
106 variable @code{orthopoly_returns_intervals} to @code{false}.
109 @c orthopoly_returns_intervals : false;
110 @c jacobi_p (150, 2, 3, 0.2);
113 (%i1) orthopoly_returns_intervals : false;
115 (%i2) jacobi_p (150, 2, 3, 0.2);
116 (%o2) - 0.062017037936715
119 Refer to the section @pxref{Floating point Evaluation} for more information.
121 Most functions in @code{orthopoly} have a @code{gradef} property; thus
124 @c diff (hermite (n, x), x);
125 @c diff (gen_laguerre (n, a, x), x);
128 (%i1) diff (hermite (n, x), x);
131 (%i2) diff (gen_laguerre (n, a, x), x);
133 n L (x) - (n + a) L (x) unit_step(n)
135 (%o2) ------------------------------------------
139 The unit step function in the second example prevents an error that would
140 otherwise arise by evaluating with @var{n} equal to 0.
142 @c CONTINUING PREVIOUS EXAMPLE HERE
151 The @code{gradef} property only applies to the ``main'' variable; derivatives with
152 respect other arguments usually result in an error message; for example
155 @c diff (hermite (n, x), x);
156 @c diff (hermite (n, x), n);
159 (%i1) diff (hermite (n, x), x);
162 (%i2) diff (hermite (n, x), n);
164 Maxima doesn't know the derivative of hermite with respect the first
166 -- an error. Quitting. To debug this try debugmode(true);
169 Generally, functions in @code{orthopoly} map over lists and matrices. For
170 the mapping to fully evaluate, the option variables
171 @code{doallmxops} and @code{listarith} must both be @code{true} (the defaults).
172 To illustrate the mapping over matrices, consider
176 @c m : matrix ([0, x], [y, 0]);
180 (%i1) hermite (2, x);
183 (%i2) m : matrix ([0, x], [y, 0]);
187 (%i3) hermite (2, m);
189 [ - 2 - 2 (1 - 2 x ) ]
192 [ - 2 (1 - 2 y ) - 2 ]
195 In the second example, the @code{i, j} element of the value
196 is @code{hermite (2, m[i,j])}; this is not the same as computing
197 @code{-2 + 4 m . m}, as seen in the next example.
199 @c CONTINUING PREVIOUS EXAMPLE HERE
201 @c -2 * matrix ([1, 0], [0, 1]) + 4 * m . m;
204 (%i4) -2 * matrix ([1, 0], [0, 1]) + 4 * m . m;
210 If you evaluate a function at a point outside its domain, generally
211 @code{orthopoly} returns the function unevaluated. For example,
214 @c legendre_p (2/3, x);
217 (%i1) legendre_p (2/3, x);
222 @code{orthopoly} supports translation into TeX; it also does two-dimensional
223 output on a terminal.
226 @c spherical_harmonic (l, m, theta, phi);
228 @c jacobi_p (n, a, a - b, x/2);
232 (%i1) spherical_harmonic (l, m, theta, phi);
237 $$Y_@{l@}^@{m@}\left(\vartheta,\varphi\right)$$
239 (%i3) jacobi_p (n, a, a - b, x/2);
244 $$P_@{n@}^@{\left(a,a-b\right)@}\left(@{@{x@}\over@{2@}@}\right)$$
248 @subsection Limitations
250 When an expression involves several orthogonal polynomials with
251 symbolic orders, it's possible that the expression actually
252 vanishes, yet Maxima is unable to simplify it to zero. If you
253 divide by such a quantity, you'll be in trouble. For example,
254 the following expression vanishes for integers @var{n} greater than 1, yet Maxima
255 is unable to simplify it to zero.
258 @c (2*n - 1) * legendre_p (n - 1, x) * x - n * legendre_p (n, x)
259 @c + (1 - n) * legendre_p (n - 2, x);
262 (%i1) (2*n - 1) * legendre_p (n - 1, x) * x - n * legendre_p (n, x)
263 + (1 - n) * legendre_p (n - 2, x);
264 (%o1) (2 n - 1) P (x) x - n P (x) + (1 - n) P (x)
268 For a specific @var{n}, we can reduce the expression to zero.
270 @c CONTINUING PREVIOUS EXAMPLE HERE
272 @c ev (% ,n = 10, ratsimp);
275 (%i2) ev (% ,n = 10, ratsimp);
279 Generally, the polynomial form of an orthogonal polynomial is ill-suited
280 for floating point evaluation. Here's an example.
282 @c ACTUALLY NEEDS load("orthopoly"); BEFORE ANYTHING ELSE
284 @c p : jacobi_p (100, 2, 3, x)$
285 @c subst (0.2, x, p);
286 @c jacobi_p (100, 2, 3, 0.2);
287 @c float(jacobi_p (100, 2, 3, 2/10));
290 (%i1) p : jacobi_p (100, 2, 3, x)$
292 (%i2) subst (0.2, x, p);
293 (%o2) 3.4442767023833592E+35
294 (%i3) jacobi_p (100, 2, 3, 0.2);
295 (%o3) interval(0.18413609135169, 6.8990300925815987E-12)
296 (%i4) float(jacobi_p (100, 2, 3, 2/10));
297 (%o4) 0.18413609135169
300 The true value is about 0.184; this calculation suffers from extreme
301 subtractive cancellation error. Expanding the polynomial and then
302 evaluating, gives a better result.
303 @c CONTINUING PREVIOUS EXAMPLE HERE
306 @c subst (0.2, x, p);
310 (%i6) subst (0.2, x, p);
311 (%o6) 0.18413609766122982
314 This isn't a general rule; expanding the polynomial does not always
315 result in an expression that is better suited for numerical evaluation.
316 By far, the best way to do numerical evaluation is to make one or more
317 of the function arguments floating point numbers. By doing that,
318 specialized floating point algorithms are used for evaluation.
320 Maxima's @code{float} function is somewhat indiscriminate; if you apply
321 @code{float} to an expression involving an orthogonal polynomial with a
322 symbolic degree or order parameter, these parameters may be
323 converted into floats; after that, the expression will not evaluate
327 @c assoc_legendre_p (n, 1, x);
329 @c ev (%, n=2, x=0.9);
332 (%i1) assoc_legendre_p (n, 1, x);
340 (%i3) ev (%, n=2, x=0.9);
346 The expression in (%o3) will not evaluate to a float; @code{orthopoly} doesn't
347 recognize floating point values where it requires an integer. Similarly,
348 numerical evaluation of the @code{pochhammer} function for orders that
349 exceed @code{pochhammer_max_index} can be troublesome; consider
352 @c x : pochhammer (1, 10), pochhammer_max_index : 5;
355 (%i1) x : pochhammer (1, 10), pochhammer_max_index : 5;
360 Applying @code{float} doesn't evaluate @var{x} to a float
362 @c CONTINUING PREVIOUS EXAMPLE HERE
372 To evaluate @var{x} to a float, you'll need to bind
373 @code{pochhammer_max_index} to 11 or greater and apply @code{float} to @var{x}.
375 @c CONTINUING PREVIOUS EXAMPLE HERE
377 @c float (x), pochhammer_max_index : 11;
380 (%i3) float (x), pochhammer_max_index : 11;
384 The default value of @code{pochhammer_max_index} is 100;
385 change its value after loading @code{orthopoly}.
387 Finally, be aware that reference books vary on the definitions of the
388 orthogonal polynomials; we've generally used the conventions
389 of Abramowitz and Stegun.
391 Before you suspect a bug in orthopoly, check some special cases
392 to determine if your definitions match those used by @code{orthopoly}.
393 Definitions often differ by a normalization; occasionally, authors
394 use ``shifted'' versions of the functions that makes the family
395 orthogonal on an interval other than @math{(-1, 1)}. To define, for example,
396 a Legendre polynomial that is orthogonal on @math{(0, 1)}, define
399 @c shifted_legendre_p (n, x) := legendre_p (n, 2*x - 1)$
400 @c shifted_legendre_p (2, rat (x));
401 @c legendre_p (2, rat (x));
404 (%i1) shifted_legendre_p (n, x) := legendre_p (n, 2*x - 1)$
406 (%i2) shifted_legendre_p (2, rat (x));
408 (%o2)/R/ 6 x - 6 x + 1
409 (%i3) legendre_p (2, rat (x));
416 @anchor{Floating point Evaluation}
417 @subsection Floating point Evaluation
419 Most functions in @code{orthopoly} use a running error analysis to
420 estimate the error in floating point evaluation; the
421 exceptions are the spherical Bessel functions and the associated Legendre
422 polynomials of the second kind. For numerical evaluation, the spherical
423 Bessel functions call SLATEC functions. No specialized method is used
424 for numerical evaluation of the associated Legendre polynomials of the
427 The running error analysis ignores errors that are second or higher order
428 in the machine epsilon (also known as unit roundoff). It also
429 ignores a few other errors. It's possible (although unlikely)
430 that the actual error exceeds the estimate.
432 Intervals have the form @code{interval (@var{c}, @var{r})}, where @var{c} is the
433 center of the interval and @var{r} is its radius. The
434 center of an interval can be a complex number, and the radius is always a positive real number.
440 @c y0 : jacobi_p (100, 2, 3, 0.2);
441 @c y1 : bfloat (jacobi_p (100, 2, 3, 1/5));
447 (%i2) y0 : jacobi_p (100, 2, 3, 0.2);
448 (%o2) interval(0.1841360913516871, 6.8990300925815987E-12)
449 (%i3) y1 : bfloat (jacobi_p (100, 2, 3, 1/5));
450 (%o3) 1.8413609135168563091370224958913493690868904463668b-1
453 Let's test that the actual error is smaller than the error estimate
455 @c CONTINUING PREVIOUS EXAMPLE HERE
457 @c is (abs (part (y0, 1) - y1) < part (y0, 2));
460 (%i4) is (abs (part (y0, 1) - y1) < part (y0, 2));
464 Indeed, for this example the error estimate is an upper bound for the
467 Maxima does not support arithmetic on intervals.
470 @c legendre_p (7, 0.1) + legendre_p (8, 0.1);
473 (%i1) legendre_p (7, 0.1) + legendre_p (8, 0.1);
474 (%o1) interval(0.18032072148437508, 3.1477135311021797E-15)
475 + interval(- 0.19949294375000004, 3.3769353084291579E-15)
478 A user could define arithmetic operators that do interval math. To
479 define interval addition, we can define
483 @c "@+"(x,y) := interval (part (x, 1) + part (y, 1), part (x, 2)
485 @c legendre_p (7, 0.1) @+ legendre_p (8, 0.1);
490 (%i2) "@@+"(x,y) := interval (part (x, 1) + part (y, 1), part (x, 2)
493 (%i3) legendre_p (7, 0.1) @@+ legendre_p (8, 0.1);
494 (%o3) interval(- 0.019172222265624955, 6.5246488395313372E-15)
497 The special floating point routines get called when the arguments
498 are complex. For example,
501 @c legendre_p (10, 2 + 3.0*%i);
504 (%i1) legendre_p (10, 2 + 3.0*%i);
505 (%o1) interval(- 3.876378825E+7 %i - 6.0787748E+7,
506 1.2089173052721777E-6)
509 Let's compare this to the true value.
512 @c float (expand (legendre_p (10, 2 + 3*%i)));
515 (%i1) float (expand (legendre_p (10, 2 + 3*%i)));
516 (%o1) - 3.876378825E+7 %i - 6.0787748E+7
519 Additionally, when the arguments are big floats, the special floating point
520 routines get called; however, the big floats are converted into double floats
521 and the final result is a double.
524 @c ultraspherical (150, 0.5b0, 0.9b0);
527 (%i1) ultraspherical (150, 0.5b0, 0.9b0);
528 (%o1) interval(- 0.043009481257265, 3.3750051301228864E-14)
531 @subsection Graphics and @code{orthopoly}
533 To plot expressions that involve the orthogonal polynomials, you
537 Set the option variable @code{orthopoly_returns_intervals} to @code{false},
539 Quote any calls to @code{orthopoly} functions.
541 If function calls aren't quoted, Maxima evaluates them to polynomials before
542 plotting; consequently, the specialized floating point code doesn't get called.
543 Here is an example of how to plot an expression that involves
544 a Legendre polynomial.
547 @c plot2d ('(legendre_p (5, x)), [x, 0, 1]),
548 @c orthopoly_returns_intervals : false;
551 (%i1) plot2d ('(legendre_p (5, x)), [x, 0, 1]),
552 orthopoly_returns_intervals : false;
557 @image{figures/orthopoly1,8cm}
560 The @i{entire} expression @code{legendre_p (5, x)} is quoted; this is
561 different than just quoting the function name using @code{'legendre_p (5, @var{x})}.
563 @opencatbox{Categories:}
568 @subsection Miscellaneous Functions
570 The @code{orthopoly} package defines the
571 Pochhammer symbol and a unit step function. @code{orthopoly} uses
572 the Kronecker delta function and the unit step function in
573 @code{gradef} statements.
575 To convert Pochhammer symbols into quotients of gamma functions,
576 use @code{makegamma}.
579 @c makegamma (pochhammer (x, n));
580 @c makegamma (pochhammer (1/2, 1/2));
583 (%i1) makegamma (pochhammer (x, n));
587 (%i2) makegamma (pochhammer (1/2, 1/2));
593 Derivatives of the Pochhammer symbol are given in terms of the @code{psi}
597 @c diff (pochhammer (x, n), x);
598 @c diff (pochhammer (x, n), n);
601 (%i1) diff (pochhammer (x, n), x);
602 (%o1) (x) (psi (x + n) - psi (x))
604 (%i2) diff (pochhammer (x, n), n);
605 (%o2) (x) psi (x + n)
609 You need to be careful with the expression in (%o1); the difference of the
610 @code{psi} functions has polynomials when @code{@var{x} = -1, -2, .., -@var{n}}. These polynomials
611 cancel with factors in @code{pochhammer (@var{x}, @var{n})} making the derivative a degree
612 @code{@var{n} - 1} polynomial when @var{n} is a positive integer.
614 The Pochhammer symbol is defined for negative orders through its
615 representation as a quotient of gamma functions. Consider
618 @c q : makegamma (pochhammer (x, n));
619 @c sublis ([x=11/3, n= -6], q);
622 (%i1) q : makegamma (pochhammer (x, n));
626 (%i2) sublis ([x=11/3, n= -6], q);
632 Alternatively, we can get this result directly.
635 @c pochhammer (11/3, -6);
638 (%i1) pochhammer (11/3, -6);
644 The unit step function is left-continuous; thus
647 @c [unit_step (-1/10), unit_step (0), unit_step (1/10)];
650 (%i1) [unit_step (-1/10), unit_step (0), unit_step (1/10)];
654 If you need a unit step function that is neither left or right continuous
655 at zero, define your own using @code{signum}; for example,
658 @c xunit_step (x) := (1 + signum (x))/2$
659 @c [xunit_step (-1/10), xunit_step (0), xunit_step (1/10)];
662 (%i1) xunit_step (x) := (1 + signum (x))/2$
664 (%i2) [xunit_step (-1/10), xunit_step (0), xunit_step (1/10)];
670 Do not redefine @code{unit_step} itself; some code in @code{orthopoly}
671 requires that the unit step function be left-continuous.
673 @subsection Algorithms
675 Generally, @code{orthopoly} does symbolic evaluation by using a hypergeometic
676 representation of the orthogonal polynomials. The hypergeometic
677 functions are evaluated using the (undocumented) functions @code{hypergeo11}
678 and @code{hypergeo21}. The exceptions are the half-integer Bessel functions
679 and the associated Legendre function of the second kind. The half-integer Bessel functions are
680 evaluated using an explicit representation, and the associated Legendre
681 function of the second kind is evaluated using recursion.
683 For floating point evaluation, we again convert most functions into
684 a hypergeometic form; we evaluate the hypergeometic functions using
685 forward recursion. Again, the exceptions are the half-integer Bessel functions
686 and the associated Legendre function of the second kind. Numerically,
687 the half-integer Bessel functions are evaluated using the SLATEC code.
690 @node Functions and Variables for orthogonal polynomials, , Introduction to orthogonal polynomials, Package orthopoly
691 @section Functions and Variables for orthogonal polynomials
693 @anchor{assoc_legendre_p}
694 @deffn {Function} assoc_legendre_p (@var{n}, @var{m}, @var{x})
695 The associated Legendre function of the first kind of degree @math{n} and
697 m4_mathcomma(<<<P_{n}^{m}(z)>>>,<<<assoc_legendre_p(n,m,z)>>>)
698 is a solution of the differential equation:
701 <<<(1-z^2){d^2 w\over dz^2} - 2z{dw\over dz} + \left[n(n+1)-{m^2\over 1-z^2}\right] w = 0>>>,
702 <<<(1-z^2)*diff(w,z,2) - 2*z*diff(w,z) + (n*(n+1)-m^2/(1-z^2))*w = 0>>>)
704 This is related to the Legendre polynomial,
705 m4_math(<<<P_n(x)>>>, <<<legendre_p(n,x)>>>)
709 <<<P_n^m(x) = (-1)^m\left(1-x^2\right)^{m/2} {d^m\over dx^m} P_n(x)>>>,
710 <<<assoc_legendre_p(n,m,x) = (-1)^m*(1-x^2)^(m/2) diff(legendre_p(n,x),x,m)>>>)
712 Reference: @urlaands{eqn 22.5.37, 779}, @urlaands{eqn 8.6.6, 334}, and @urlaands{eqn 8.2.5, 333}.
716 @c assoc_legendre_p(2,0,x);
718 @c factor(assoc_legendre_p(2,1,x));
719 @c (-1)^1*(1-x^2)^(1/2)*diff(legendre_p(2,x),1);
723 (%i1) assoc_legendre_p(2,0,x);
726 (%o1) (- 3 (1 - x)) + ---------- + 1
733 (%i3) factor(assoc_legendre_p(2,1,x));
735 (%o3) - 3 x sqrt(1 - x )
737 (%i4) (-1)^1*(1-x^2)^(1/2)*diff(legendre_p(2,x),x);
739 (%o4) - (3 - 3 (1 - x)) sqrt(1 - x )
743 (%o5) - 3 x sqrt(1 - x )
746 @opencatbox{Categories:}
747 @category{Package orthopoly}
752 @anchor{assoc_legendre_q}
753 @deffn {Function} assoc_legendre_q (@var{n}, @var{m}, @var{x})
754 The associated Legendre function of the second kind of degree @math{n}
756 m4_mathcomma(<<<Q_{n}^{m}(z)>>>,<<<assoc_legendre_q(n,m,z)>>>)
757 is a solution of the differential equation:
760 <<<(1-z^2){d^2 w\over dz^2} - 2z{dw\over dz} + \left[n(n+1)-{m^2\over 1-z^2}\right] w = 0>>>,
761 <<<(1-z^2)*diff(w,z,2) - 2*z*diff(w,z) + (n*(n+1)-m^2/(1-z^2))*w = 0>>>)
763 Reference: Abramowitz and Stegun, equation 8.5.3 and 8.1.8.
767 @c assoc_legendre_q(0,0,x);
768 @c assoc_legendre_q(1,0,x);
769 @c assoc_legendre_q(1,1,x);
772 (%i1) assoc_legendre_q(0,0,x);
778 (%i2) assoc_legendre_q(1,0,x);
782 (%o2)/R/ ------------------
784 (%i3) assoc_legendre_q(1,1,x);
787 log(- -----) sqrt(1 - x ) x - 2 sqrt(1 - x ) x - log(- -----) sqrt(1 - x )
789 - ---------------------------------------------------------------------------
794 @opencatbox{Categories:}
795 @category{Package orthopoly}
801 @deffn {Function} chebyshev_t (@var{n}, @var{x})
802 The Chebyshev polynomial of the first kind of degree @math{n},
803 m4_math(<<<T_n(x).>>>,<<<chebyshev_t(n,x).>>>)
805 Reference: @urlaands{eqn 22.5.47, 779}.
808 m4_math(<<<T_n(x)>>>,<<<chebyshev_t(n,x)>>>)
809 can be written in terms of a hypergeometric function:
812 <<<T_n(x) = {_{2}}F_{1}\left(-n, n; {1\over 2}; {1-x\over 2}\right)>>>,
813 <<<hypergeometric([-n,n],[1/2],(1-x)/2)>>>)
815 The polynomials can also be defined in terms of the sum
818 <<<T_n(x) = {n\over 2} \sum_{r=0}^{\lfloor {n/2}\rfloor} {(-1)^r\over n-r} {n-r\choose k}(2x)^{n-2r}>>>,
819 <<<chebyshev_t(n,x) = n/2*sum((-1)^r/(n-r)*binomial(n-r,r)*(2*x)^(n-2*r), r, 0, floor(n/2))>>>)
821 or the Rodrigues formula
824 <<<T_n(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)(1-x^2)^n\right)>>>,
825 <<<@math{chebyshev_t(n,x) = 1/(k(n)*w(x))*diff(w(x)*(1-x^2)^n, x, n)}>>>
832 w(x) &= 1/\sqrt{1-x^2} \cr
833 \kappa_n &= (-2)^n\left(1\over 2\right)_n
835 <<<@math{w(x) = 1/sqrt(1-x^2)}
837 @math{k_n = (-2)^n*pochhammer(1/2,n)}>>>)
843 @c factor(chebyshev_t(3,x));
844 @c factor(hgfred([-3,3],[1/2],(1-x)/2));
847 (%i1) chebyshev_t(2,x);
849 (%o1) (- 4 (1 - x)) + 2 (1 - x) + 1
853 (%i3) factor(chebyshev_t(3,x));
856 (%i4) factor(hgfred([-3,3],[1/2],(1-x)/2));
861 @opencatbox{Categories:}
862 @category{Package orthopoly}
868 @deffn {Function} chebyshev_u (@var{n}, @var{x})
869 The Chebyshev polynomial of the second kind of degree @math{n},
870 m4_mathdot(<<<U_n(x)>>>,<<<chebyshev_u(n,x)>>>)
872 Reference: @urlaands{eqn 22.5.48,779}.
875 m4_math(<<<U_n(x)>>>,<<<chebyshev_u(n,x)>>>)
876 can be written in terms of a hypergeometric function:
879 <<<U_n(x) = (n+1)\; {_{2}F_{1}}\left(-n, n+2; {3\over 2}; {1-x\over 2}\right)>>>,
880 <<<chebyshev_u(n,x) = (n+1)*hypergeometric([-n,n+1],[3/2],(1-x)/2)>>>)
882 The polynomials can also be defined in terms of the sum
885 <<<U_n(x) = \sum_{r=0}^{\lfloor n/2 \rfloor} (-1)^r {n-r \choose r} (2x)^{n-2r}>>>,
886 <<<chebyshev_u(n,x) = sum((-1)^r*binomial(n-r,r)*(2*x)^(n-2*r), r, 0, floor(n/2))>>>)
888 or the Rodrigues formula
891 <<<U_n(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)(1-x^2)^n\right)>>>,
892 <<<@math{chebyshev_u(n,x) = 1/(k(n)*w(x))*diff(w(x)*(1-x^2)^n, x, n)}>>>
899 w(x) &= \sqrt{1-x^2} \cr
900 \kappa_n &= {(-2)^n\left({3\over 2}\right)_n \over n+1}
902 <<<@math{w(x) = sqrt(1-x^2)}
904 @math{k(n) = (-2)^n*pochhammer(3/2,n)/(n+1)}>>>).
909 @c expand(chebyshev_u(3,x));
910 @c expand(4*hgfred([-3,5],[3/2],(1-x)/2));
913 (%i1) chebyshev_u(2,x);
916 (%o1) 3 ((- ---------) + ---------- + 1)
921 (%i3) expand(chebyshev_u(3,x));
924 (%i4) expand(4*hgfred([-3,5],[3/2],(1-x)/2));
929 @opencatbox{Categories:}
930 @category{Package orthopoly}
935 @anchor{gen_laguerre}
936 @deffn {Function} gen_laguerre (@var{n}, @var{a}, @var{x})
937 The generalized Laguerre polynomial of degree @math{n},
938 m4_mathdot(<<<L_n^{(\alpha)}(x)>>>,<<<gen_laguerre(n,a,x)>>>)
940 These can be defined by
943 <<<L_n^{(\alpha)}(x) = {n+\alpha \choose n}\; {_1F_1}(-n; \alpha+1; x)>>>,
944 <<<gen_laguerre(n, a, x) = binomial(n+a,n)*hypergeometric([-n], [a+1], x)>>>)
946 The polynomials can also be defined by the sum
949 <<<L_n^{(\alpha)}(x) = \sum_{k=0}^n {(\alpha + k + 1)_{n-k} \over (n-k)! k!} (-x)^k>>>,
950 <<<@math{gen_laguerre(n, a, x) = sum(pochhammer(a+k+1,n-k)/((n-k)!*k!)*(-x)^k, k, 0, n)}>>>)
952 or the Rodrigues formula
955 <<<L_n^{(\alpha)}(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)x^n\right)>>>,
956 <<<@math{gen_laguerre(n, a, x) = 1/(k(n)*w(x))*diff(w(x)*x^n, x, n)}>>>
963 w(x) &= e^{-x}x^{\alpha} \cr
966 <<<@math{w(x) = %e^(-x)*x^a}
970 Reference: @urlaands{eqn 22.5.54,780}.
974 @c gen_laguerre(1,k,x);
975 @c gen_laguerre(2,k,x);
976 @c binomial(2+k,2)*hgfred([-2],[1+k],x);
979 (%i1) gen_laguerre(1,k,x);
981 (%o1) (k + 1) (1 - -----)
983 (%i2) gen_laguerre(2,k,x);
986 (k + 1) (k + 2) (--------------- - ----- + 1)
987 (k + 1) (k + 2) k + 1
988 (%o2) ---------------------------------------------
990 (%i3) binomial(2+k,2)*hgfred([-2],[1+k],x);
993 (k + 1) (k + 2) (--------------- - ----- + 1)
994 (k + 1) (k + 2) k + 1
995 (%o3) ---------------------------------------------
1000 @opencatbox{Categories:}
1001 @category{Package orthopoly}
1007 @deffn {Function} hermite (@var{n}, @var{x})
1008 The Hermite polynomial of degree @math{n},
1009 m4_mathdot(<<<H_n(x)>>>,<<<hermite(n,x)>>>)
1011 These polynomials may be defined by a hypergeometric function
1014 <<<H_n(x) = (2x)^n\; {_2F_0}\left(-{1\over 2} n, -{1\over 2}n+{1\over 2};;-{1\over x^2}\right)>>>,
1015 <<<hermite(n,x) = (2*x)^n * hypergeometric([-n/2, -n/2+1/2],[], -1/x^2)>>>)
1020 <<<H_n(x) = n! \sum_{k=0}^{\lfloor n/2 \rfloor} {(-1)^k(2x)^{n-2k} \over k! (n-2k)!}>>>,
1021 <<<hermite(n,x) = n!*sum((-1)^k*(2*x)^(n-2*k)/(k!*(n-2*k)!), k, 0, floor(n/2))>>>)
1023 or the Rodrigues formula
1026 <<<H_n(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)\right)>>>,
1027 <<<@math{hermite(n,x) = 1/(k(n)*w(x))*diff(w(x), x, n)}>>>
1034 w(x) &= e^{-{x^2/2}} \cr
1037 <<<@math{w(x) = %e(-x^2/2)}
1039 @math{k(n) = (-1)^n}>>>)
1041 Reference: @urlaands{eqn 22.5.55,780}.
1047 @c expand(hermite(4,x));
1048 @c expand((2*x)^4*hgfred([-2,-2+1/2],[],-1/x^2));
1049 @c expand(4!*sum((-1)^k*(2*x)^(4-2*k)/(k!*(4-2*k)!),k,0,floor(4/2)));
1055 (%o1) - 12 x (1 - ----)
1060 (%i3) expand(hermite(4,x));
1062 (%o3) 16 x - 48 x + 12
1063 (%i4) expand((2*x)^4*hgfred([-2,-2+1/2],[],-1/x^2));
1065 (%o4) 16 x - 48 x + 12
1066 (%i5) expand(4!*sum((-1)^k*(2*x)^(4-2*k)/(k!*(4-2*k)!),k,0,floor(4/2)));
1068 (%o5) 16 x - 48 x + 12
1071 @opencatbox{Categories:}
1072 @category{Package orthopoly}
1078 @deffn {Function} intervalp (@var{e})
1079 Return @code{true} if the input is an interval and return false if it isn't.
1081 @opencatbox{Categories:}
1082 @category{Package orthopoly}
1083 @category{Predicate functions}
1089 @deffn {Function} jacobi_p (@var{n}, @var{a}, @var{b}, @var{x})
1090 The Jacobi polynomial,
1091 m4_mathdot(<<<P_n^{(a,b)}(x)>>>, <<<jacobi_p(n,a,b,x)>>>)
1093 The Jacobi polynomials are actually defined for all
1094 @math{a} and @math{b}; however, the Jacobi polynomial
1095 weight @math{(1 - x)^a (1 + x)^b} isn't integrable
1097 m4_math(<<<a \le -1>>>, <<<a <= -1>>>)
1099 m4_mathdot(<<<b \le -1>>>, <<<b <= -1>>>)
1101 Reference: @urlaands{eqn 22.5.42,779}.
1103 The polynomial may be defined in terms of hypergeometric functions:
1106 <<<P_n^{(a,b)}(x) = {n+a\choose n} {_1F_2}\left(-n, n + a + b + 1; a+1; {1-x\over 2}\right)>>>,
1107 <<<jacobi_p(n,a,b,x) = binomial(n+a,n)*hypergeometric([-n,n+a+b+1],[a+1],(1-x)/2)>>>)
1109 or the Rodrigues formula
1112 <<<P_n^{(a, b)}(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)\left(1-x^2\right)^n\right)>>>,
1113 <<<@math{jacobi_p(n,a,b,x) = 1/(k(n)*w(x))*diff(w(x)*(1-x^2)^n, x, n)}>>>
1120 w(x) &= (1-x)^a(1-x)^b \cr
1121 \kappa_n &= (-2)^n n!
1123 <<<@math{w(x) = (1-x)^a*(1-x)^b}
1125 @math{k(n) = (-2)^n*n!}>>>)
1129 @c jacobi_p(0,a,b,x);
1130 @c jacobi_p(1,a,b,x);
1133 (%i1) jacobi_p(0,a,b,x);
1135 (%i2) jacobi_p(1,a,b,x);
1137 (%o2) (a + 1) (1 - -------------------)
1141 @opencatbox{Categories:}
1142 @category{Package orthopoly}
1148 @deffn {Function} laguerre (@var{n}, @var{x})
1149 The Laguerre polynomial,
1150 m4_math(<<<L_n(x)>>>,<<<laguerre(n,x)>>>)
1153 Reference: @urlaands{eqn 22.5.16, 778} and @urlaands{eqn 22.5.54, 780}.
1155 These are related to the generalized Laguerre polynomial by
1158 <<<L_n(x) = L_n^{(0)}(x)>>>,
1159 <<<laguerre(n,x) = gen_laguerre(n,0,x)>>>)
1161 The polynomials are given by the sum
1164 <<<L_n(x) = \sum_{k=0}^{n} {(-1)^k\over k!}{n \choose k} x^k>>>,
1165 <<<laguerre(n,x) = sum((-1)^k/k!*binomial(n,k)*x^k,k,0,n)>>>)
1171 @c gen_laguerre(2,0,x);
1172 @c sum((-1)^k/k!*binomial(2,k)*x^k,k,0,2);
1175 (%i1) laguerre(1,x);
1177 (%i2) laguerre(2,x);
1182 (%i3) gen_laguerre(2,0,x);
1187 (%i4) sum((-1)^k/k!*binomial(2,k)*x^k,k,0,2);
1194 @opencatbox{Categories:}
1195 @category{Package orthopoly}
1201 @deffn {Function} legendre_p (@var{n}, @var{x})
1202 The Legendre polynomial of the first kind,
1203 m4_mathcomma(P_n(x),legendre(n,x))
1206 Reference: @urlaands{eqn 22.5.50, 779} and @urlaands{eqn 22.5.51, 779}.
1208 The Legendre polynomial is related to the Jacobi polynomials by
1211 <<<P_n(x) = P_n^{(0,0)}(x)>>>,
1212 <<<legendre_p(n,x) = jacobi_p(n,0,0,x)>>>)
1214 or the Rodrigues formula
1217 <<<P_n(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)\left(1-x^2\right)^n\right)>>>,
1218 <<<@math{legendre_p(n,x) = 1/(k(n)*w(x))*diff(w(x)*(1-x^2)^n, x, n)}>>>
1226 \kappa_n &= (-2)^n n!
1230 @math{k(n) = (-2)^n*n!}>>>)
1237 @c expand(legendre_p(3,x));
1238 @c expand(jacobi_p(3,0,0,x));
1241 (%i1) legendre_p(1,x);
1243 (%i2) legendre_p(2,x);
1246 (%o2) (- 3 (1 - x)) + ---------- + 1
1253 (%i4) expand(legendre_p(3,x));
1258 (%i5) expand(jacobi_p(3,0,0,x));
1264 @opencatbox{Categories:}
1265 @category{Package orthopoly}
1271 @deffn {Function} legendre_q (@var{n}, @var{x})
1272 The Legendre function of the second kind,
1273 m4_math(<<<Q_n(x)>>>, <<<legendre_q(n,x)>>>)
1276 Reference: Abramowitz and Stegun, equations 8.5.3 and 8.1.8.
1278 These are related to
1279 m4_math(<<<Q_n^m(x)>>>,<<<assoc_legendre_q(n,m,x)>>>)
1283 <<<Q_n(x) = Q_n^0(x)>>>,
1284 <<<legendre_q(n,x) = assoc_legendre_q(n,0,x)>>>)
1290 @c assoc_legendre_q(1,0,x);
1293 (%i1) legendre_q(0,x);
1299 (%i2) legendre_q(1,x);
1303 (%o2)/R/ ------------------
1305 (%i3) assoc_legendre_q(1,0,x);
1309 (%o3)/R/ ------------------
1313 @opencatbox{Categories:}
1314 @category{Package orthopoly}
1319 @anchor{orthopoly_recur}
1320 @deffn {Function} orthopoly_recur (@var{f}, @var{args})
1321 Returns a recursion relation for the orthogonal function family
1322 @var{f} with arguments @var{args}. The recursion is with
1323 respect to the polynomial degree.
1326 @c orthopoly_recur (legendre_p, [n, x]);
1329 (%i1) orthopoly_recur (legendre_p, [n, x]);
1330 (2 n + 1) P (x) x - n P (x)
1332 (%o1) P (x) = -------------------------------
1336 The second argument to @code{orthopoly_recur} must be a list with the
1337 correct number of arguments for the function @var{f}; if it isn't,
1338 Maxima signals an error.
1341 @c orthopoly_recur (jacobi_p, [n, x]);
1344 (%i1) orthopoly_recur (jacobi_p, [n, x]);
1346 Function jacobi_p needs 4 arguments, instead it received 2
1347 -- an error. Quitting. To debug this try debugmode(true);
1350 Additionally, when @var{f} isn't the name of one of the
1351 families of orthogonal polynomials, an error is signalled.
1354 @c orthopoly_recur (foo, [n, x]);
1357 (%i1) orthopoly_recur (foo, [n, x]);
1359 A recursion relation for foo isn't known to Maxima
1360 -- an error. Quitting. To debug this try debugmode(true);
1363 @opencatbox{Categories:}
1364 @category{Package orthopoly}
1369 @defvr {Variable} orthopoly_returns_intervals
1370 Default value: @code{true}
1372 When @code{orthopoly_returns_intervals} is @code{true}, floating point results are returned in
1373 the form @code{interval (@var{c}, @var{r})}, where @var{c} is the center of an interval
1374 and @var{r} is its radius. The center can be a complex number; in that
1375 case, the interval is a disk in the complex plane.
1377 @opencatbox{Categories:}
1378 @category{Package orthopoly}
1383 @anchor{orthopoly_weight}
1384 @deffn {Function} orthopoly_weight (@var{f}, @var{args})
1386 Returns a three element list; the first element is
1387 the formula of the weight for the orthogonal polynomial family
1388 @var{f} with arguments given by the list @var{args}; the
1389 second and third elements give the lower and upper endpoints
1390 of the interval of orthogonality. For example,
1393 @c w : orthopoly_weight (hermite, [n, x]);
1394 @c integrate (w[1] * hermite (3, x) * hermite (2, x), x, w[2], w[3]);
1397 (%i1) w : orthopoly_weight (hermite, [n, x]);
1400 (%o1) [%e , - inf, inf]
1401 (%i2) integrate(w[1]*hermite(3, x)*hermite(2, x), x, w[2], w[3]);
1405 The main variable of @var{f} must be a symbol; if it isn't, Maxima
1408 @opencatbox{Categories:}
1409 @category{Package orthopoly}
1415 @deffn {Function} pochhammer (@var{x}, @var{n})
1416 The Pochhammer symbol,
1417 m4_mathdot(<<<(x)_n>>>, <<<pochhammer(x,n)>>>)
1418 (See @urlaands{eqn 6.1.22, 256} and @urldlmf{5.2.iii}).
1421 integers @var{n} with @code{@var{n} <= pochhammer_max_index}, the
1423 m4_math(<<<(x)_n>>>, <<<pochhammer(x, n)>>>)
1426 m4_math(<<<x(x+1)(x+2)\cdots(x+n-1)>>>, <<<x (x + 1) (x + 2) ... (x +
1429 m4_math(<<<n > 0>>>, n > 0)
1431 to 1 when @math{n = 0}.
1432 For negative @math{n},
1433 m4_math(<<<(x)_n>>>, <<<pochhammer (x, n)>>>)
1436 m4_math(<<<(-1)^n/(1-x)_{-n}.>>>, <<<(-1)^n / pochhammer (1 - x, -n).>>>)
1440 @c pochhammer (x, 3);
1441 @c pochhammer (x, -3);
1444 (%i1) pochhammer (x, 3);
1445 (%o1) x (x + 1) (x + 2)
1446 (%i2) pochhammer (x, -3);
1448 (%o2) - -----------------------
1449 (1 - x) (2 - x) (3 - x)
1452 To convert a Pochhammer symbol into a quotient of gamma functions,
1453 (see @urlaands{eqn 6.1.22, 256}) use @code{makegamma}; for example
1456 @c makegamma (pochhammer (x, n));
1459 (%i1) makegamma (pochhammer (x, n));
1465 When @var{n} exceeds @code{pochhammer_max_index} or when @var{n}
1466 is symbolic, @code{pochhammer} returns a noun form.
1469 @c pochhammer (x, n);
1472 (%i1) pochhammer (x, n);
1477 @opencatbox{Categories:}
1478 @category{Package orthopoly}
1479 @category{Gamma and factorial functions}
1484 @defvr {Variable} pochhammer_max_index
1487 @code{pochhammer (@var{n}, @var{x})} expands to a product if and only if
1488 @code{@var{n} <= pochhammer_max_index}.
1493 @c pochhammer (x, 3), pochhammer_max_index : 3;
1494 @c pochhammer (x, 4), pochhammer_max_index : 3;
1497 (%i1) pochhammer (x, 3), pochhammer_max_index : 3;
1498 (%o1) x (x + 1) (x + 2)
1499 (%i2) pochhammer (x, 4), pochhammer_max_index : 3;
1504 Reference: @urlaands{eqn 6.1.16,256}.
1506 @opencatbox{Categories:}
1507 @category{Package orthopoly}
1508 @category{Gamma and factorial functions}
1513 @anchor{spherical_bessel_j}
1514 @deffn {Function} spherical_bessel_j (@var{n}, @var{x})
1515 The spherical Bessel function of the first kind,
1516 m4_math(<<<j_n(x).>>>, <<<spherical_bessel_j(n,x).>>>)
1518 Reference: @urlaands{eqn 10.1.8, 437} and @urlaands{eqn 10.1.15, 439}.
1520 It is related to the Bessel function by
1523 <<<j_n(x) = \sqrt{\pi\over 2x} J_{n+1/2}(x)>>>,
1524 <<<spherical_bessel_j(n,x) = sqrt(%pi/(2*x))*bessel_j(n+1/2,x)>>>)
1528 @c spherical_bessel_j(1,x);
1529 @c spherical_bessel_j(2,x);
1531 @c expand(sqrt(%pi/(2*x))*bessel_j(2+1/2,x)),besselexpand:true;
1534 (%i1) spherical_bessel_j(1,x);
1538 (%o1) ---------------
1540 (%i2) spherical_bessel_j(2,x);
1542 (- (1 - --) sin(x)) - --------
1545 (%o2) ------------------------------
1548 sin(x) 3 sin(x) 3 cos(x)
1549 (%o3) (- ------) + -------- - --------
1552 (%i4) expand(sqrt(%pi/(2*x))*bessel_j(2+1/2,x)),besselexpand:true;
1553 sin(x) 3 sin(x) 3 cos(x)
1554 (%o4) (- ------) + -------- - --------
1558 @opencatbox{Categories:}
1559 @category{Package orthopoly}
1560 @category{Bessel functions}
1565 @anchor{spherical_bessel_y}
1566 @deffn {Function} spherical_bessel_y (@var{n}, @var{x})
1567 The spherical Bessel function of the second kind,
1568 m4_math(<<<y_n(x).>>>, <<<<spherical_bessel_y(n,x).>>>)
1570 Reference: @urlaands{eqn 10.1.9, 437} and @urlaands{eqn 10.1.15, 439}.
1572 It is related to the Bessel function by
1575 <<<y_n(x) = \sqrt{\pi\over 2x} Y_{n+1/2}(x)>>>,
1576 <<<spherical_bessel_y(n,x) = sqrt(%pi/(2*x))*bessel_y(n+1/2,x)>>>)
1579 @c spherical_bessel_y(1,x);
1580 @c spherical_bessel_y(2,x);
1582 @c expand(sqrt(%pi/(2*x))*bessel_y(2+1/2,x)),besselexpand:true;
1585 (%i1) spherical_bessel_y(1,x);
1589 (%o1) -------------------
1591 (%i2) spherical_bessel_y(2,x);
1593 -------- - (1 - --) cos(x)
1596 (%o2) - --------------------------
1599 3 sin(x) cos(x) 3 cos(x)
1600 (%o3) (- --------) + ------ - --------
1603 (%i4) expand(sqrt(%pi/(2*x))*bessel_y(2+1/2,x)),besselexpand:true;
1604 3 sin(x) cos(x) 3 cos(x)
1605 (%o4) (- --------) + ------ - --------
1609 @opencatbox{Categories:}
1610 @category{Package orthopoly}
1611 @category{Bessel functions}
1616 @anchor{spherical_hankel1}
1617 @deffn {Function} spherical_hankel1 (@var{n}, @var{x})
1618 The spherical Hankel function of the
1620 m4_math(<<<h_n^{(1)}(x).>>>, <<<spherical_hankel1(n,x).>>>)
1622 Reference: @urlaands{eqn 10.1.36,439}.
1627 <<<h_n^{(1)}(x) = j_n(x) + iy_n(x)>>>,
1628 <<<spherical_hankel1(n,x) = spherical_bessel_j(n,x) + %i*spherical_bessel_y(n,x)>>>)
1630 @opencatbox{Categories:}
1631 @category{Package orthopoly}
1632 @category{Bessel functions}
1637 @anchor{spherical_hankel2}
1638 @deffn {Function} spherical_hankel2 (@var{n}, @var{x})
1639 The spherical Hankel function of the
1641 m4_math(<<<h_n^{(2)}(x).>>>, <<<spherical_hankel2(n,x).>>>)
1643 Reference: @urlaands{eqn 10.1.17,439}.
1648 <<<h_n^{(2)}(x) = j_n(x) + iy_n(x)>>>,
1649 <<<spherical_hankel2(n,x) = spherical_bessel_j(n,x) - %i*spherical_bessel_y(n,x)>>>)
1651 @opencatbox{Categories:}
1652 @category{Package orthopoly}
1653 @category{Bessel functions}
1658 @anchor{spherical_harmonic}
1659 @deffn {Function} spherical_harmonic (@var{n}, @var{m}, @var{theta}, @var{phi})
1660 The spherical harmonic function,
1661 m4_mathdot(<<<Y_n^m(\theta, \phi)>>>, <<<spherical_harmonic(n,m,theta,phi)>>>)
1663 Spherical harmonics satisfy the angular part of Laplace's equation in spherical coordinates.
1665 For integers @math{n} and @math{m} such
1667 m4_math(<<<n \geq |m|>>>,<<<n <= abs(m)>>>)
1670 m4_mathdot(<<<\theta \in [0, \pi]>>>,<<<theta in [0, %pi]>>>)
1672 spherical harmonic function can be defined by
1675 <<<Y_n^m(\theta, \phi) = (-1)^m \sqrt{{2n+1\over 4\pi} {(n-m)!\over (n+m)!}} P_n^m(\cos\theta) e^{im\phi}>>>,
1676 <<<@math{spherical_harmonic(n, m, theta, phi) := (-1)^m * (((n-m)!*(2*n+1))/(4*%pi*(n+m)!))^(1/2)* exp(%i*m*phi)*assoc_legendre_p(n,m,cos(theta))}>>>)
1680 m4_mathcomma(<<<n < |m|>>>, <<<n < abs(m)>>>)
1682 spherical harmonic function vanishes.
1684 The factor @math{(-1)^m}, frequently used in Quantum mechanics, is
1685 called the @url{https://en.wikipedia.org/wiki/Spherical_harmonics#Condon%E2%80%93Shortley_phase, Condon-Shortely phase}.
1686 Some references, including @emph{NIST Digital Library of Mathematical Functions} omit
1687 this factor; see @url{http://dlmf.nist.gov/14.30.E1}.
1689 Reference: Merzbacher 9.64.
1693 @c spherical_harmonic(1,0,theta,phi);
1694 @c spherical_harmonic(1,1,theta,phi);
1695 @c spherical_harmonic(1,-1,theta,phi);
1696 @c spherical_harmonic(2,0,theta,phi);
1700 (%i1) spherical_harmonic(1,0,theta,phi);
1702 (%o1) ------------------
1704 (%i2) spherical_harmonic(1,1,theta,phi);
1706 sqrt(3) %e sin(theta)
1707 (%o2) ---------------------------
1710 (%i3) spherical_harmonic(1,-1,theta,phi);
1712 sqrt(3) %e sin(theta)
1713 (%o3) - -----------------------------
1716 (%i4) spherical_harmonic(2,0,theta,phi);
1719 sqrt(5) ((- 3 (1 - cos(theta))) + ------------------- + 1)
1721 (%o4) ----------------------------------------------------------
1725 sqrt(5) (3 cos (theta) - 1)
1726 (%o5) ---------------------------
1730 @opencatbox{Categories:}
1731 @category{Package orthopoly}
1737 @deffn {Function} unit_step (@var{x})
1738 The left-continuous unit step function; thus
1739 @code{unit_step (@var{x})} vanishes for @code{@var{x} <= 0} and equals
1740 1 for @code{@var{x} > 0}.
1742 If you want a unit step function that takes on the value 1/2 at zero,
1745 @opencatbox{Categories:}
1746 @category{Package orthopoly}
1747 @category{Mathematical functions}
1752 @anchor{ultraspherical}
1753 @deffn {Function} ultraspherical (@var{n}, @var{a}, @var{x})
1754 The ultraspherical polynomial,
1755 m4_math(<<<C_n^{(a)}(x)>>>, <<<ultraspherical(n,a,x)>>>)
1756 (also known as the Gegenbauer polynomial).
1758 Reference: @urlaands{eqn 22.5.46,779}.
1760 These polynomials can be given in terms of Jacobi polynomials:
1763 <<<C_n^{(\alpha)}(x) = {\Gamma\left(\alpha + {1\over 2}\right) \over \Gamma(2\alpha)}
1764 {\Gamma(n+2\alpha) \over \Gamma\left(n+\alpha + {1\over 2}\right)}
1765 P_n^{(\alpha-1/2, \alpha-1/2)}(x)>>>,
1766 <<<ultraspherical(n,a,x) = gamma(a+1/2)/gamma(2*a)*gamma(n+2*a)/gamma(n+a+1/2)*jacobi_p(n,a-1/2,a-1/2,x)>>>)
1771 <<<C_n^{(\alpha)}(x) = \sum_{k=0}^{\lfloor n/2 \rfloor} {(-1)^k (\alpha)_{n-k} \over k! (n-2k)!}(2x)^{n-2k}>>>,
1772 <<<@math{ultraspherical(n,a,x) = sum((-1)^k*pochhammer(a,n-k)/k!/(n-2*k)!*(2*x)^(n-2*k),k, 0, floor(n/2))}>>>)
1774 or the Rodrigues formula
1777 <<<C_n^{(\alpha)}(x) = {1\over \kappa_n w(x)} {d^n\over dx^n}\left(w(x)\left(1-x^2\right)^n\right)>>>,
1778 <<<@math{ultraspherical(n,x) = 1/(k(n)*w(x))*diff(w(x)*(1-x^2)^n, x, n)}>>>
1785 w(x) &= \left(1-x^2\right)^{\alpha-{1\over 2}} \cr
1786 \kappa_n &= {(-2)^n\left(\alpha + {1\over 2}\right)_n n!\over (2\alpha)_n} \cr
1788 <<<@math{w(x) = (1-x^2)^(a-1/2)}
1790 @math{k(n) = (-2)^n*pochhammer(a+1/2,n)*n!/pochhammer(2*a,n)}>>>)
1794 @c ultraspherical(1,a,x);
1796 @c factor(ultraspherical(2,a,x));
1799 (%i1) ultraspherical(1,a,x);
1801 (%o1) 2 a (1 - -----------------)
1807 (%i3) factor(ultraspherical(2,a,x));
1809 (%o3) a (2 a x + 2 x - 1)
1812 @opencatbox{Categories:}
1813 @category{Package orthopoly}