Equipotential Curves and Streamlines
Clear[pot,v,x,y,z] pot[x_,y_]:=x y
v=grad2[pot][x,y]
Plot the equipotential curves xy=c.
equipot=ContourPlot[pot[x,y],{x,-5,5},{y,-5,5}, ContourShading->False,
ContourStyle->Dashing[{.02}],AspectRatio->Automatic];Find the streamlines.
Clear[x,y] DSolve[x'[t]/y[t]==y'[t]/x[t],y[t],t]
Clear[x,y];
DSolve[{x'[t]/y[t]==y'[t]/x[t]},y,t];
y=Evaluate[y[t]/.Flatten[%][[1]]]/.x[t]->x;
ySo . . .
y=-Sqrt[x^2+c]. This implies y^2=x^2+c or
x^2-y^2=c
stream=ContourPlot[x^2-y^2,{x,-5,5},{y,-5,5},ContourShading->False,
AspectRatio->Automatic];
Show[equipot,stream];
Notice anything?
Let's look at another one.
Consider the gradient field {2xy,x^2-y^2}. Does it come from a potential? If so, what is the potential?
Consider the gradient field {2xy,x^2-y^2}. Does it ...
Clear[equipot,stream]
equipot=ContourPlot[pot[x,y],{x,-5,5},{y,-5,5}, ContourShading->False,
ContourStyle->Dashing[{.02}],AspectRatio->Automatic];Let's find streamlines. Let's help Mathematica out by separating the variables.
Clear[x,y] DSolve[x'[t]/x[t]==2 y'[t] y[t]/(x[t]^2-y[t]^2),y[t],t]
Clear[x,y]
DSolve[{x'[t]/x[t]==2 y'[t] y[t]/(x[t]^2-y[t]^2)},y,t];
y=Evaluate[y[t]/.Flatten[%][[1]]]/.x[t]->x;
ySo . . .
y=-Sqrt[(1/3 x^3+c)/x]. This implies y^2=1/3 x^2+c/x or
1/3 x^2-y^2+c/x=0. Multiply through by x:
1/3 x^3-xy^2=c
Clear[x,y]
stream=ContourPlot[1/3 x^3-x y^2,{x,-5,5},{y,-5,5},ContourShading->False,
AspectRatio->Automatic];
Show[equipot,stream];
Notice anything yet? Look closer at the "straighter" parts.