Ejemplo n.º 1
0
        public override Complex Value(
            double radius_fm
            )
        {
            double X = DebyeMass_MeV * radius_fm / Constants.HbarC_MeV_fm;

            if (radius_fm == 0)
            {
                return(new Complex(0, 0));
            }
            else if (X <= 10)
            {
                return(new Complex(-(AlphaEff / radius_fm + SigmaOverDebyeMass_fm) * Math.Exp(-X),
                                   -AlphaOverDebyeMass_fm
                                   * (1.0 - 0.5 * (AdvancedMath.IntegralEi(X) * Math.Exp(-X) * (1.0 / X + 1.0)
                                                   + AdvancedMath.IntegralE(1, X) * Math.Exp(X) * (1.0 / X - 1.0)))));
            }
            else
            {
                double X2 = X * X;
                return(new Complex(-(AlphaEff / radius_fm + SigmaOverDebyeMass_fm) * Math.Exp(-X),
                                   -AlphaOverDebyeMass_fm
                                   * (1.0 - (((40.0 / X2 + 1.0) * 18.0 / X2 + 1.0) * 4.0 / X2 + 1.0) * 2.0 / X2)));
            }
        }
Ejemplo n.º 2
0
 public void IntegralE0()
 {
     // A & S 5.1.24
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-4, 1.0E3, 8))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(AdvancedMath.IntegralE(0, x), Math.Exp(-x) / x));
     }
 }
Ejemplo n.º 3
0
 public void IntegralEAtZero()
 {
     // A & S 5.1.23
     foreach (int n in TestUtilities.GenerateIntegerValues(2, 100, 8))
     {
         Assert.IsTrue(AdvancedMath.IntegralE(n, 0.0) == 1.0 / (n - 1.0));
     }
 }
Ejemplo n.º 4
0
 public void IntegralE1Integral()
 {
     // A & S 5.1.33
     Assert.IsTrue(TestUtilities.IsNearlyEqual(
                       FunctionMath.Integrate(t => MoreMath.Sqr(AdvancedMath.IntegralE(1, t)), 0.0, Double.PositiveInfinity),
                       2.0 * Math.Log(2.0)
                       ));
 }
Ejemplo n.º 5
0
 public void IntegralEiE1Integrals()
 {
     // Here are a couple unusual integrals involving both Ei and E1
     // https://nvlpubs.nist.gov/nistpubs/jres/73B/jresv73Bn3p191_A1b.pdf
     Assert.IsTrue(TestUtilities.IsNearlyEqual(
                       FunctionMath.Integrate(x => Math.Exp(-x) * AdvancedMath.IntegralE(1, x) * AdvancedMath.IntegralEi(x), 0.0, Double.PositiveInfinity),
                       -Math.PI * Math.PI / 12.0
                       ));
 }
 public void ComplexEinE1Agreement()
 {
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-3, 1.0E3, 8))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedComplexMath.Ein(x),
                           AdvancedMath.IntegralE(1, x) + AdvancedMath.EulerGamma + Math.Log(x)
                           ));
     }
 }
Ejemplo n.º 7
0
 public void IntegralESpecialCases()
 {
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 4))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(AdvancedMath.IntegralE(n, 0.0), 1.0 / (n - 1)));
         Assert.IsTrue(AdvancedMath.IntegralE(n, Double.MaxValue) == 0.0);
         Assert.IsTrue(AdvancedMath.IntegralE(n, Double.PositiveInfinity) == 0.0);
         Assert.IsTrue(Double.IsNaN(AdvancedMath.IntegralE(n, Double.NaN)));
     }
 }
Ejemplo n.º 8
0
 public void IntegralE1Inequality()
 {
     // A & S 5.1.20
     // Choose maximum x to keep e^x from overflowing.
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-4, Math.Log(Double.MaxValue / 10.0), 8))
     {
         double lower = Math.Log(1.0 + 2.0 / x) / 2.0;
         double upper = Math.Log(1.0 + 1.0 / x);
         double value = Math.Exp(x) * AdvancedMath.IntegralE(1, x);
         Assert.IsTrue((lower < value) && (value < upper));
     }
 }
Ejemplo n.º 9
0
 public void IntegralERecurrence()
 {
     // A & S 5.1.14
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 8))
     {
         foreach (double x in TestUtilities.GenerateRealValues(1.0E-4, 1.0E4, 24))
         {
             Assert.IsTrue(TestUtilities.IsNearlyEqual(
                               n * AdvancedMath.IntegralE(n + 1, x) + x * AdvancedMath.IntegralE(n, x),
                               Math.Exp(-x)
                               ));
         }
     }
 }
Ejemplo n.º 10
0
 public void IntegralEDefinition()
 {
     // A & S 5.1.4
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 4))
     {
         foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 10.0, 8))
         {
             Assert.IsTrue(TestUtilities.IsNearlyEqual(
                               AdvancedMath.IntegralE(n, x),
                               FunctionMath.Integrate(t => Math.Exp(-x * t) / MoreMath.Pow(t, n), 1.0, Double.PositiveInfinity)
                               ));
         }
     }
 }
Ejemplo n.º 11
0
 public void IntegralEInequality()
 {
     // A & S 5.1.19
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 8))
     {
         // Choose maximum x to keep e^x from overflowing.
         foreach (double x in TestUtilities.GenerateRealValues(1.0E-4, Math.Log(Double.MaxValue / 10.0), 8))
         {
             double lower = 1.0 / (x + n);
             double upper = 1.0 / (x + (n - 1));
             double value = Math.Exp(x) * AdvancedMath.IntegralE(n, x);
             Assert.IsTrue((lower < value) && (value <= upper));
         }
     }
 }
Ejemplo n.º 12
0
        public void ComplexEinAgreement () {
            foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 1.0E4, 16)) {
                Console.WriteLine("Ei {0} {1} {2}", x, AdvancedMath.IntegralEi(x), AdvancedMath.EulerGamma + Math.Log(x) - AdvancedComplexMath.Ein(-x));
                if (x < Math.Log(Double.MaxValue / 10.0)) {
                    Assert.IsTrue(TestUtilities.IsNearlyEqual(
                        AdvancedMath.IntegralEi(x),
                        AdvancedMath.EulerGamma + Math.Log(x) - AdvancedComplexMath.Ein(-x)
                    ));
                }
                Console.WriteLine("E1 {0} {1} {2}", x, AdvancedMath.IntegralE(1, x) + AdvancedMath.EulerGamma + Math.Log(x), AdvancedComplexMath.Ein(x));
                Assert.IsTrue(TestUtilities.IsNearlyEqual(
                    AdvancedMath.IntegralE(1, x) + AdvancedMath.EulerGamma + Math.Log(x),
                    AdvancedComplexMath.Ein(x)
                ));
            }

        }