# NIntegrate with variable in it

I would like to NIntegrate with a variable in the function. Later I will be series expanding it. Can it be done in Matehematica? I am getting errors for a sample integration as,

NIntegrate[Series[Cosh[x]*Exp[-z*Cosh[x]], {z, 0, 2}], {x, 0, \[Infinity]}]

The error is,

NIntegrate::inumr: The integrand Cosh[x]-Cosh[x]^2 z+1/2 Cosh[x]^3 z^2+O[z]^3 has evaluated to non-numerical values for all sampling points in the region with boundaries {{\[Infinity],0.}}.

Is there a way out? I know that, analytically, I can obtain expressions in terms of modified Bessel functions of second kind. But Mathematica does not pick that up.

• Numerical procedures require the numerical values for all variables. Thus, you can't assign the Infinity as a boundary. Jul 19 at 7:56
• The integral diverges for all real z. You can see that by doing ser = Normal[Series[Cosh[x]*Exp[-z*Cosh[x]], {z, 0, 2}]]; res = Integrate[ser, x]; Limit[res, x -> Infinity, Assumptions -> Element[z, Reals]]  or by plotting res for different values of z. Jul 19 at 8:37
• I think your integral has the value BesselK[1,z]. You should be able to verify this numerically. Jul 20 at 14:06

If I correctly understand the question, you ask about the asymptotic of the integral $$\int_0^\infty \cosh (x) \exp (-z \cosh (x))\,dx$$ as $$z\to 0$$ and/or $$z->\infty$$. Unfortunately, Mathematica 12.3 fails with that integral: Integrate[Cosh[x] Exp[-z Cosh[x]], {x, 0, \[Infinity]}, Assumptions -> z > 0] returns the input. The integral under consideration can be calculated numerically by

f[z_?NumericQ] := NIntegrate[Cosh[x] Exp[-z Cosh[x]], {x, 0, \[Infinity]}]
f[0.01]


99.9739

Unfortunatelly, the Series command does not work with f[z]. One may investigate the asymptotic of f[z] as z tends to 0 from above in such a way

Table[f[Exp[-k]]/Exp[k], {k, 1, 20}]


{0.887927, 0.975973, 0.995517, 0.999226, 0.999873, 0.99998, 0.999997, \ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}

The above result suggests that f[z] is asymptotically equal to 1/z as z approaches 0 from above. I think this can be proven by Laplace's method which is not currently implemented in Mathematica.