Beispiel #1
0
 public void ComplexArcTrigInversion()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 32))
     {
         Complex asin = ComplexMath.Asin(z);
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Sin(asin), z));
         Complex acos = ComplexMath.Acos(z);
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Cos(acos), z));
         Assert.IsTrue(TestUtilities.IsSumNearlyEqual(asin, acos, Math.PI / 2.0));
     }
 }
Beispiel #2
0
        public void ComplexArcTrigReflection()
        {
            foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-3, 1.0E3, 32))
            {
                Complex asin  = ComplexMath.Asin(z);
                Complex masin = ComplexMath.Asin(-z);
                Assert.IsTrue(TestUtilities.IsNearlyEqual(masin, -asin));

                Complex acos  = ComplexMath.Acos(z);
                Complex macos = ComplexMath.Acos(-z);
                Assert.IsTrue(TestUtilities.IsSumNearlyEqual(acos, macos, Math.PI));
            }
        }
Beispiel #3
0
        public void ComplexArcTrigSpecialValues()
        {
            Assert.IsTrue(ComplexMath.Asin(Complex.Zero) == Complex.Zero);
            Assert.IsTrue(ComplexMath.Asin(Complex.One) == Math.PI / 2.0);
            Assert.IsTrue(ComplexMath.Asin(-Complex.One) == -Math.PI / 2.0);
            Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Asin(Complex.I), Complex.I * Math.Log(1.0 + Math.Sqrt(2.0))));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Asin(-Complex.I), -Complex.I * Math.Log(1.0 + Math.Sqrt(2.0))));

            Assert.IsTrue(ComplexMath.Acos(Complex.Zero) == Math.PI / 2.0);
            Assert.IsTrue(ComplexMath.Acos(Complex.One) == Complex.Zero);
            Assert.IsTrue(ComplexMath.Acos(-Complex.One) == Math.PI);
            Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Acos(Complex.I), Math.PI / 2.0 - Complex.I * Math.Log(1.0 + Math.Sqrt(2.0))));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Acos(-Complex.I), Math.PI / 2.0 + Complex.I * Math.Log(1.0 + Math.Sqrt(2.0))));
        }
Beispiel #4
0
        public void ComplexAsinRealAgreement()
        {
            foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 1.0E2, 8))
            {
                Complex z = ComplexMath.Asin(x);

                if (x <= 1.0)
                {
                    Assert.IsTrue(TestUtilities.IsNearlyEqual(z, Math.Asin(x)));
                }
                else
                {
                    double im = Math.Log(x + Math.Sqrt((x - 1.0) * (x + 1.0)));
                    Assert.IsTrue(TestUtilities.IsNearlyEqual(z, new Complex(Math.PI / 2.0, im)));
                }
            }
        }
Beispiel #5
0
        public void ComplexArcTrigExtremeValues()
        {
            double logMax = Math.Log(Double.MaxValue);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(
                              ComplexMath.Asin(Double.MaxValue),
                              new Complex(Math.PI / 2.0, Math.Log(2.0) + logMax)
                              ));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(
                              ComplexMath.Asin(Double.MaxValue * Complex.I),
                              new Complex(0.0, Math.Log(2.0) + logMax)
                              ));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(
                              ComplexMath.Asin(new Complex(Double.MaxValue, Double.MaxValue)),
                              new Complex(Math.PI / 4.0, 1.5 * Math.Log(2.0) + logMax)
                              ));
        }