示例#1
0
  public Complex division(Complex n) throws ArithmeticException {
    Complex div = new Complex();
    if (n.module() == 0.0) {
      throw new ArithmeticException("Divide by zero");
    } else {
      div = this.modToComp(this.module() / n.module(), this.phase() - n.phase());
    }

    return div;
  }
示例#2
0
  private static boolean diverges(final double real, final double complex, final int interactions) {
    final Complex c = new Complex(real, complex);

    Complex z = c;

    int interaction = 0;
    while ((z.module() <= 2) && (++interaction < interactions)) {
      z = z.squared().add(c);
    }

    return (z.module() > 2);
  }