Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Horner’s method

  1. Jan 12, 2007 #1
    The Horner’s method is an algorithm that evaluates polynomials. The following pseudocode shows how to use this method to find the
    value of anxn + an-1xn-1 + . . . + a1x + a0 at x = c.
    procedure Horner(c, a0, a1, a2, . . . , an : real numbers)
    y := an
    for i := 1 to n
    y := y × c + an-i
    end {y = ancn + an-1cn-1 + . . . + a1c + a0}

    (a) Evaluate x2 + 5x + 3 at x = 2 by working through each step of the algorithm.
    (b) Exactly how many multiplications and additions are used by this algorithm to evaluate a polynomial of degree n at x = c? (Do not count additions used to increment the loop variable.)

    please help in details thanx much

  2. jcsd
  3. Jan 13, 2007 #2


    User Avatar
    Science Advisor
    Homework Helper

    n=2. a2=1, a1=5, a0=3. c=2. There - I did the hard part. Now just DO it. Step through the algorithm.
  4. Jan 13, 2007 #3
    okey x^2 + 5x + 3 at x=2
    i need to make sure about your answer.sooo

    x^2(is a2) + 5x(is a1) + 3 (is a0) at x=2 (is n=2)
    correct or not?

    i will give anonther example make sure about it

    lets assume evaluate 3x^2 + x + 1 at x=2

    so according to you 3x^2(is a=2) + x(is a=1) + 1 (is a=0) at x=2(is n=2)
    is it correct

    please let me know
  5. Jan 13, 2007 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Boy are they going out of their way to make this obscure.

    Horner's method is simply factoring the polynomial to eliminate all orders of x greater then 1. Then you start multiplying and adding your way through the nest.
    For example expand a quadratic like this:
    [tex] ax^2 + bx + c = x(ax+b) + c [/tex]

    To do the calculation start inside the parens and work your way out.

    This method is very useful for RPN calculators.
  6. Jan 15, 2007 #5
    Integral, Is Horner's method just an elaborate way to say that the value of a polynomial at x=a is simply the remainder when the polynomial is divided by x-a?

    Nevermind... (I've never seen it written as Horner's method before; I just scratched it out on paper, and "that's all it is?") You're right! They did make that pretty obscure.

    OP, if you're having trouble following it, have you been exposed to synthetic division before? Simply, synthetic division is used to divide a polynomial by a linear binomial in the form (x-a). The remainder after such a division is equal to f(a).
  7. Jan 16, 2007 #6


    User Avatar
    Science Advisor
    Homework Helper

    To answer the question, it doesn't matter if you don't know what Horner's method is, or what it's supposed to do.

    You are given an algorithm, and asked to work through it step by step and count the number of operations. A computer just follows the instructions in the algorithm. To answer the question, you need to do the same as the computer would do.
  8. Jan 23, 2007 #7
    how did you calculate c=2

    please explain in details

    how about this
    okey x^2 + 5x + 3 at x=2
    what is c?
  9. Jan 24, 2007 #8


    User Avatar
    Science Advisor

    No one "calculated" c= 2! The definition of Horner's method said "use this method to find the value of a_nx^n + a_(n-1)x^(n-1) + . . . + a_1x + a_0 at x = c".
    Your problem asks you to find the value of a given polynomia "at x= 2".

    Just compare that "general form "anx^n + an-1x^(n-1) + . . . + a1x + a0 at x = c" with the specific problem you are given. In x^2+ 5x+ 3, the highest power of x is 2: n= 2. The coefficient of that highest power is 1, the next 5, the constant term is 3: a_2= 1, a_1= 5, a_0= 3. Because the problem says "at x= 2" compared with "at x= c", c= 2.

    Here's a test: "evaluate 4x^3+ 3x^2- 2x+ 4 at x= 1". What are n, a_3, a_2, a_1, a_0, and c?

    By the way, notice the use of "_2" for subscripts and "^2" for exponents? Makes it much easier to read.
    Last edited by a moderator: Jan 24, 2007
  10. Jan 24, 2007 #9
    thank you HallsofIvy it is clear now......
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook