I'm trying to plot this equation of motion for a pendulum with a periodically applied torque for 20 cycles,enter image description here

where b, m, L, g are given constant values.

{y''[t]==-(b/(m*L^2))*y'[t] - (g/L)*y[t] + T*cos{x[t]]/(m*L^2),

xSolution = periodic[20,Pi,1,0.22,1,1,1,1,1]


I believe Mathematica won't solve this since there are two different variables in the equation. How can I use the NDSolveValue command to solve this equation and plot the results?

  • $\begingroup$ Do you have definition of x[t]? Or is it also supposed to be solved as a second differential equation? If so then what is that second equation? You also have Sovle, not Solve and a { that should probably be a [. Those are not a promising start in a language that is as demanding of correctness as Mathematica. $\endgroup$ – Bill Oct 22 '14 at 3:02
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Oct 22 '14 at 3:12
  • $\begingroup$ You can paste your code in, instead of typing it. You'll probably have fewer typos. In case it's not a type, cosine is Cos with a capital C. $\endgroup$ – Michael E2 Oct 22 '14 at 3:18
  • $\begingroup$ This works, DSolve[{y''[t] == -(b/(m*L^2))*y'[t] - (g/L)*y[t] + T*Cos[Ω t]/(m*L^2), y'[0] == y1, y[0] == y2}, y, t], which is the DE you quote. Like Bill, I don't understand the role of x[t]. The equations do not completely define what x[t] equals. $\endgroup$ – Michael E2 Oct 22 '14 at 3:21
  • $\begingroup$ NDSolveValue is mispelled. $\endgroup$ – lurscher Oct 22 '14 at 3:30

Your code for your model is wrong. As others are saying, your forcing function is $\cos(\omega t)$. Therefore, you simply use NDSolve to obtain solution.

eq =theta''[t] + b/(m L0^2) theta'[t] + g/L0 Sin[theta[t]] -T0 Cos[w t]/(m L0^2);
ic = {theta'[0] == Pi, theta[0] == 1};
b = 0.22;
m = 1;
L0 = 1;
g = 9.8;
w = 1;
T0 = 1;
sol = First@NDSolve[{eq == 0, ic}, theta[t], {t, 0, 10}];
Plot[theta[t] /. sol, {t, 0, 10}, PlotTheme -> "Detailed"]

Mathematica graphics


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.