Example #1
0
 public void IntegralCinReflection()
 {
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 1.0E4, 8))
     {
         Assert.IsTrue(AdvancedMath.IntegralCin(-x) == AdvancedMath.IntegralCin(x));
     }
 }
Example #2
0
 public void IntegralCinDefinition()
 {
     // To avoid cancellation error, near cos(x) ~ 1, use half-angle formula
     //   1 - \cos(x) = 2 \sin^2(x/2)
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 1.0E2, 8))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           FunctionMath.Integrate(t => 2.0 * MoreMath.Sqr(MoreMath.Sin(t / 2.0)) / t, 0.0, x),
                           AdvancedMath.IntegralCin(x)
                           ));
     }
 }
 public void ComplexEinCinSiAgreement()
 {
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-2, 1.0E2, 8))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedComplexMath.Ein(Complex.I * x).Im,
                           AdvancedMath.IntegralSi(x)
                           ));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedComplexMath.Ein(Complex.I * x).Re,
                           AdvancedMath.IntegralCin(x)
                           ));
     }
 }
Example #4
0
 public void IntegralCiCinRelation()
 {
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-4, 1.0, 4))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedMath.EulerGamma + Math.Log(x) - AdvancedMath.IntegralCin(x),
                           AdvancedMath.IntegralCi(x)
                           ));
     }
     foreach (double x in TestUtilities.GenerateRealValues(1.0, 1.0E4, 4))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedMath.EulerGamma + Math.Log(x) - AdvancedMath.IntegralCi(x),
                           AdvancedMath.IntegralCin(x)
                           ));
     }
 }
Example #5
0
 public void IntegralCinSpecialCases()
 {
     Assert.IsTrue(AdvancedMath.IntegralCin(0.0) == 0.0);
 }