public static Complex QuoteOf(Complex X, Complex Y) { double e = Math.pow(Y.real, 2) + Math.pow(Y.imag, 2); Complex Z = new Complex(); Z.setReal((X.real * Y.real + X.imag * Y.imag) / e); Z.setImag((X.imag * Y.real - X.real * Y.imag) / e); return Z; }
public static void main(String[] args) { new Complex(2, 4).printNum(); new Complex(6, 7).addNum(new Complex(4, 6)).printNum(); new Complex(6, 7).multiplyNum(new Complex(4, 6)).printNum(); Complex c = new Complex(4, 7); c.setImag(6); c.setReal(3); c.printNum(); }
public static Complex DiffOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real - Y.real); Z.setImag(X.imag - Y.imag); return Z; }
public static Complex prodOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real * Y.real - X.imag * Y.imag); Z.setImag(X.real * Y.imag + X.imag * Y.real); return Z; }
public static Complex sumOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real + Y.real); Z.setImag(X.imag + Y.imag); return Z; }