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.

  • $\begingroup$ Numerical procedures require the numerical values for all variables. Thus, you can't assign the Infinity as a boundary. $\endgroup$
    – Rom38
    Jul 19 at 7:56
  • $\begingroup$ 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. $\endgroup$
    – Nasser
    Jul 19 at 8:37
  • $\begingroup$ I think your integral has the value BesselK[1,z]. You should be able to verify this numerically. $\endgroup$
    – mikado
    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]}]


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.