I was trying to make the contour plot on $(v,r)$ axis for planetary motion for different orbits to check for bounded and unbounded motion. This is what I tried

   Derivative[1][r][t]^2 - 0.2`/r[t] + 0.6`/r[t]^2 == k, {k, -10,10}, 
      {Derivative[1][r][t], 0, 100}, {r[t], -5, 5}]

This is what I get as an error

Options expected (instead of {r[t],-5,5}) beyond position 3

I can't figure out what's wrong with that.

  • $\begingroup$ Welcome to Mathematica SE! Please, compare your code the examples of ContourPlot in the documenation. The thrid arguments needs to be a range specification similar to the second. The equation in the first argument needs to be solved, and depend only on k and t. $\endgroup$
    – Johu
    Sep 4 '18 at 17:44
  • $\begingroup$ @Johu I looked on ContourPlot documentation. I could not find a Contour example of a function and its derivative. r[t] and r'[t] in my case. Or should I explicitly write equations of r[t] and r'[t] and solve them ? $\endgroup$
    – aargiee
    Sep 4 '18 at 17:50
  • $\begingroup$ Yes, you have to solve the equation before. Look up DSolve. $\endgroup$
    – Johu
    Sep 4 '18 at 18:03
  • $\begingroup$ @Johu Actually I managed to get it. I changed $r'[t]$ to $v[t]$ and removed k and addded an extra argument in the end {Contours -> 10} and voila I got it. Thanks $\endgroup$
    – aargiee
    Sep 4 '18 at 18:06
  • $\begingroup$ Yes, You are right. This works, because the plotted function is then only a function of $v$ and $r$. Consider answering your own qustion with the solution you found, such that others could later learn from you. $\endgroup$
    – Johu
    Sep 4 '18 at 18:10
ContourPlot[0.5` v[t]^2 - 2/r[t] + 6/r[t]^2,
  {r[t], 0, 100}, 
  {v[t], -0.5, 0.5}, 
  Contours -> 10, ContourShading -> None, ContourLabels -> All

enter image description here

This gives 10 Contours There is no Shading to distinguish them because I want it like that and I have labeled the Contours too for easier identification.

  • $\begingroup$ I hope you do not mind, that I edited the code for the readability, replaced none with None and added the output figure. Keep it up learning Mathematica! $\endgroup$
    – Johu
    Sep 4 '18 at 18:28
  • $\begingroup$ No not at all. I was infact trying to add an image but didn't want to take a screenshot of it $\endgroup$
    – aargiee
    Sep 4 '18 at 18:29
  • $\begingroup$ They are very easy to import. I select the figure in the notebook, click shortcut keys for edit->copy as->bitmap and paste it into import figure dialog box of the form. $\endgroup$
    – Johu
    Sep 4 '18 at 18:31
  • $\begingroup$ Alright. I'll do that next time $\endgroup$
    – aargiee
    Sep 4 '18 at 18:32

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.