Reputation: 45692
I'm working with PolynomialFunction. I derivate/integrate my function f
in the next way:
// derivation ...
new PolynomialFunction(vector).value(x).getPartialDerivative(derivationOrder)
// integration ...
UnivariateIntegrator integrator = new IterativeLegendreGaussIntegrator(pointsNumber, relativeAccuracy, absoluteAccuracy, minIterations, maxIterations);
integrator.integrate(128, f, from, to);
But how to get derivation/integration result from function f
without specifying real values?
I.e. derivate (8 + 3x + x^2) => 3 + 2x
Upvotes: 0
Views: 633
Reputation: 644
For polynomial functions, you can get derivatives directly (as polynomials) using the polynomialDerivative
method of the PolynomialFunction
class. There is also a more general setup for differentiation described in the analysis section of the Commons Math User Guide.
Upvotes: 1
Reputation: 196
I do not believe the Apache Math Commons Library supports symbolic derivation/integration. However, if you are using polynomials as your question implies, this is computationally easy enough. If you represent a polynomial as an array of coefficients like Apache does for their PolynomialFunction, this makes it pretty easy.
Derivative:
Integration:
Doing this for an arbitrary function becomes a lot harder, or sometimes even impossible. There are programs out there that are pretty good at this, such as SageMath. I would consult a calculus text for more information. I hope that helps!
Upvotes: 1