0

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
Roshana
  • 357
  • 1
  • 3
  • 17
  • I don't know this package but the docs refer to a paper which starts by saying "Automatic differentiation is a way to find the derivative of an expression without finding the expression of a derivative" http://www1.american.edu/cas/mathstat/People/kalman/pdffiles/mmgautodiff.pdf - so this is probably doing numeric differentiation. So, no. – doctorlove Jul 23 '14 at 08:46
  • 2
    With apache-commons-math you can find numeric solutions. With the symja project you can also find symbolic solutions. https://bitbucket.org/axelclk/symja_android_library/wiki/Home – axelclk Jul 24 '14 at 10:17

0 Answers0