## `orthpoly::gegenbauer` -- the Gegenbauer (ultraspherical) polynomials

#### Introduction

`orthpoly::gegenbauer``(n,a,x)` computes the value of the n-th degree Gegenbauer polynomial with parameter a at the point x.

#### Call(s)

`orthpoly::gegenbauer(n, a, x)`

#### Parameters

`n` | - | a nonnegative integer: the degree of the polynomial.
`a` | - | an arithmetical expression.
`x` | - | an indeterminate or an arithmetical expression. An indeterminate is either an identifier (of domain type `DOM_IDENT`) or an indexed identifier (of type `"_index"`).

#### Returns

If `x` is an indeterminate, then a polynomial of domain type `DOM_POLY` is returned. If `x` is an arithmetical expression, then the value of the Gegenbauer polynomial at this point is returned as an arithmetical expression. If `n` is not a nonnegative integer, then `orthpoly::gegenbauer` returns itself symbolically.

#### Related Functions

`orthpoly::chebyshev2`, `orthpoly::legendre`

#### Details

- Evaluation for real floating point values x from the interval [-1.0,1.0] is numerically stable. Cf. example 2.

#### Example 1

Polynomials of domain type `DOM_POLY` are returned, if identifiers or indexed identifiers are specified:

    >> orthpoly::gegenbauer(2, a, x)

                                         2   2
                          poly((2 a + 2 a ) x  - a, [x])

    >> orthpoly::gegenbauer(3, 2, x[1])

                                     3
                         poly(32 x[1]  - 12 x[1], [x[1]])

However, using arithmetical expressions as input the ``values'' of these polynomials are returned:

    >> orthpoly::gegenbauer(2, a, 6*x)

                                    2           2  2
                              72 a x  - a + 72 a  x

    >> orthpoly::gegenbauer(3, 2, x[1] + 2)

           8 (x[1] + 2) (3 (x[1] + 2) (4 x[1] + 8) - 2)   20 x[1]
           -------------------------------------------- - ------- - 40/3
                                3                            3

``Arithmetical expressions'' include numbers:

    >> orthpoly::gegenbauer(2, a, sqrt(2)),
       orthpoly::gegenbauer(3, 0.4, 8 + I),
       orthpoly::gegenbauer(1000, -1/3, 0.3)

                          2
                 3 a + 4 a , 865.536 + 341.152 I, 0.00006046127974

If no integer degree is specified, then `orthpoly::gegenbauer` returns itself symbolically:

    >> orthpoly::gegenbauer(n, a, x), orthpoly::gegenbauer(1/2, 2, x)

          orthpoly::gegenbauer(n, a, x), orthpoly::gegenbauer(1/2, 2, x)

#### Example 2

If a floating point value is desired, then a direct call such as

    >> orthpoly::gegenbauer(200, 4, 0.3)

                                    165549.7263

is appropriate and yields a correct result. One should not evaluate the symbolic polynomial at a floating point value, because this may be numerically unstable:

    >> G200 := orthpoly::gegenbauer(200, 4, x):

    >> DIGITS := 10: evalp(G200, x = 0.3)

                                  -1.537729446e11

This result is caused by numerical round-off. Also with increased `DIGITS` only a few leading digits are correct:

    >> DIGITS := 20: evalp(G200, x = 0.3)

                               165541.53415992590886

    >> delete DIGITS, G200:

#### Background

- The Gegenbauer polynomials are given by the recursion formula

      G(n,a,x)= 2*(n-1+a)/n*x*G(n-1,a,x)+(n-2+2*a)/n*G(n-2,a,x)

  with G(0,a,x)=1, G(1,a,x)=2*a*x.
- For fixed real a>-1/2 these polynomials are orthogonal on the interval [-1,1] with respect to the weight function w(x)=(1-x^2)^(a-1/2)
- G(n,1/2,x) coincides with the Legendre polynomial P(n,x).
- G(n,1,x) coincides with the Chebyshev polynomial U(n,x) of the second kind.
- The polynomials G(n,0,x) are trivial.

#### Changes

- Indexed identifiers are now regarded as indeterminates. Arbitrary expressions are now accepted for the parameter a. Non-integer degrees n are now accepted, leading to an unevaluated function call. Efficiency was improved.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000