# If function's argument is close to an integer how to choose the function definition for the integer argument? [duplicate]

I have the following function which is expressed through the numerical integration

F1[\[Nu]_?NumericQ, x_?NumericQ] :=
Exp[-x/2]/\[Pi] NIntegrate[
Exp[- (x/2) Cos[t]] Cos[\[Nu]*t], {t, 0, \[Pi]}]


If the first argument is an integer the integral is exressed through the Bessel function:

F1[\[Nu]_?IntegerQ, x_] := (-1)^\[Nu] E^(-x/2) BesselI[\[Nu], x/2]


So

F1[1, x^2]


yields

-E^(-(x^2/2)) BesselI[1, x^2/2]


But

F1[1., x^2]


is returned unevaluated:

F1[1., x^2]


How to define F1 so that it would return (-1)^\[Nu] E^(-x/2) BesselI[\[Nu], x/2] if \[Nu] is close to an integer within given accuracy? One solution is evident:

F1[\[Nu]_ /; Abs[Round[\[Nu]] - \[Nu]] < 10^-10, x_] :=
Cos[\[Pi] \[Nu]] E^(-x/2) BesselI[Round[\[Nu]], x/2]


Is there a better solution?

By the way, the integral can be expressed through the hypergeometric function,

F3[\[Nu]_, x_] :=
HypergeometricPFQRegularized[{1, 1/2}, {1 - \[Nu], 1 + \[Nu]}, -x]


but Mathematica don't know that.

My question is motivated by the fact that the hypergeometric function for big arguments is evaluated more slow than numerical integration, and numerical integration is slow for integer \[Nu].

You could simply put the following before the F1[ν_?NumericQ, ...] definition:
epsilon = 10^-6  (* Replace with whatever tolerance you'd like to use *)

You might want to make sure to clear out old definitions with ClearAll[F1] first.