Search code examples
javamathcalculus

Integrals in java


I would like to ask whether is there a library or method in java that can take a string which contains the prescription of a function like "4x^2 + 3x" and return the integrated version of the string. When the input is "4x^2 + 3x" I want to get an output like "(4/3)x^3 + (3/2)x^2 + c".


Solution

  • You could use the following java Polynomial class http://www.comscigate.com/cs/IntroSedgewick/90scientific/92symbolic/Polynomial.java.html. It has a public Polynomial integrate() function. You would have to parse your String into an instance of this class.