0

我了解到,通过使用 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
4

0 回答 0