public void testTanInf() { TestUtils.assertSame(zeroNaN, oneInf.tan()); TestUtils.assertSame(zeroNaN, oneNegInf.tan()); TestUtils.assertSame(Complex.NaN, infOne.tan()); TestUtils.assertSame(Complex.NaN, negInfOne.tan()); TestUtils.assertSame(Complex.NaN, infInf.tan()); TestUtils.assertSame(Complex.NaN, infNegInf.tan()); TestUtils.assertSame(Complex.NaN, negInfInf.tan()); TestUtils.assertSame(Complex.NaN, negInfNegInf.tan()); }
// 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()); }
public void testTan() { Complex z = new Complex(3, 4); Complex expected = new Complex(-0.000187346, 0.999356); TestUtils.assertEquals(expected, z.tan(), 1.0e-5); }