This method is used to find the value of a polynomial of degree n for a given value of x. In general, a polynomial is solved by solving all terms one by one and then calculating the sum of all terms.
A given polynomial is of the form
(They may be positive or negative) and n is a positive integer.
Now the value of this polynomial is to be found for a given x.
The idea of this method is to initialize the result as the coefficient of , then multiplying this result with x, and then add the next coefficient to the result. Finally, the result will be calculated by repeating this procedure.
A polynomial of degree n
The value of the polynomial for a given x.
Step 1: [taking the inputs from the user] Read n [the number of terms of the polynomials] for i = 0 to n - 1 repeat Read arr[i] [the co-efficient of the polynomials] [End of ‘for’ loop] Read x [the value for which the value of the polynomial is to be calculated] Step 2: [Horner’s Method] Set r ← arr for i = 1 to n - 1 repeat Set r ← r × x + arr[i] Print r [End of Horner’s method]
1. It reduces the number of multiplication operations.
2. Time complexity is reduced from the normal process of evaluation.
1. All the operations are dependent. The next calculation is dependent on the previous data, so, parallelism cannot be achieved for this algorithm.
1. This method is used to find the value of a polynomial more efficiently and in less time.