I am a completely new to Mathematica, and I am sorry if this question is dumb. I have to solve a system of two second order non linear coupled differential equations (that I got from the Lagrangian equation of motions for a particular system). The following is my code: I hope it is clear.

  -29.4 + 9.8 Cos[y[t]] + x[t] Derivative[1][y][t]^2 - 4 x''[t] == 0,   
  9.8 Sin[y[t]] + 2 Derivative[1][x][t] Derivative[1][y][t] + x[t] y''[t] == 0, 
  x[0] == 1, y[0] == 1.57, Derivative[1][x][0] == 0, 
  Derivative[1][y][0] == 29.4
 {x[t], y[t]}, {t, 0.1}

But I am getting exactly the same output as the input. Mathematica is returning the same piece of code.

  • $\begingroup$ I edited the code (it works now), please check if I got it right. $\endgroup$ – b.gates.you.know.what Sep 6 '12 at 16:52
  • $\begingroup$ @b.gatessucks While correcting the code probably helped the poster, you have actually obscured the problem itself for the other readers. For cases like this it might be better to provide your insights in comments or as an actual answer. $\endgroup$ – Sjoerd C. de Vries Sep 6 '12 at 17:06
  • $\begingroup$ @SjoerdC.deVries Will do, thanks. $\endgroup$ – b.gates.you.know.what Sep 6 '12 at 17:09
  • 4
    $\begingroup$ Dear ramanujan_dirac. I'd like to welcome you on Mathematica.SE. I would also like to ask you to solve the very basic questions (e.g., how to enter code into Mathematica, like you did below Verde's question) yourself using the quickstart guides that Mathematica provides. If you encounter any problems in that process, feel free to ask. $\endgroup$ – Sjoerd C. de Vries Sep 6 '12 at 17:10
  • 2
    $\begingroup$ Also, please note that crossposting on other SE sites (like you did here) is frowned upon. It scatters answers around and makes it more difficult for other users to find a complete answer. $\endgroup$ – Sjoerd C. de Vries Sep 6 '12 at 19:40
s = NDSolve[{-29.4 + 9.8 Cos@y[t] +    x[t] y'[t]^2 - 4 x''[t] == 0, 
                     9.8 Sin@y[t] + 2 x'[t] y'[t]   + x[t]  y''[t] == 0,  
           x[0] == 1, y[0]  == 1.57, 
          x'[0] == 0, y'[0] == 29.4}, 
         {x[t], y[t]}, {t, 0.7}]
ParametricPlot[{x[t], y[t]} /. s, {t, 0, .7}, Evaluated -> True]

Mathematica graphics


For the derivatives:

Plot[{x[t] /. s, Dt[x[t] /. s, t]}, {t, 0, 1}, Evaluated -> True]

Mathematica graphics

  • $\begingroup$ Oh. How did you do this? Where do I enter the code actually? I myself entered it by create new -> package, and entered it in the input. Is this correct? Also, can I get a polynomial approximated function as the solution. $\endgroup$ – user2223 Sep 6 '12 at 16:59
  • $\begingroup$ OK. I got it. Thanks for the trouble. $\endgroup$ – user2223 Sep 6 '12 at 17:03
  • $\begingroup$ How can I get the graphs of x vs t, and y vs t? $\endgroup$ – user2223 Sep 9 '12 at 3:40
  • $\begingroup$ OK. I tried this command Plot[Evaluate[x'[t]/.s],{t,0,.7}], with x prime replaced by x, for the x vs t graph and it worked. But it is not giving me an answer for x prime itself. The graph is blank. $\endgroup$ – user2223 Sep 9 '12 at 4:07
  • $\begingroup$ @ramanujan_dirac See edit. Please remember to upvote and accept answers, try also to answer questions, and read the faq of the site. $\endgroup$ – Dr. belisarius Sep 9 '12 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy