33.6k views
1 vote
) Evaluating a polynomial limit analytically You should have learned by now the process for finding the derivative of a polynomial (as another polynomial). Write a program that will read in from the user a cubic polynomial f(x) (as a set of 4 coefficients), and use this to compute the derivative polynomial (i.e. compute the three coefficients of the derivative f’(x)). Then, read in a value for x from a user, and evaluate the derivative polynomial at that x. Print out that value. b) Evaluating a polynomial derivative numerically

User Beaslera
by
7.4k points

1 Answer

4 votes

Answer:

This code or is program to find a given value of derivative of a polynomial.

Explanation:

We know already how to apply or make the procedures mathematically talking so this short program will eventually help you how to find logic.

// libraries

#include <stdio.h>

#include <conio.h>

//use to control floating elements

float poly(float a[], int, float);

//main

int main()

{

// Enter the degree of polynomial equation

float x, a[10], y1;

int deg, i;

printf("Enter the degree of polynomial equation: ");

scanf("%d", &deg);

printf("Ehter the value of x for which the equation is to be evaluated: ");

// Enter the coefficient of x to the power

scanf("%f", &x);

for(i=0; i<=deg; i++)

{

printf("Enter the coefficient of x to the power %d: ",i);

scanf("%f",&a[i]);

}

// The value of polynomial equation for the value of x

y1 = poly(a, deg, x);

printf("The value of polynomial equation for the value of x = %.2f is: %.2f",x,y1);

return 0;

}

/* function for finding the value of polynomial at some value of x */

float poly(float a[], int deg, float x)

{

float p;

int i;

p = a[deg];

for(i=deg;i>=1;i--)

{

p = (a[i-1] + x*p);

}

return p;

}

User Martin Meixger
by
6.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.