Talk:Horner's method

message: I posted the following in Talk:Ruffini's rule, but got no response.  I'm reposting the content here, since it may be more relevant here:
My professor showed me this algorithm for evaluating polynomials (more) quickly, and it looks very much like synthetic division:
Suppose  f(x) = 3x^6 + 5x^3 + 2x^2 + 1  (I just made it up), and I want to know what  f(2)  is.  I setup the problem thusly,
  2 |     3     0     0     5     2     0     1
    |
    |           6    12    24    58   120   240
    |-------------------------------------------
          3     6    12    29    60   120   241
The 2 at the very left is the parameter, and the rest of the first row is the coefficients of the polynomial.  The first coefficient drops down directly.  Then I multiply it by the parameter to get 6, which goes to 2nd row, 2nd column.  I add the columns (0 + 6) and drop down the sum.  Multiply it by the parameter again yields 12, which goes to 2nd row, 3rd column, ...  Repeat until the last column, and the last sum is  f(2) 
This algorithm needed 7 multiplies and 6 adds.  Computing  f(x) = 3(2)^6 + 5(2)^3 + 2(2)^2 + 1  directly would need 14 multiplies and 4 adds.
Is this a variant of synthetic division, thus belongs to the aritcle?  If not, where else is more appropriate?  IMHO, it's pretty neat and deserves mention somewhere.
madoka 00:31, Oct 12, 2004 (UTC)
This is precisely the Horner scheme. The long-division-like notation, as far as I know, is your prof's idea.
Loisel 13:42, 14 Oct 2004 (UTC)
replies: text: Actually, I was taught this table layout by a classical mathematician of the first order.  He mentioned that people use this method in Europe. I assume from his background that he meant Eastern Europe.  Tparameter 18:29, 9 November 2006 (UTC)
thread_title:  A notation for the Horner scheme 

message: I think the first description is gibberish. I'll delete it unless someone protests. Loisel 05:17, 6 May 2004 (UTC)
replies: text: Done. Loisel 04:52, 11 May 2004 (UTC)
thread_title:  Old stuff 

message: The formula
:p(x) = a_0 + x(a_1 + x(a_2 + \cdots x(a_{n-1} + a_n x)))
must be written
:p(x) = a_0 + x(a_1 + x(a_2 + \cdots x(a_{n-1} + a_n x)\cdots))
to make the number of ")" match the number of "(".
Bo Jacoby 10:45, 7 March 2006 (UTC)
thread_title:  error in formula 

message: It occurs to me, reading this article, that the claim about numerical efficiency is misleading.  Naive evaluation of a polynomial, say
:p(x) = a_0 + a_1 x + \dots + a_n x^n\ 
does not necessarily require
:\frac{n(n + 1)}{2} = \sum_{i = 0}^n i
as claimed in the article, unless one is indeed very naive.  A better way to do it, and the way people actually do it, is to compute the powers successively and save the results.  This requires only n - 1 multiplications, since one is in effect computing only x^n.  One then multiplies each by its coefficient, another n multiplications, and adds the results: n additions.  It follows then that the naive algorithm requires only 2n - 1 multiplications and n additions, so Horner's method is, in terms of time complexity, not even a big-O improvement.  It merely improves the "coefficient".
That's time complexity; what about space complexity?  Horner's method requires only storing one number at a time, namely b_i when computing b_{i + 1}, after which it is no longer needed.  These numbers are all about magnitude a_n x^n, or in terms of bits, about \log a_n + n\log x.  So one requires O(n) storage space to execute Horner's algorithm.  The naive algorithm again naively requires storing all the numbers x, x^2, \dots before multiplying with the coefficients and then adding, which would appear to be a space complexity requirement of O(n^2) bits (that's 1 + 2 + ...), but that's just as silly as multiplying each power of x separately.  One should instead perform "nested summation", namely computing successively a_0, a_0 + a_1 x, \dots, which requires only remembering the previous value of x and the previous iteration's partially computed sum: additional space complexity, again O(n), or more specifically, about 2n\log x.  So Horner is again just an improvement of a factor of 2.
One objection I foresee is that someone will claim that this is "changing" the naive computation by optimizing it.  That's a reasonable claim for the time complexity computation, since a priori I do need all the powers of x and I'm just choosing to do it cleverly.  My point is, though, that if you wanted to do it on paper you would compute those powers by the method I describe; it's only when writing in some kind of programming language that you'd fall into the (easy) trap of writing something stupid like (code snippet from a likely implementation in C):
for (i = 0; i <= n; ++i) {
    poly += a[i] * pow(x, i);
}
which requires recomputing each one.  And that's an issue with the representation of the algorithm rather than the algorithm itself; I maintain that the naive algorithm as it is conceived by anyone who sits down to do it is as I have described.  Still, the point stands: the naive algorithm does call, apparently, for computing each power separately.  It is less clear that the same objection applies to the computation of space complexity: consider that by definition of a sum, we have
:p(x) = a_0 + a_1 x + \dots + a_n x^n = \sum_{i = 0}^n a_i x^i,\  where the big sigma is defined in general by:
:\sum_{i = 0}^{n + 1} A_i = \sum_{i = 0}^n A_i + A_{n + 1}.\ 
In other words, the definition of repeated addition is as "nested addition"; this is not nearly the same league of optimization as Horner's "nested multiplication", which requires actually factoring distributed products in the polynomial.  This is just the associative law, and in fact it is not even an optimization because it is required by definition of addition as a binary operation.  The biggest choice made here is to write the sum in order of increasing powers of x, which is already done in the statement of the problem.
This is not to diminish the value of this method.  It's just to say that it isn't as much better as it would seem, unless the person doing the naive computation is really a total naif.  I would correct the article, and I'm certain that I'm not the only person to have thought of this so it's probably not original research, but this is totally not my field and I don't know a reference that would have it.  So I put it here instead, in case one of you knows. Ryan Reich 21:11, 13 July 2007 (UTC)
replies: text: Hell, as soon as I write this I check back at the section in the article and find that something else makes reference to Knuth Vol. 2.  So I check Knuth (I always do intend to read it...) and find that even before the very first algorithm in section 4.6.4, he makes precisely the observation I just made.  He doesn't discuss the space complexity at all, though, except for dismissing it with a comment about accessing results in memory that really is a comment on the time complexity, so I still don't have a reference to that.  I'm putting it in anyway and hoping someone else can fix this.  So references are still welcome. Ryan Reich 21:15, 13 July 2007 (UTC)
thread_title:  More numerical efficiency 

message: In the section on polynomial root finding, it reads:
* Given a polynomial p_n(x) of degree n with zeros  z_n < z_{n-1} < ... < z_1  make some initial guess  x_0  such that  x_0 > z_1 .
What isn't clear is how to determine a range for the roots (the values z_n and z_1) without knowing what the roots are in the first place; if there's a method, it would be nice to refer to it. It's also not obvious why the method should start with a root that's outside the range of roots - why not use the intermediate value theorem and bisect to find a starting guess? --Jay (Histrion) (talk • contribs) 02:00, 1 November 2009 (UTC)
replies: text: The whole section should be erased or rewritten. The title is wrong, since the root finding invokes Newton's method as a black box. What it describes is polynomial deflation, that is, dividing off a linear factor using the Horner scheme. One would expect that the implementation of Newton's method using a two stage Horner scheme were described as well.--LutzL (talk) 08:20, 2 November 2009 (UTC)

text: And, to make the confusion complete, the proponents on the Ruffini's rule talk page (in the archive now) would argue that this deflation procedure is not what the Horner scheme is about. Because the long or synthetic division interpretation of the result of this algorithm in their tradition bears the name Ruffini, whereas Horner scheme solely applies to the polynomial evaluation part.--LutzL (talk) 08:26, 2 November 2009 (UTC)
thread_title:  Polynomial root finding 

message: The example of a Python implementation of the Horner Scheme can be slightly improved.  It currently lacks comments, and takes an unnecessary input.  I propose to add some comments to it and eliminate the input n, instead taking it as the length of the list a.  I also propose to combine the variables n and i, as only one is necessary.  These changes will make the Python function more efficient and more user-friendly.
The change would be as follows:
def Horner(a, x):
    """A function that implements the Horner Scheme for evaluating a polynomial.
    Inputs:  a, a list containing the coefficients of the polynomial
             x, the value at which the polynomial will be evaluated
    Outputs: result, the value of the polynomial evaluated at x
    """
    n = len(a)
    result = a[n]
    while n >= 1:
        result = result * x + a[n-1]
        n -= 1
    return result
Agreed -- I believe the implementation currently up is incorrect. It evaluates the coefficients backwards.
2604:2000:4081:8900:956C:2E51:27F3:B2F1 (talk) 21:40, 17 December 2017 (UTC)
thread_title:  Concerning the Python Implementation 

message: There is something distinctly wrong with calling an article Horner scheme and then saying Horner method everywhere. If the title is not the common name then try changing it to the common name, otherwise use the title. Dmcq (talk) 17:01, 4 March 2012 (UTC)
replies: text: I did a quick google books on "Horner scheme" "Horner rule" and "Horner method" and the various versions with a 's or s after Horner and "Horner's method" seems to have quite a clear win so if no-one complains in the next day I'll swap the two so the title of this article is Horner's method. Dmcq (talk) 17:12, 4 March 2012 (UTC)
replies: text: Well if you've come here you've seen IU've moved it! Dmcq (talk) 13:29, 5 March 2012 (UTC)
thread_title:  Horner scheme/method 

message: Substituted at 18:02, 5 June 2016 (UTC)
thread_title: Assessment comment

message: Some may be interested in this article:
"The classical Chinese version of Horner’s method: Technical considerations", 12 January 2017, 
http://donwagner.dk/horner/horner.html
Dbwagner (talk) 14:48, 13 January 2017 (UTC)
thread_title:  The classical Chinese version of Horner’s method[[User:Dbwagner|Dbwagner]] ([[User talk:Dbwagner|talk]]) 14:48, 13 January 2017 (UTC) 

message: I added the expression
:
p(x) = (b_1 + b_2 x + b_3 x^2 + b_4x^3 + \cdots + b_{n-1} x^{n-2} +b_nx^{n-1})(x-x_0)+b_0
as a link between theory and application (examples). This expression is of course empirically true, but can anyone prove it mathematically? That proof is vital, because otherwise this article is only really about Horner's rule, not Horner's method. Tavernsenses (talk) 09:00, 26 September 2019 (UTC)
thread_title: Added link between theory and application

message: : I have created the article Polynomial evaluation. It also covers Horner's rule, since it's pretty short to describe. Would it make sense to make Horner's method all about the division algorithm and refer to Polynomial evaluation for the evaluation method? Thomasda (talk) 12:21, 30 May 2021 (UTC)
replies: text:  Many people know Horner's rule under the name of Horner. So the description of the method must be in an article named after Horner (see WP:LEAST). As the method is pretty short to describe, there is no harm to have it described several times in Wikipedia, if all descriptions are linked to the main one. Normally this is done with a template  at the top of secondary descriptions. In Polynomial evaluation, I have used  instead, because Horner's method requires to be improved for not being confusing. D.Lazard (talk) 12:51, 30 May 2021 (UTC)
thread_title:  Relationship with the article "Polynomial evaluation" 

message: Whilst Horner's method is clearly optimal for calculations done manually by a single human, it's also clearly the least parallelizable, as operations must be performed in one specific sequence. Even just two humans working on the same evaluation could choose a faster method than this one. Martin Kealey (talk) 08:45, 10 March 2024 (UTC)
thread_title:  Efficiency?