Horner’s method implementation in c programming language to evaluate value of polynomial expressions

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
Output of Horner method or algorithm in c programming language to solve polynomial expression
2 Comments
  1. March 16, 2012
  2. March 16, 2012