I am trying to apply NSolve to an Interpolation function which I have evaluated before. For a function of 1 argument everything works out but as soon as I try to apply the procedure for a function of 2 arguments Mathematica throws an error message at me. Here is my code

t1 = ListInterpolation[Table[x^2 + y^2, {x, 0, 2, .1}, {y, 0, 2, .1}], {{0, 2}, {0, 2}}];

FindRoot[t1[x, x] == 1, {x, 1}]

NSolve[t1[x, x] == 1, x]

FindRoot works but for NSolve mathematica does not evaluate the interpolation function.


t1 = ListInterpolation[
   Table[x^2 + y^2, {x, 0, 2, .1}, {y, 0, 2, .1}],
   {{0, 2}, {0, 2}}];

For the case where both arguments are the same, define a single-argument function

f[x_?NumericQ] := t1[x, x]

NSolve[f[x] == 1, x]

enter image description here

  • $\begingroup$ Thanks, it worked. Is there a possibility to store the InterpolationFunction in a kind of true function and work directly with it? $\endgroup$ – ricoschmidt_ber Sep 16 at 14:37
  • $\begingroup$ Look at NonlinearModelFit or related fitting functions. $\endgroup$ – Bob Hanlon Sep 16 at 14:42

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.