Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using Manipulate and Plot3D to plot a function with two real variables and two extra parameters.

f[x_, y_, alpha_, gamma_] := x*y + alpha*x - Log[Power[x, gamma]*y]   
Manipulate[
    Plot3D[f[x, y, alpha, gamma], {x, 0, 5}, {y, 0, 5}, 
    PlotStyle -> Opacity[0.4]],
    {alpha, -100, 100, 0.1}, {gamma, -100, 
    100, 0.1}]

I want to dynamically highlight/plot the 3D curve (or set of points) of the vanishing partials (D[f, x] == D[f, y] == 0) over the function, and have it update according to the parameter values manipulated.

I know I should probably use NDSolve for this, But I need the solution to be updated and displayed on parameter changes. How do I do that?

share|improve this question
    
maybe, related blog post: blog.wolfram.com/2013/01/08/… –  halmir Mar 15 '13 at 14:01

1 Answer 1

I would use MeshFunctions, although self-intersecting mesh lines usually aren't connected properly. Increasing PlotPoints helps.

g[x_, y_] := Cos[2 x + y] + y^3/2 - y;
Plot3D[g[x, y], {x, -2, 2}, {y, -2, 2}, 
 PlotPoints -> ControlActive[Automatic, 50], MeshStyle -> {Blue, Red},
  MeshFunctions -> {Function[{x, y, z}, Derivative[1, 0][g][x, y]], 
   Function[{x, y, z}, Derivative[0, 1][g][x, y]]}, 
 Mesh -> {{0}, {0}}]

Output of plot

I had already written the example, before your edit adding your code appeared. Here is the principle applied to your code:

f[x_, y_, alpha_, gamma_] := x*y + alpha*x - Log[Power[x, gamma]*y]
Manipulate[
 Plot3D[f[x, y, alpha, gamma], {x, 0, 5}, {y, 0, 5}, 
  PlotStyle -> Opacity[0.4], 
  PlotPoints -> ControlActive[Automatic, 50], 
  MeshStyle -> {Blue, Red}, 
  MeshFunctions -> {Function[{x, y, z}, Derivative[1, 0, 0, 0][f][x, y, alpha, gamma]], 
    Function[{x, y, z}, Derivative[0, 1, 0, 0][f][x, y, alpha, gamma]]}, 
  Mesh -> {{0}, {0}}],
 {alpha, -100, 100, 0.1}, {gamma, -100, 100, 0.1}]
share|improve this answer
    
Thanks @Michael E2 ! And another thing.. How do I keep the same functionality but have alpha and gamma not be arguments of f? –  Dror Mar 15 '13 at 14:37
    
You could put the function definition inside Manipulate and set TrackedSymbols :> {alpha, gamma}. –  Michael E2 Mar 15 '13 at 19:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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