class 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);
  }

}