poly

Evaluate polynomial A(x) = a0 + a1x + a2x2 + a3x3; ...

Uses Horner's rule A(x) = a0 + x(a1 + x(a2 + x(a3 + ...)))

  1. Unqual!(CommonType!(T1, T2)) poly(T1 x, T2[] A)
    @trusted pure nothrow @nogc
    Unqual!(CommonType!(T1, T2))
    poly
    (
    T1
    T2
    )
    (
    T1 x
    ,
    in T2[] A
    )
  2. Unqual!(CommonType!(T1, T2)) poly(T1 x, T2[N] A)

Parameters

x T1

the value to evaluate.

A T2[]

array of coefficients a0, a1, etc.

Examples

real x = 3.1L;
static real[] pp = [56.1L, 32.7L, 6];

assert(poly(x, pp) == (56.1L + (32.7L + 6.0L * x) * x));

Meta