Class HornerScheme


  • public class HornerScheme
    extends Object
    Horner scheme is an algorithm for the efficient evaluation of polynomials in monomial form. It can also be seen as a fast algorithm for dividing a polynomial by a linear polynomial with Ruffini's rule.

    The polynomial remainder theorem says:

    
     P(x) = Q(x)(x - x0) + P(x0)
     
    We thus can compute the value of a polynomial P(x) at x0, i.e., P(x0), and at the same time the quotient Q(x).
    See Also:
    Wikipedia: Horner scheme
    • Constructor Detail

      • HornerScheme

        public HornerScheme​(Polynomial polynomial,
                            double x)
        Evaluate a polynomial at x.
        Parameters:
        polynomial - a polynomial
        x - a point to evaluate the polynomial at
    • Method Detail

      • remainder

        public double remainder()
        Get the remainder, P(x0).
        Returns:
        the remainder
      • quotient

        public Polynomial quotient()
        Get the quotient, Q(x).
        Returns:
        the quotient