Exemplo n.º 1
0
 public void ComplexPowExponent()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 6))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(Math.E, z), ComplexMath.Exp(z)));
     }
 }
 public void ComplexReimannZetaPrimesTest()
 {
     // pick high enough values so that p^-x == 1 within double precision before we reach the end of our list of primes
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0, 100.0, 8))
     {
         Complex zz = z;
         if (zz.Re < 0.0)
         {
             zz = -zz;
         }
         zz += 10.0;
         Console.WriteLine(zz);
         Complex f = 1.0;
         for (int p = 2; p < 100; p++)
         {
             if (!AdvancedIntegerMath.IsPrime(p))
             {
                 continue;
             }
             Complex t = Complex.One - ComplexMath.Pow(p, -zz);
             if (t == Complex.One)
             {
                 break;
             }
             f = f * t;
         }
         Assert.IsTrue(TestUtilities.IsNearlyEqual(1.0 / AdvancedComplexMath.RiemannZeta(zz), f));
     }
 }
Exemplo n.º 3
0
 public void ComplexPowOneHalf()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 16))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, 0.5), ComplexMath.Sqrt(z)));
     }
 }
Exemplo n.º 4
0
 public void ComplexPowSpecialCases()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 10))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, -1), 1.0 / z));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, 0), 1.0));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, 1), z));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, 2), z * z));
     }
 }
Exemplo n.º 5
0
 public void ComplexPow()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 8))
     {
         Complex p = 1.0;
         for (int k = 1; k < 16; k++)
         {
             p *= z;
             Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, k), p));
             Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(z, -k), 1.0 / p));
         }
     }
 }
Exemplo n.º 6
0
        public void ComplexPowSpecialValues()
        {
            Assert.IsTrue(ComplexMath.Pow(Complex.Zero, Complex.Zero) == Complex.One);
            Assert.IsTrue(ComplexMath.Pow(Complex.One, Complex.Zero) == Complex.One);
            Assert.IsTrue(ComplexMath.Pow(-Complex.One, Complex.Zero) == Complex.One);
            Assert.IsTrue(ComplexMath.Pow(Complex.I, Complex.Zero) == Complex.One);
            Assert.IsTrue(ComplexMath.Pow(a, Complex.Zero) == Complex.One);

            Assert.IsTrue(ComplexMath.Pow(Complex.Zero, Complex.One) == Complex.Zero);
            Assert.IsTrue(ComplexMath.Pow(Complex.One, Complex.One) == Complex.One);
            Assert.IsTrue(ComplexMath.Pow(-Complex.One, Complex.One) == -Complex.One);
            Assert.IsTrue(ComplexMath.Pow(Complex.I, Complex.One) == Complex.I);
            Assert.IsTrue(ComplexMath.Pow(a, Complex.One) == a);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(Complex.I, Complex.I), Math.Exp(-Math.PI / 2.0), TestUtilities.RelativeTarget));
        }
Exemplo n.º 7
0
 public void ComplexPowMultiplication()
 {
     Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(a, 2.0) * ComplexMath.Pow(a, 3.0), ComplexMath.Pow(a, 5.0)));
 }
 public void ComplexGammaDuplicationTest()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 16))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(AdvancedComplexMath.Gamma(2.0 * z), ComplexMath.Pow(2.0, 2.0 * z - 0.5) * AdvancedComplexMath.Gamma(z) * AdvancedComplexMath.Gamma(z + 0.5) / Math.Sqrt(2.0 * Math.PI)));
     }
 }