Given a polynomial string str, the task is to integrate the given string and print the string after integrating it.
Note: The input format is such that there is a whitespace between a term and the ‘+’ symbol.
Input: str = “4X3 + 3X1 + 2X2”
Output: X4 + (3/2)X2 + (2/3)X3 + C
Input: str = “5X3 + 7X1 + 2X2 + 1X0”
Output: (5/4)X4 + (7/2)X2 + (2/3)X3 + Xq + C
Approach: The idea is to observe that when the given equation consists of multiple polynomials , the integration of the given polynomial .
Also it is known that the indefinite integral of is .
Therefore, we split the given string and integrate every term in it.
Below is the implementation of the above approach:
(5/4)X^4 + (7/2)X^2 + (2/3)X^3 + (1/1)X^1 + C
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.
- Integration in a Polynomial for a given value
- Program to calculate Double Integration
- Program to differentiate the given Polynomial
- Program for Derivative of a Polynomial
- Mathematics | Indefinite Integrals
- Sgn value of a polynomial
- Content of a Polynomial
- 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 sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to find value of 1^k + 2^k + 3^k + ... + n^k
- Program to find last two digits of 2^n
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Program to find the value of tan(nΘ)
- Program to find LCM of 2 numbers without using GCD
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
- Program to find the value of sin(nΘ)
- Program to find the sum of the series 1 + x + x^2+ x^3+ .. + x^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 email@example.com. 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.