Function: laguerreL (n, x)

Evaluate Laguerre polynomials.

Compute the value of the Laguerre polynomial of order n for each element of x. For example, the Laguerre polynomial of order 14 evaluated at the point 6 is

laguerreL (14, 6)
  ⇒ 0.9765

This implementation uses a three-term recurrence directly on the values of x. The result is numerically stable, as opposed to evaluating the polynomial using the monomial coefficients. For example, we can compare the above result to a symbolic construction:

syms x
L = laguerreL (14, x);
exact = subs (L, x, 6)
  ⇒ exact = (sym)
      34213
      ─────
      35035

If we extract the monomial coefficients and numerically evaluate the polynomial at a point, the result is rather poor:

coeffs = sym2poly (L);
polyval (coeffs, 6)
  ⇒ 0.9765
err = ans - double (exact);
num2str (err, '%.3g')
  ⇒ -1.68e-11

So please don’t do that! The numerical laguerreL function does much better:

err = laguerreL (14, 6) - double (exact)
  ⇒ err = 9.9920e-16

See also: @sym/laguerreL.

Package: symbolic