Given a polynomial as string and a value. Evaluate polynomial’s derivative for the given value.
Note: The input format is such that there is a whitespace between a term and the ‘+’ symbol
The derivative of p(x) = ax^n is p'(x) = a*n*x^(n-1)
Also, if p(x) = p1(x) + p2(x)
Here p1 and p2 are polynomials too
p'(x) = p1′(x) + p2′(x)
Input : 3x^3 + 4x^2 + 6x^1 + 89x^0 2 Output :58 Explanation : Derivative of given polynomial is : 9x^2 + 8x^1 + 6 Now put x = 2 9*4 + 8*2 + 6 = 36 + 16 + 6 = 58 Input : 1x^3 3 Output : 27
We split the input string into tokens and for each term calculate the derivative separately for each term and add them to get the result.
This article is contributed by Ankit Jain . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to differentiate the given Polynomial
- Program to find the indefinite Integration of the given Polynomial
- Sgn value of a polynomial
- Integration in a Polynomial for a given value
- Content of a Polynomial
- Minimize the sum of roots of a given polynomial
- Horner's Method for Polynomial Evaluation
- Finding nth term of any Polynomial Sequence
- Complete the sequence generated by a polynomial
- Python | Finding Solutions of a Polynomial Equation
- String hashing using Polynomial rolling hash function
- Program to calculate value of nCr
- Program to find value of 1^k + 2^k + 3^k + ... + n^k
- Program for sum of cos(x) series
- Program to add two fractions
- Program to compare m^n and n^m
- Program to add two polynomials
- C program to calculate the value of nPr
- Program for n-th even number
- Program for n-th odd number