public void ComplexDoubleAngle() { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-3, 1.0E3, 16)) { // Since sin(z) and cos(z) have factors that go like e^{\pm Im(z)}, they will blow up if the imaginary // part of z gets too big. We just skip over those problematic values. if (Math.Abs(z.Im) > Math.Log(Double.MaxValue) / 2.0) { continue; } Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Sin(2.0 * z), 2.0 * ComplexMath.Sin(z) * ComplexMath.Cos(z))); Assert.IsTrue(TestUtilities.IsSumNearlyEqual(ComplexMath.Sqr(ComplexMath.Cos(z)), -ComplexMath.Sqr(ComplexMath.Sin(z)), ComplexMath.Cos(2.0 * z))); } }