Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
I edited the code (it works now), please check if I got it right. – b.gatessucks Sep 6 '12 at 16:52
@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. – Sjoerd C. de Vries Sep 6 '12 at 17:06
@SjoerdC.deVries Will do, thanks. – b.gatessucks Sep 6 '12 at 17:09
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. – Sjoerd C. de Vries Sep 6 '12 at 17:10
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. – Sjoerd C. de Vries Sep 6 '12 at 19:40

1 Answer 1

up vote 1 down vote accepted
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

share|improve this answer
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. – user2223 Sep 6 '12 at 16:59
OK. I got it. Thanks for the trouble. – user2223 Sep 6 '12 at 17:03
How can I get the graphs of x vs t, and y vs t? – user2223 Sep 9 '12 at 3:40
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. – user2223 Sep 9 '12 at 4:07
@ramanujan_dirac See edit. Please remember to upvote and accept answers, try also to answer questions, and read the faq of the site. – belisarius has settled Sep 9 '12 at 4:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.