## Horner Method

Back to Programming

### Description

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.

DERIVATION

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 ${\mathrm{x}}^{\mathrm{n}}$, 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.

### Algorithm

INPUT:

A polynomial of degree n

OUTPUT:

The value of the polynomial for a given x.

PROCESS:

``````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[0]
for i = 1 to n - 1 repeat
Set r ← r × x + arr[i]
Print r
[End of Horner’s method]``````

### Code

1. It reduces the number of multiplication operations.

2. Time complexity is reduced from the normal process of evaluation.