I'm using the code:

time = Table[i, {i, 0, 2042, 10.87}];
I1 = Table[Exp[-((i - 1000)^2)/(250)^2], {i, 0, 2042, 10.87}];
I1time = Table[{time[[i]], 10^3 I1[[i]]}, {i, 1, Length[time]}];

I1spline = Interpolation[I1time, Method -> "Spline"]
Int[sx_, sy_] := 
  NIntegrate[I1spline[x] Exp[- (sx + I sy) x], {x, 0, 20}];

sxmin = 0; sxmax = 50; sxInc = 0.5;
symin = -50;  symax = 50; syInc = 0.5; 

DiscreateLT = 
  Flatten[Table[{{sx, sy}, Int[sx, sy]}, {sx, sxmin, sxmax, 
     sxInc}, {sy, symin, symax, syInc}], 1];

LTNOspline = Interpolation[DiscreateLT, Method -> "Hermite"]

This works fine, and generates the function LTNOspline with no problems. But it is not accurate enough for my problem, so I want to use the Spline method instead. However, when I change

LTNOspline = Interpolation[DiscreateLT, Method -> "Hermite"] 


LTNOspline = Interpolation[DiscreateLT, Method -> "Spline"]

in my code, I get the error message

Interpolation::mspl: The Spline method could not be used because the data could not be coerced to machine real numbers.

Any suggestions about how to use the spline interpolation without the error message?

  • $\begingroup$ mathematica.stackexchange.com/questions/24800/… $\endgroup$
    – Young
    Commented Jul 23, 2016 at 18:07
  • 1
    $\begingroup$ My suggestion is to use {sx, sy, Int[sx, sy]} as the 1st argument to Table in the definition of DiscreateLT. I have no way of checking this idea because you don't give all the code needed to duplicate your work. $\endgroup$
    – m_goldberg
    Commented Jul 23, 2016 at 20:52

1 Answer 1


your data is complex and ( I guess) the spline method cannot handle complex numbers. You can separately fit the real and imaginary parts like this:

LTNOsplineRe = 
 Interpolation[MapAt[Re, DiscreateLT, {All, 2}], Method -> "Spline"]
LTNOsplineIm = 
 Interpolation[MapAt[Im, DiscreateLT, {All, 2}], Method -> "Spline"]
LTNOspline = 
 Function[{x, y}, LTNOsplineRe[x, y] + I LTNOsplineIm[x, y]]
  • $\begingroup$ I've implemented your above suggestion and now my code works! Thanks! As you suggested, it would seem that the "Spline" method cannot handle complex data $\endgroup$
    – M.P. WOODS
    Commented Jul 25, 2016 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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