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
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.
- 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
- 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 to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to find the sum of a Series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2)
- Program to find sum of the given sequence
- Program to find HCF iteratively
- Program to Find the value of cos(nΘ)
- Program to find Sum of the series 1*3 + 3*5 + ....
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^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.