4
$\begingroup$

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?

$\endgroup$
1
4
$\begingroup$

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}]
$\endgroup$
2
  • $\begingroup$ Thanks @Michael E2 ! And another thing.. How do I keep the same functionality but have alpha and gamma not be arguments of f? $\endgroup$
    – user76568
    Mar 15 '13 at 14:37
  • $\begingroup$ You could put the function definition inside Manipulate and set TrackedSymbols :> {alpha, gamma}. $\endgroup$
    – Michael E2
    Mar 15 '13 at 19:35

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.