如何在java中找到符号差异

时间:2014-07-23 08:39:45

标签: java symbolic-math derivative apache-commons-math differentiation

我了解到,通过在org.apache.commons.math3.analysis.differentiation包中使用DerivativeStructure,可以计算函数的偏导数。

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

我想知道是否有办法使用DerivativeStructure类或其他库来获得函数的符号区分?。

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

0 个答案:

没有答案