예제 #1
0
 public void ComplexTrigSpecialCases()
 {
     Assert.IsTrue(ComplexMath.Sin(0.0) == Complex.Zero);
     Assert.IsTrue(ComplexMath.Cos(0.0) == Complex.One);
     Assert.IsTrue(ComplexMath.Tan(0.0) == Complex.Zero);
     Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Sin(Math.PI / 2.0), 1.0, TestUtilities.RelativeTarget));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Tan(Math.PI / 4.0), 1.0, TestUtilities.RelativeTarget));
 }
예제 #2
0
 public void ComplexNegativeAngles()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 16))
     {
         if (Math.Abs(z.Im) > Math.Log(Double.MaxValue / 10.0))
         {
             continue;                                                    // sin and cos blow up in imaginary part of argument gets too big
         }
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Sin(-z), -ComplexMath.Sin(z)), String.Format("remainder {0}", ComplexMath.Sin(-a) + ComplexMath.Sin(a)));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Cos(-z), ComplexMath.Cos(z)), String.Format("{0} vs. {1}", ComplexMath.Cos(-a), ComplexMath.Cos(a)));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Tan(-z), -ComplexMath.Tan(z)));
     }
 }
예제 #3
0
 public void ComplexSecTanTest()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 10))
     {
         if (Math.Abs(z.Im) > Math.Log(Double.MaxValue / 10.0))
         {
             continue;                                                    // sin and cos blow up in imaginary part of argument gets too big
         }
         Complex sec = 1.0 / ComplexMath.Cos(z);
         Complex tan = ComplexMath.Tan(z);
         Assert.IsTrue(TestUtilities.IsSumNearlyEqual(sec * sec, -tan * tan, 1));
     }
 }
예제 #4
0
 public void ComplexSecTanTest()
 {
     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;
         }
         Complex sec = 1.0 / ComplexMath.Cos(z);
         Complex tan = ComplexMath.Tan(z);
         Assert.IsTrue(TestUtilities.IsSumNearlyEqual(sec * sec, -tan * tan, 1));
     }
 }
예제 #5
0
 public void ComplexTanTanh()
 {
     foreach (Complex x in TestUtilities.GenerateComplexValues(1.0E-3, 1.0E3, 16))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Tanh(x), -ComplexMath.I * ComplexMath.Tan(ComplexMath.I * x)));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Tanh(-ComplexMath.I * x), -ComplexMath.I * ComplexMath.Tan(x)));
     }
 }