ComplexMathUtils { public static ComplexNumber inverse(final ComplexNumber z) { ArgumentChecker.notNull(z, "z"); final double c = z.getReal(); final double d = z.getImaginary(); if (Math.abs(c) > Math.abs(d)) { final double dOverC = d / c; final double denom = c + d * dOverC; return new ComplexNumber(1 / denom, -dOverC / denom); } final double cOverD = c / d; final double denom = c * cOverD + d; return new ComplexNumber(cOverD / denom, -1 / denom); }  static ComplexNumber add(final ComplexNumber z1, final ComplexNumber z2); static ComplexNumber add(final ComplexNumber... z); static ComplexNumber add(final ComplexNumber z, final double x); static ComplexNumber add(final double x, final ComplexNumber z); static double arg(final ComplexNumber z); static ComplexNumber conjugate(final ComplexNumber z); static ComplexNumber divide(final ComplexNumber z1, final ComplexNumber z2); static ComplexNumber divide(final ComplexNumber z, final double x); static ComplexNumber divide(final double x, final ComplexNumber z); static ComplexNumber exp(final ComplexNumber z); static ComplexNumber inverse(final ComplexNumber z); static ComplexNumber log(final ComplexNumber z); static double mod(final ComplexNumber z); static ComplexNumber square(final ComplexNumber z); static ComplexNumber multiply(final ComplexNumber z1, final ComplexNumber z2); static ComplexNumber multiply(final ComplexNumber... z); static ComplexNumber multiply(final double x, final ComplexNumber... z); static ComplexNumber multiply(final ComplexNumber z, final double x); static ComplexNumber multiply(final double x, final ComplexNumber z); static ComplexNumber pow(final ComplexNumber z1, final ComplexNumber z2); static ComplexNumber pow(final ComplexNumber z, final double x); static ComplexNumber pow(final double x, final ComplexNumber z); static ComplexNumber sqrt(final ComplexNumber z); static ComplexNumber subtract(final ComplexNumber z1, final ComplexNumber z2); static ComplexNumber subtract(final ComplexNumber z, final double x); static ComplexNumber subtract(final double x, final ComplexNumber z);  }
@Test public void testInverse() { assertComplexEquals(ComplexMathUtils.inverse(ComplexMathUtils.inverse(Z1)), Z1); }