I am trying to numerically evaluate an integral. I have a function to be integrated, ftbI[s,a] with undetermined variable(s) a. I create a function that evaluates the integral, given the value of this variable, i.e. :


Now, inside of ftbI are other functions. One of these functions is an interpolation between some data points. The integral will integrate up to Inf , so extrapolation will be used, but this is okay.

If I try to evaluate FI[a], the integral gets stuck and doesn't seem to progress. So I try to evaluate just the function ftbI[s,a] at some point, and I get the attached result. Evaluating ftbI

You'll see that there are a bunch of these "interpolatingFunctions" floating around. I am assuming that this is the problem with my Nintegrate. So my question is, what are these interpolatingfunctions? I've tried evaluating the part of ftbI that is the interpolation part that I mentioned above, and it seems to give me a real number anywhere within the region of integration, so I am unclear why my ftbI can't be evaluated properly.

Any guesses as to what is going on here, or things I can try to further explore issue are greatly appreciated. I might be wrong as to the issue of my integration, what I have said is just my guess. Thank you

  • 1
    $\begingroup$ A numeric integration requires all variables to have numeric values, e.g., FI[a_?NumericQ] := Nintegrate[ftbI[s, a], {s, slower, supper}] However, the cause of your problems cannot be determined without the appropriate definitions/code. $\endgroup$
    – Bob Hanlon
    Jul 1 at 22:45
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Jul 2 at 3:34

The problem (as seen in the image of the output) is that you are passing a complex number as an argument to an InterpolatingFunction, which is defined only for real inputs.


Interpolation[Range[5]^2][1 + I]

This returns

Note that InterpolatingFunction does not evaluate to a number, which resembles what appears in the OP's image.

This indicates that the most likely source of the problem is a simple mistake in the definition of ftbI[].

  • $\begingroup$ I see. Is there any sneaky reason you know of that could cause this? I can't figure out how my function is evaluating at a complex point. The function looks approximately like ftbI[x] =...+ Interpolation[x]+.... I am not using complex numbers at all, and x is a real number that I determine. I can provide more details if interested but I am not sure how useful it would be $\endgroup$ Jul 4 at 19:23
  • $\begingroup$ @PhysicsPerson I don't recall seeing it come up before. So it's either in your code or in a latent definition. (A variable's definition will persist until the kernel is Quit[] or the definition is Clear[]-ed. If that's the problem, quitting and restarting the kernel would fix it, unless the definition is in your init.m file.) $\endgroup$
    – Michael E2
    Jul 4 at 19:57

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