0

I define function

g[x_] := NIntegrate[Tanh[x y]/(y^2 + 1), {y, 0, \[Infinity]}]

g[1] = 1.04826. But g[x]/.{x->1} gives error: NIntegrate::inumr: The integrand Tanh[x y]/(1+y^2) has evaluated to non-numerical values for all sampling points in the region with boundaries {{\[Infinity],0.}}. I use this function in another numerical integration and obtain the same error. How to avoid this problem?

corey979
  • 23,947
  • 7
  • 58
  • 101
nail
  • 189
  • 7
  • 3
    Since the definition of g uses numeric techniques, its arguments should be restricted to numeric values: g[x_?NumericQ] := NIntegrate[Tanh[x y]/(y^2 + 1), {y, 0, Infinity}] – Bob Hanlon Sep 22 '16 at 23:47
  • 3
    See http://mathematica.stackexchange.com/questions/18393/what-are-the-most-common-pitfalls-awaiting-new-users/26037#26037 – Michael E2 Sep 22 '16 at 23:49

0 Answers0