Next: partitions() Up: Mathematical Macros Help File Previous: neldermead()   Contents

# orthopoly()

Usage:
 ```orthopoly(x, n, [,polycode [,parameters]]), x a REAL vector with no MISSING values, n >= 0 an integer, polycode one of p, j, g, t, u,l, h and d, parameters a REAL scalar or vector ```

Keywords: orthogonal polynomials
```orthopoly() is a macro which computes values of several of the standard
orthogonal polynomials.

P <- orthopoly(x, n), where x is a REAL vector with no MISSING values
and n > 0 is an integer, computes the matrix
P = hconcat(P0(x), P1(x), ..., Pn(x))
where Pj(x) = vector(Pj(x[1], Pj(x[2]), ...) and Pj is the j-th
Legendre polynomial.  When x is a scalar, P is vector(P0(x),..., Pn(x)).

P <- orthopoly(x, n, polycode [,parameters]) does the same except
the type of polynomials is determined by polycode, an unquoted letter
which must be one of p, j, g, t, T, u, U, l, h and d.

parameters is required when polycode is j, G, or l, is optional when
polycode is d and should not be an argument otherwise.

The following table summarizes the options
Polynomial type      polycode  parameters
Legendre                p       none
Jacobi                  j       vector(alpha,beta)
Gegenbauer              g       alpha
Chebyshev 1             t       none
Shifted Chebyshev 1     T       none
Chebyshev 2             u       none
Shifted Chebyshev 2     U       none
Laguerre                l       alpha
Hermite                 h       none
Discrete                d       vector w of with w[i] > 0; default
is w = rep(1,length(x)).

The discrete polynomials are defined by both vector x and the vector of
weights.  They are orthogonal on the discrete set x[1], ..., x[m],
where m = length(x).  That is, they satisfy
w[1]*Pj(x[1])*Pk(x[1]) + w[2]*Pj(x[2])*Pk(x[2]) + . . . +
w[m]*Pj(x[m])*Pk(x[m]) = 0, j != k

All but the discrete polynomials are computed from the recurrence
relations in Table 22.7 of Handbook of Mathematical Functions by
Abramowitz and Stegun and satisfy the normalizations in Table 22.4.
The discrete polynomials are also computed by recursion and are
standardized so that sum(wj*poly(x[j])^2)/sum(wj) = 1
```

Gary Oehlert 2003-01-15