我在使用Apache Commons Math库时遇到了问题。我只想创建像f(x) = 4x^2 + 2x这样的函数,并且我想计算该函数的导数 --> f'(x) = 8x + 2。
我阅读了关于微分的文章(http://commons.apache.org/proper/commons-math/userguide/analysis.html,第4.7节)。有一个例子我不理解:
在第5行显然出现了编译错误。函数
我阅读了关于微分的文章(http://commons.apache.org/proper/commons-math/userguide/analysis.html,第4.7节)。有一个例子我不理解:
int params = 1;
int order = 3;
double xRealValue = 2.5;
DerivativeStructure x = new DerivativeStructure(params, order, 0, xRealValue);
DerivativeStructure y = f(x); //COMPILE ERROR
System.out.println("y = " + y.getValue();
System.out.println("y' = " + y.getPartialDerivative(1);
System.out.println("y'' = " + y.getPartialDerivative(2);
System.out.println("y''' = " + y.getPartialDerivative(3);
在第5行显然出现了编译错误。函数
f(x)
被调用但未定义。我错在哪里了? 有没有人使用过apache commons math库进行微分/导数,或者有没有其他库/框架可以帮助我?谢谢。
f
和变量x
不存在。 - Lews Therin