Finding x given y from an interpolating function

I would like to put a dot on the point of a curve that has a specific y value but I don't know the x value.

A simple example of my code is

eqns = {y''[t] + y[t] == 3 a Sin[y[t]], y == y' == 1};
pfun = ParametricNDSolveValue[eqns, y + y, {t, 0, 5}, {a}];
Plot[pfun[a], {a, -2, 2}] So say I want to find the x at which y=3. How? Once I have the two coordinates I know how to add the dot. I guess I'm confused because the interpolating function gives you the y given the x, and I can't figure out how to do the inverse. Also any suggestions of tutorials on how to use interpolating functions would be great. Thanks!

• One comment: the subject should reflect the intent of the question. This one seems to have reversed x and y. – Daniel Lichtblau Jun 11 '13 at 0:01

One way is to use FindRoot

FindRoot[pfun[x] == 3.0, {x, 0}]

Another way is InverseFunction which can be utilised like this

InverseFunction[pfun][3.0]
• Thanks for responding so quickly. I tried the InverseFunction and it gave me InverseFunction[ParametricFunction[<>]] – LiaChica Jun 8 '13 at 12:01
• @Lia, ah, that means ParametricFunction[] is not invertible. Stick with hal's first proposal, then. – J. M. will be back soon Jun 8 '13 at 12:07
• @LiaChica The initial x in FindRoot is sometimes crucial to find the correct solution. Always remember that FindRoot is a local method with stepsize approximations etc where all kinds of bad things can happen. E.g. FindRoot[Sin[x], {x, Pi/2}] gives -8.0*Pi here. So you should have a good understanding of your function. – halirutan Jun 8 '13 at 15:38
• I managed to make FindRoot work once I gave it a specific domain to look in, e.g. FindRoot[pfun[x]==3.0,{x,0,5}] Many thanks! – LiaChica Jun 9 '13 at 9:37

If you do want to use InverseFunction you could make interpolating function via FunctionInterpolation:

f = FunctionInterpolation[pfun[a], {a, -2, 2}];

InverseFunction[f]

(* 0.206407 *)