# NDSolveValue with a multiple variable equation

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

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

periodic[tmax_,y1_,y2_,b_,m_,L_,g_,x0_,T_]:=
NDSovleValue[
{y''[t]==-(b/(m*L^2))*y'[t] - (g/L)*y[t] + T*cos{x[t]]/(m*L^2),
y'[0]==y1,
y[0]==y2,
x[0]==x0,
y,
{t,0,tmax}]

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

Plot[xSolution[t],{t,0.20}]


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?

• 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. – Bill Oct 22 '14 at 3:02
• 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! – Michael E2 Oct 22 '14 at 3:12
• 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. – Michael E2 Oct 22 '14 at 3:18
• 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. – Michael E2 Oct 22 '14 at 3:21
• NDSolveValue is mispelled. – 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"]