private static function horner($x, $c) {
    if (count($c) == 0)
      throw new InvalidArgumentException('No coefficients were provided');

    $i = count($c) - 1;
    $y = $c[$i];
    while ($i > 0) {
      $i--;
      $y = $y * $x + $c[$i];
    }

    return $y;
  }
private static function horner($x, $c) {
    if (count($c) == 0)
      throw new InvalidArgumentException('No coefficients were provided');

    $i = count($c) - 1;
    $y = $c[$i];
    while ($i > 0) {
      $i--;
      $y = $y * $x + $c[$i];
    }

    return $y;
  }
private static function horner ( $ x , $ c ) { if ( count ( $ c ) == 0 ) throw new InvalidArgumentException ( 'No coefficients were provided' ) ; $ i = count ( $ c ) - 1 ; $ y = $ c [ $ i ] ; while ( $ i > 0 ) { $ i -- ; $ y = $ y * $ x + $ c [ $ i ] ; } return $ y ; }
Evaluates a polynomial with coefficients c at x of which x is the constant
term by means of the Horner method

@param float $x The constant term
@param array $c The coefficients of the polynomial

@return float                    The value of the polynomial
@throws InvalidArgumentException Occurs if no coefficients are provided

@see p.10-11, 'Avoiding powers'
Evaluates a polynomial with coefficients c at x of which x is the constant term by means of the Horner method