In this resource I will explain Horner’s method and also use Horner’s Method to solve or evaluate the value of polynomial expressions. The implementation of Horner’s method in c programming language to solve polynomial expression is as:-
At first understand the Horner’s method. Horner algorithm or method is used to solve the polynomial expressions. By using Horner method we can fast calculate the value or polynomial expressions. Horner method is also called synthetic division. Horner method or scheme is invented by British mathematician William George Horner.
Coding:-
#include <stdlib.h> #include <stdio.h> #include <conio.h> void main() { float arrayOfCoefficient[100],sumOfPolynomial=0,XValue; int n,i; clrscr(); printf("Highest degree of a polynomial's to solve the value:"); scanf("%d",&n); printf("Each coefficients of polynomial one by one:"); for(i=n;i>=0;i--) { scanf("%f",&arrayOfCoefficient[i]); } printf("Enter the value of xValue of polynomail :"); scanf("%f",&xValue); for(i=n;i>0;i--) { sumOfPolynomial=(sumOfPolynomial+arrayOfCoefficient[i])*xValue; } sumOfPolynomial=sumOfPolynomial+arrayOfCoefficient[0]; printf("nEvaluted Value of hole expression is =%f",sumOfPolynomial); getch(); }
Source Code:Horner
Output:-
Let’s take example of polynomial as following
4x5+2x4+x3+2x2+2x+1
If the value of base of polynomial is take as 3 then the total evaluated value of this polynomial is as shown in figure.
Output of Horner method or algorithm in c programming language to solve polynomial expression |
the above program is some error showing. like you didn't mention the process done in 20 and 22nd lines.
Very keen observation has been made by you, I appreciate it. Well while typing in a hurry I miss the + in line 20 and 21nd.
Thanks for notify error in code.
Now it is error free.