2

I want to evaluate $P(x)=5+3x+5x^2+4x^4$ using Horner's method

So I rewrite $P(x)$ as :

$$P(x)=5+3x+5x^2+0x^3+4x^4\tag{1}$$

and applying Horner's method to get: $$P(x)=5+x(3+x(5+x(0+4x)))\tag{2}$$ Is it done? or I should rewrite it as : $$P(x)=5+x(3+x(5+x\times4x)))\tag{3}$$ What about this: $$P(x)=5+x(3+x(5+4x^2)))\tag{4}$$Which one of these three form is ok for Horner's method?

Somos
  • 35,251
  • 3
  • 30
  • 76
Aligator
  • 1,454

1 Answers1

4

Horner's method is understood as a systematic algorithm, not as a formula.

$$p\leftarrow4,\\p\leftarrow p\cdot x+0,\\p\leftarrow p\cdot x+5,\\p\leftarrow p\cdot x+3,\\p\leftarrow p\cdot x+5.$$


Note that this is not truly equivalent to the expression

$$\left(\left(\left(\left(4\right)\cdot x+0\right)\cdot x+5\right)\cdot x+3\right)+5$$

and even less

$$5+x\cdot\left(3+x\cdot\left(5+x\cdot\left(0+x\cdot\left(4\right)\right)\right)\right)$$

as executed by a calculator or computer, which would use a stack to handle the nested parenthesis and possibly end up in a stack overflow (low-end calculator or high degree polynomial). Horner's scheme only requires constant additional space.