我试图完成我的junit测试以找到多项式方法的导数并且我在使其工作时遇到了一些麻烦。这是方法:
public Polynomial derivative() {
MyDouble a = new MyDouble(0);
MyDouble b = this.a.add(this.a);
MyDouble c = this.b;
Polynomial poly = new Polynomial (a, b, c);
return poly;
}
这是junit测试:
public void testDerivative() {
MyDouble a = new MyDouble(2), b = new MyDouble(4), c = new MyDouble(8);
MyDouble d = new MyDouble(0), e = new MyDouble(4), f = new MyDouble(4);
Polynomial p1 = new Polynomial(a, b, c);
Polynomial p2 = new Polynomial(d,e,f);
assertTrue(p1.derivative().equals(p2));
}
我不太清楚为什么它不工作......我一遍又一遍地检查它,我知道我错过了一些东西。感谢大家提供的任何帮助,不胜感激