public void BesselKRatioExact(int n, double zr, double zi, double cyr, double cyi, int decimalPlaces) { var z = new Complex(zr, zi); var actual = SpecialFunctions.BesselK(n + 1, z, true) / SpecialFunctions.BesselK(n, z, true); AssertHelpers.AlmostEqualRelative(new Complex(cyr, cyi), actual, decimalPlaces); }
public void ComplexBesselKnExact(double v, double zr, double zi, double cyr, double cyi, int decimalPlaces) { AssertHelpers.AlmostEqualRelative( new Complex(cyr, cyi), SpecialFunctions.BesselK(v, new Complex(zr, zi)), decimalPlaces ); }
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 BesselK1Exact(double x, double expected) { AssertHelpers.AlmostEqualRelative(expected, SpecialFunctions.BesselK(1, x), 14); }
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); }