GATE | GATE-CS-2006 | Question 1
Consider the polynomial p(x) = a0 + a1x + a2x2 + a3x3 , where ai ≠ 0 ∀i. The minimum number of multiplications needed to evaluate p on an input x is:
Background Explanation :
Horner’s rule for polynomial division is an algorithm used to simplify the process of evaluating a polynomial f(x) at a certain value x = x0 by dividing the polynomial into monomials (polynomials of the 1st degree). Each monomial involves a maximum of one multiplication and one addition processes. The result obtained from one monomial is added to the result obtained from the next monomial and so forth in an accumulative addition fashion. To explain the above, let is re-write the polynomial in its expanded form;
f(x0) = a0 + a1x0+ a2x0^2+ … + anx0^n
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
This can, also, be written as:
f(x0) = a0 + x0(a1+ x0(a2+ x0(a3+ … + (an-1 + anx0)….)
The algorithm proposed by this rule is based on evaluating the monomials formed above starting
from the one in the inner-most parenthesis and move out to evaluate the monomials in the outer
Using Horner’s Rule, we can write the polynomial as following
a0 + (a1 + (a2 + a3x)x)x
In the above form, we need to do only 3 multiplications
p = a3 X x ------------ (1) q = (a2 + p) X x ---------(2) r = (a1 + q) X x ---------(3) result = a0 + r
This solution is contributed by Nitika Bansal.
Quiz of this Question