[TestCase(0, 1E6, 1E6, 0.99999975000000000003, 2.5000006250003125000E-7, 8)] // cf. BesselI(0, 1e6 + 1e6 j) = 7.4E434290 - 6.9E434290 j and BesselI(1, 1e6 + 1e6 j) = 7.4E434290 - 6.9E434290 j public void BesselIRatioExact(int n, double zr, double zi, double cyr, double cyi, int decimalPlaces) { var z = new Complex(zr, zi); var actual = SpecialFunctions.BesselI(n + 1, z, true) / SpecialFunctions.BesselI(n, z, true); AssertHelpers.AlmostEqualRelative(new Complex(cyr, cyi), actual, decimalPlaces); }
public void ComplexBesselInExact(double v, double zr, double zi, double cyr, double cyi, int decimalPlaces) { AssertHelpers.AlmostEqualRelative( new Complex(cyr, cyi), SpecialFunctions.BesselI(v, new Complex(zr, zi)), decimalPlaces ); }
public void BesselI0Approx([Range(-3.75, 3.75, 0.25)] double x) { // Approx by Abramowitz/Stegun 9.8.1 Assert.AreEqual(Evaluate.Polynomial(x / 3.75, 1.0, 0.0, 3.5156229, 0.0, 3.0899424, 0.0, 1.2067492, 0.0, 0.2659732, 0.0, 0.0360768, 0.0, 0.0045813), SpecialFunctions.BesselI(0, x), 1e-7); }
public void BesselK1Approx([Range(0.20, 2.0, 0.20)] double x) { // Approx by Abramowitz/Stegun 9.8.7 Assert.AreEqual(Evaluate.Polynomial(x / 2.0, x * Math.Log(x / 2.0) * SpecialFunctions.BesselI(1, x) + 1.0, 0.0, 0.15443144, 0.0, -0.67278579, 0.0, -0.18156897, 0.0, -0.01919402, 0.0, -0.00110404, 0.0, -0.00004686), SpecialFunctions.BesselK(1, x) * x, 1e-8); }
public void BesselK0Approx([Range(0.20, 2.0, 0.20)] double x) { // Approx by Abramowitz/Stegun 9.8.5 Assert.AreEqual(Evaluate.Polynomial(x / 2.0, -Math.Log(x / 2.0) * SpecialFunctions.BesselI(0, x) - 0.57721566, 0.0, 0.42278420, 0.0, 0.23069756, 0.0, 0.03488590, 0.0, 0.00262698, 0.0, 0.00010750, 0.0, 0.00000740), SpecialFunctions.BesselK(0, x), 1e-8); }
public void BesselInExact(int n, double x, double expected) { AssertHelpers.AlmostEqualRelative(expected, SpecialFunctions.BesselI(n, x), 14); }
public void BesselI1Approx([Range(-3.75, 3.75, 0.25)] double x) { // Approx by Abramowitz/Stegun 9.8.3 Assert.AreEqual(Evaluate.Polynomial(x / 3.75, 0.5, 0.0, 0.87890594, 0.0, 0.51498869, 0.0, 0.15084934, 0.0, 0.02658733, 0.0, 0.00301532, 0.0, 0.00032411) * x, SpecialFunctions.BesselI(1, x), 1e-8); }