Given a polynomial string str, the task is to differentiate the given string and print the string after differentiating it.
Note: The input format is such that there is a whitespace between a term and the ‘+’, ’-’ symbol
Input: str = “4X3 + 3X1 + 2X2”
Output: “12X2 + 3X0 + 4X1”
The derivative of p(x) = A*XN is p'(x) = A * N * XN – 1
Input: str = “5X4 + 6X2 + 5X2”
Output: “20X3 + 12X1 + 10X1”
Approach: The idea is to observe that when the given equation consists of multiple polynomials , the differentiation of the given polynomial .
And, it is known that the derivative of is
Therefore, we split the given string and differentiate every term in it.
Below is the implementation of the above approach:
20X^3 + 12X^1 + 10X^1
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program for Derivative of a Polynomial
- Program to find the indefinite Integration of the given Polynomial
- Sgn value of a polynomial
- Integration in a Polynomial for a given value
- Finding nth term of any Polynomial Sequence
- Complete the sequence generated by a polynomial
- Horner's Method for Polynomial Evaluation
- Python | Finding Solutions of a Polynomial Equation
- Program to find value of 1^k + 2^k + 3^k + ... + n^k
- Program for n-th even number
- Program for n-th odd number
- Program to add two polynomials
- C program to calculate the value of nPr
- Program to compare m^n and n^m
- Program to add two fractions
- Program to calculate value of nCr
- Program for sum of cos(x) series
- Program to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to add two integers of given base
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.