0
$\begingroup$

I cannot understand why I cannot reproduce an example given in the NDSolve command help.

Namely I would like to plot the steepest ascent path on the surface $z = x^2-y^2$, starting from the point $(0,-1)$. I try to solve the system of differential equations for the gradient flow

  s = NDSolve[{x'[t] == 2*x[t], y'[t] == -2*y[t], x[0] == 0, 
   y[0] == -1}, {x, y}, {t, 20}]

but when I issue the command, as in the command help

ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, 20}]

the axes appear, but not the expected plot, a segment from $(-1,0)$ to $(0,0)$, thanks for any hint

$\endgroup$
2
$\begingroup$

Adding a PlotRange seems to work for me:

ParametricPlot[
 Evaluate[{x[t], y[t]} /. s],
 {t, 0, 20},
 ImageSize -> 400,
 PlotRange -> {-2, 2},
 PlotStyle -> AbsoluteThickness[3]
]

Parametric plot with plot range specified.

$\endgroup$
  • $\begingroup$ I would love to understand why Plot Range is not needed in the NDSolve command help.. $\endgroup$ – Smerdjakov May 6 at 18:07
  • $\begingroup$ @Smerdjakov I don't think PlotRange is needed in general. I think it might be just because the ratio of line width to height is 0:1 and ParametricPlot isn't expecting that? I'm not totally sure though, sorry. $\endgroup$ – MassDefect May 6 at 18:22

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.