# Manipulate with a function as a parameter

I'm trying to make a Manipulate command to plot the contour lines of a function of two variables $f(x,y)$. I think I should use the "InputField" option somehow, and I thought of something like this:

   Manipulate[
ContourPlot[f[x, y] == 0, {x, -5, 5}, {y, -5, 5}],
{f, #1-#2 &, InputField[_]}]


However, this gives me a slider for $f$, which I don't want, and also changing the function doesn't seem to work.

My question is, how do you work with the Manipulate command when one of the arguments is a function, and more specifically, how do you fix my line of code.

Thanks!

P.S.

I also don't like feeding the function with the # notation, I'd prefer to feed in an expression involving x and y.

Both styles are possible

Row[{
Manipulate[ ContourPlot[ a[x, y] == 0, {x, -5, 5}, {y, -5, 5}], {{a, #1 - #2 &}}],
Manipulate[ ContourPlot[       a == 0, {x, -5, 5}, {y, -5, 5}], {{a, x - y}}]}
]


Edit

Answering your comment below, you may use the function in many ways. Here I numerically solve a differential equation involving it:

Manipulate[
nd = NDSolve[{(a /. y -> y[x]) == y'[x], y[0] == 1}, y, {x, -5, 5}];
GraphicsRow[{
Plot[y[x] /. nd, {x, -5, 5}],
ContourPlot[a == 0, {x, -5, 5}, {y, -5, 5}]}],
{{a, -Cos[y] + Sin[x]^2}}]


• Thanks for your answer. Can this be modified so that the input is still in the elegant terms of x and y, but I can still use it as a function? (i.e. use something like a[x,y]==0). Jul 2, 2015 at 14:10
• @user1337 try Manipulate[ ContourPlot[Evaluate@a, {x, -5, 5}, {y, -5, 5}], {{a, x - y == 0}}] Jul 2, 2015 at 14:14
• Sorry, but to be more specific, what if I want to feed in the function a in terms of x and y, but use it both to plot the contour a[x,y]==0, and to solve the ODE y'[x]==a[x,y[x]]. I mean, working with both a[x,y] and a[x,y[x]] in the same Manipulate, while the UI still in nice symbolic form. Jul 2, 2015 at 14:17
• Actually, the follow up question is far too big to be discussed in the comments. I'll post it separately. Thanks again. Jul 2, 2015 at 14:26
• @user1337 Yep. I think so too. Thanks for the accept Jul 2, 2015 at 14:36