I learned that by using DerivativeStructure in org.apache.commons.math3.analysis.differentiation package, one can calculate partial derivatives of a function.
DerivativeStructure x = new DerivativeStructure(1, 3, 0, 2.5);
DerivativeStructure x2 = x.pow(2);
//y = 4x^2 + 2x
DerivativeStructure y = new DerivativeStructure(4.0, x2, 2.0, x);
System.out.println("y = " + y.getValue()); // y = 30.0
System.out.println("y' = " + y.getPartialDerivative(1)); //y' = 22.0
System.out.println("y'' = " + y.getPartialDerivative(2)); //y'' = 8.0
System.out.println("y''' = " + y.getPartialDerivative(3)); //y''' = 0.0
I'm wondering if there's a way to get the symbolic differentiation of a function, using DerivativeStructure class or some other library ?.
eg:- if y = 4x^2 + 2x, i want to find get the results as 8x+2 , 8x not the evaluated results like 30.0 and 22.0