Function: chebyshevU (n, x)

Numerically evaluate Chebyshev polynomials of the second kind.

Evaluates the Chebyshev polynomial of the second kind of degree n at the point x, in double precision. Both inputs can be arrays but their sizes must be either the same or scalar.

Example:

chebyshevU (18, 0.9)
  ⇒ ans = 1.7315

Using this function may be preferable to evaluating the polynomial in monomial form because the latter can give poor accuracy due to numerical instability. For example, consider evaluating the Chebyshev polynomial of degree 10 at a point by evaluating in the monomial basis:

syms n x
C = chebyshevU (10, x)
  ⇒ C = (sym)
            10         8         6        4       2
      1024⋅x   - 2304⋅x  + 1792⋅x  - 560⋅x  + 60⋅x  - 1
value1 = polyval (sym2poly (C), 0.96105)
  ⇒ value1 = 0.2219

Instead, we could use the present function:

value2 = chebyshevU (10, 0.96105)
  ⇒ value2 = 0.2219

Both results look similar but value2 is more accurate—they differ by significantly more than machine precision:

value1 - value2
  ⇒ 1.0586e-13

Note this function may be slow for large numbers of inputs. This is because it is not a native double-precision implementation but rather the numerical evaluation of the Python mpmath function chebyshevu.

Developer note: would likely be faster if implemented directly using the three-term recurrence.

See also: @double/chebyshevT, @sym/chebychevU.

Package: symbolic