public static double BesselKSeries(double a, double x) { if (a == System.Math.Floor(a)) { throw new Exception("a cannot be integer"); } return(0.5 * System.Math.PI / System.Math.Sin(System.Math.PI * a) * (MMath.BesselI(-a, x) - MMath.BesselI(a, x))); }