SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.polynomial
Class HornerScheme

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.polynomial.HornerScheme

public class HornerScheme
extends java.lang.Object

Horner scheme is an algorithm for the efficient evaluation of polynomials in monomial form. It can also be viewed as a fast algorithm for dividing a polynomial by a linear polynomial with Ruffini's rule.

By polynomial remainder theorem,

P(x) = Q(x)(x - x0) + P(x0)
That is, it computes the value of a polynomial P(x) at x0, i.e., P(x0), and at the same time gives the quotient Q(x).

See Also:
Wikipedia: Horner scheme

Constructor Summary
HornerScheme(Polynomial polynomial, double x)
          Evaluate a polynomial at x.
 
Method Summary
 Polynomial quotient()
          Get the quotient, the value of P(x).
 double remainder()
          Get the remainder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HornerScheme

public HornerScheme(Polynomial polynomial,
                    double x)
Evaluate a polynomial at x.

Parameters:
polynomial - a polynomial
x - a point to evaluate at
Method Detail

remainder

public double remainder()
Get the remainder.

Returns:
the remainder

quotient

public Polynomial quotient()
Get the quotient, the value of P(x).

Returns:
the quotient

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.