public static ComplexNumber multiply(ComplexNumber... z) { ArgChecker.notNull(z, "z"); int n = z.length; ArgChecker.isTrue(n > 0, "nothing to multiply"); if (n == 1) { return z[0]; } else if (n == 2) { return multiply(z[0], z[1]); } else { ComplexNumber product = multiply(z[0], z[1]); for (int i = 2; i < n; i++) { product = multiply(product, z[i]); } return product; } }
/** * arccos - the inverse of cos. * @param z A complex number * @return acos(z) */ public static ComplexNumber acos(ComplexNumber z) { ArgChecker.notNull(z, "z"); return ComplexMathUtils.multiply( NEGATIVE_I, ComplexMathUtils.log( ComplexMathUtils.add( z, ComplexMathUtils.sqrt(ComplexMathUtils.subtract(ComplexMathUtils.multiply(z, z), 1))))); }
public static ComplexNumber atan(ComplexNumber z) { ArgChecker.notNull(z, "z"); ComplexNumber iZ = ComplexMathUtils.multiply(z, I); ComplexNumber half = new ComplexNumber(0, 0.5); return ComplexMathUtils.multiply( half, ComplexMathUtils.log(ComplexMathUtils.divide(ComplexMathUtils.subtract(1, iZ), ComplexMathUtils.add(1, iZ)))); }
@Test public void testDivideMultiply() { assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(Z1, Z2), Z2), Z1); assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(Z1, X), X), Z1); assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(X, Z1), Z1), X_C); assertComplexEquals(ComplexMathUtils.multiply(X, Z1), ComplexMathUtils.multiply(Z1, X)); }
public static ComplexNumber acosh(ComplexNumber z) { ArgChecker.notNull(z, "z"); return ComplexMathUtils.log( ComplexMathUtils.add( z, ComplexMathUtils.sqrt(ComplexMathUtils.subtract(ComplexMathUtils.multiply(z, z), 1)))); }
public static ComplexNumber tanh(ComplexNumber z) { ComplexNumber z2 = ComplexMathUtils.exp(z); ComplexNumber z3 = ComplexMathUtils.exp(ComplexMathUtils.multiply(z, -1)); return ComplexMathUtils.divide(ComplexMathUtils.subtract(z2, z3), ComplexMathUtils.add(z2, z3)); }
public static ComplexNumber asinh(ComplexNumber z) { ArgChecker.notNull(z, "z"); return ComplexMathUtils.log( ComplexMathUtils.add( z, ComplexMathUtils.sqrt(ComplexMathUtils.add(ComplexMathUtils.multiply(z, z), 1)))); }
public static ComplexNumber atanh(ComplexNumber z) { ArgChecker.notNull(z, "z"); return ComplexMathUtils.multiply( 0.5, ComplexMathUtils.log(ComplexMathUtils.divide(ComplexMathUtils.add(1, z), ComplexMathUtils.subtract(1, z)))); }
ComplexMathUtils.multiply(null, Z1); } catch (final IllegalArgumentException e) { assertStackTraceElement(e.getStackTrace()); ComplexMathUtils.multiply(Z1, null); } catch (final IllegalArgumentException e) { assertStackTraceElement(e.getStackTrace()); ComplexMathUtils.multiply(X, (ComplexNumber) null); } catch (final IllegalArgumentException e) { assertStackTraceElement(e.getStackTrace()); ComplexMathUtils.multiply(null, X); } catch (final IllegalArgumentException e) { assertStackTraceElement(e.getStackTrace());