This class's implementation is split into two parts: the parent class ChebyshevParam<T>, which manages the function's parameters, and this class, which handles how the function is evaluated. Thus, be sure to also consult ChebyshevParam<T> for the full interface of this function.
Chebyshev polynomials are a special type of ultraspheric polynomials
that are useful in such contexts as numerical analysis and circuit
design. They form an orthogobnal set.
A (type I) Chebyshev polynomial, T_n, is generated via the
equation:
A common use of Chebyshev polynomials is in approximating
functions. In particular, any function that is approximated by
a power series,
Approximating a function with Chebyshev polynomials has some
important advantages. For one, if the function is well approximated
by a converging power series, one can obtain an equally accurate
estimate using fewer terms of the corresponding Chebyshev series.
More important, though, is the property over the interval [-1, 1],
each polynomial has a domain of [-1, 1]; thus, the series is nicely
bounded. And because of this bounded property, approximations
calculated from a Chebyshev series are less susceptible to machine
rounding errors than the equivalent power series.
With a simple change of variable, it is possible to approximate a
continuous function over any restricted interval using a
Chebyshev series. This documention refers to this interval as the
Chebyshev interval (set with the
setInterval() function). The
other important input parameters, of course, include the
coefficients of the polynomials.
Like all Functions, the Chebyshev series is evaluated via the
function operator, operator(). If the input value is
within the range set by
setInterval(), it is
transformed to the range [-1, 1] via,
The derivative of a Chebyshev series with respect to the independent
variable (i.e. the argument x) is easily calculated analytically
and can be expressed as another Chebyshev series; this is what the
derivative() function returns. However, the more general way to
obtain derivatives is via the AutoDiff
templated type.
The next example illustrates how to use the
AutoDiff class to simultaneously
calculate derivatives. Here, we replace the Double type with
AutoDiff
create an n-th order Chebyshev polynomial with the coefficients
equal to zero. The bounded domain is [T(-1), T(1)]. The
OutOfDomainMode is CONSTANT, and the default value is T(0).
create a zero-th order Chebyshev polynomical with the first coefficient
equal to one.
min is the minimum value of its Chebyshev interval, and
max is the maximum value.
mode sets the behavior of the function outside the Chebyshev interval
(see setOutOfIntervalMode() and OutOfIntervalMode enumeration
definition for details).
defval is the value returned when the function is evaluated outside
the Chebyshev interval and mode=CONSTANT.
create a fully specified Chebyshev polynomial.
coeffs holds the coefficients of the Chebyshev polynomial (see
setCoefficients() for details).
min is the minimum value of its canonical range, and
max is the maximum value.
mode sets the behavior of the function outside the Chebyshev interval
(see setOutOfIntervalMode() and OutOfIntervalMode enumeration
definition for details).
defval is the value returned when the function is evaluated outside
the canonical range and mode=CONSTANT.
create a fully specified Chebyshev polynomial.
config is a record that contains the non-coefficient data
that configures this class.
The fields recognized by this class are those documented for the
ChebyshevPara::setMode()
function.
create a deep copy of another Chebyshev polynomial
make this instance a (deep) copy of another Chebyshev polynomial
Destructor
Return the Chebyshev polynomial which is the derivative of this one
(with respect to the argument x).
Create a new copy of this object. The caller is responsible
for deleting the pointer.
About Chebyshev Polynomials
T_n(x) = cos n(arccos x)
Through clever use of trigometric identities, one can express T_n
as a real polynomial expression of the form
n
T_n(x) = SUM C_i t^i
i=0
The low order polynomials look like this:
T_0 = 1
T_1 = x
T_2 = 2x^2 - 1
T_3 = 4x^3 - 3x
T_4 = 8x^4 - 8x^2 + 1
T_5 = 16x^5 - 20x^3 + 5x
Higher order polynomials satisfy the recurrance relation,
T_(n+1) = 2xT_(n) - T_(n-1).
f(x) ~ SUM P_i x^i,
over the interval [-1, 1] can be approximated by a linear
combination of Chebyshev polynomials:
f(x) ~ SUM C_i T_i(x),
where C_i is the set of so-called Chebyshev coefficients.
Using the Chebyshev Function class
y = x - (min + max)/2) / ((max - min)/2)
The series is then evaluated with the coefficients set either at
construction or via setCoefficients(). The value that is returned
when the input value is outside the Chebyshev interval depends on
the out-of-interval mode (set via
setOutOfIntervalMode()). The
default mode is to return a default value which can be set via
setDefault(). The supported
modes are identified by the
enumeration OutOfIntervalMode; see the
documentation for ChebyshevParam
for a detailed description of these modes. In practice, though, it is
expected that this class will be configured for the interval of interest.
Example
In this example, a 2nd order Chebyshev polynomial series is
created.
// set coeffs to desired values
Vector<Double> coeffs(3, 1);
// configure the function
Chebyshev<Double> cheb;
cheb.setInterval(-0.8, 7.2);
cheb.setDefault(1.0);
cheb.setCoefficients(coeffs);
// evaluate the function as necessary
Double z = cheb(-0.5); // -0.5 is within range, z = 0.78625
z = cheb(4.2); // 4.2 is within range, z = 0.375
z = cheb(-3); // -3 is out of the interval, z = 1
Chebyshev<AutoDiffA<Double> > cheb;
cheb.setDefault(AutoDiffA<Double>(1));
cheb.setInterval(AutoDiffA<Double>(-0.8), AutoDiffA<Double>(7.2));
// we'll track derivatives with respect to x and each of our
// coefficients; for a second-order series, this makes 4
// derivatives total. x will be the first variable; the
// coefficients will the 2nd-4th variables
cheb.setCoefficient(0, AutoDiffA<Double>(3.1, 4, 1)); // c0 = 3.1
cheb.setCoefficient(1, AutoDiffA<Double>(2.4, 4, 2)); // c1 = 2.4
cheb.setCoefficient(2, AutoDiffA<Double>(0.5, 4, 3)); // c2 = 0.5
// now evaluate the function
AutoDiffA<Double> x(1.2, 4, 0); // x = 1.2
AutoDiffA<Double> y = cheb(x); // y = 1.65
Double dydx = y.derivative(0); // dy/dx = 0.35
Double dydc1 = y.derivative(2); // dy/dc1 = -0.5
Motivation
This class was created to support systematic errors in the simulator tool.
It can be used by Jones matrix classes to vary gains in a predictable way,
mimicing natural processes of the atmosphere or instrumental effects.
Template Type Argument Requirements (T)
Thrown Exceptions
To Do
Member Description
Chebyshev() : ChebyshevParamModeImpl<T>()
create a zero-th order Chebyshev polynomial with the first coefficient
equal to zero. The bounded domain is [T(-1), T(1)]. The
OutOfDomainMode is CONSTANT, and the default value is T(0).
explicit Chebyshev(const uInt n) : n<T>(n)
Chebyshev(const T &min, const T &max, const typename max<T>:: OutOfIntervalMode mode=CONSTANT, const T &defval=T(0)) : ChebyshevParamModeImpl<T>(min, max, mode, defval)
Chebyshev(const Vector<T> &coeffs, const T &min, const T &max, const typename ChebyshevParam<T>:: OutOfIntervalMode mode=CONSTANT, const T &defval=T(0)) : ChebyshevParamModeImpl<T>(coeffs, min, max, mode, defval)
Chebyshev(uInt order, const RecordInterface& mode) : ChebyshevParamModeImpl<T>(order, mode)
Chebyshev(const Vector<T> &coeffs, const RecordInterface& mode) : Recorderface<T>(coeffs, mode)
Chebyshev(const Chebyshev &other) : ChebyshevParamModeImpl<T>(other)
Chebyshev<T> &operator=(const Chebyshev<T> &other)
virtual ~Chebyshev()
virtual T eval(const typename FunctionTraits<T>::ArgType *x) const
Evaluate the Chebyshev at x.
Chebyshev<T> derivative() const
virtual Function<T> *clone() const