Exemple #1
0
  // sample client for testing
  public static void main(String[] args) {
    Complex a = new Complex(5.0, 6.0);
    Complex b = new Complex(-3.0, 4.0);

    System.out.println("a            = " + a);
    System.out.println("b            = " + b);
    System.out.println("Re(a)        = " + a.re());
    System.out.println("Im(a)        = " + a.im());
    System.out.println("b + a        = " + b.plus(a));
    System.out.println("a - b        = " + a.minus(b));
    System.out.println("a * b        = " + a.times(b));
    System.out.println("b * a        = " + b.times(a));
    System.out.println("a / b        = " + a.divides(b));
    System.out.println("(a / b) * b  = " + a.divides(b).times(b));
    System.out.println("conj(a)      = " + a.conjugate());
    System.out.println("|a|          = " + a.abs());
    System.out.println("tan(a)       = " + a.tan());
  }