factor out duplicated maths
@@ -34,8 +34,10 @@ public class ArcTan2Vertex extends DoubleBinaryOpVertex {
DualNumber aDual = a.getDualNumber();
DualNumber bDual = b.getDualNumber();
- Infinitesimal thisInfA = aDual.getInfinitesimal().multiplyBy(b.getValue() / (Math.pow(b.getValue(), 2) * Math.pow(a.getValue(), 2)));
- Infinitesimal thisInfB = bDual.getInfinitesimal().multiplyBy(- (a.getValue() / (Math.pow(b.getValue(), 2) * Math.pow(a.getValue(), 2))));
+ double denominator = (Math.pow(b.getValue(), 2) * Math.pow(a.getValue(), 2));
+
+ Infinitesimal thisInfA = aDual.getInfinitesimal().multiplyBy(b.getValue() / denominator);
+ Infinitesimal thisInfB = bDual.getInfinitesimal().multiplyBy(- (a.getValue() / denominator));
Infinitesimal newInf = thisInfA.add(thisInfB);
return new DualNumber(op(a.getValue(), b.getValue()), newInf);
}
