开发者

Efficient polynomial evaluation with Horner's Algorithm

I have the equation y = 3(x+1)^2 + 5(x+1)^4.

Using Horner's scheme I could evaluate this polynomial in this form, y = 8+x(26+x(33+x(20+5x))), th开发者_StackOverflow社区us requiring 8 arithmetic operations.

I could also evaluate it in this form, y = (x+1)^2 * ((5x+10)x+8), requiring 7 operations.

I've been told this can be done in 5 operations but Horner's algorithm is supposed to be most efficient and it can only do it in 7 operations. Am I missing something?


Let a = (x+1)^2, that's 2 ops. Then y=3a + 5a^2 = a(3+5a), 3 more ops for a total of 5.


3(x+1)^2 + 5(x+1)^4 = (x+1)^2[3 + 5(x+1)^2].

I can do that in 5 operations:

1) x+1
2) (x+1)^2
3) 5(x+1)^2
4) 5(x+1)^2 + 3
5) (x+1)^2[5(x+1)^2 + 3]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜