I'm confused to find a set of differential equations of motion of a pair of masses, m1
and m2
joined by a spring of constant k
.
The unstretched length of the spring is L
, and the initial conditions are; x1[0]=0, x2[0]=L+a, x1'[t]=0, x2'[t]=0
. x1[t]
and x2[t]
are the positions of the masses m1
and m2
at any time t
.
I used Lagrangian dynamics to find the differential equations of motion, but I'm not sure my codes are correct. And I have no idea where I need to put the initial conditions to find the differential equations. Can someone help me?
Needs["VariationalMethods`"];
T = 0.5*m1*x1'[t]^2 + 0.5*m2*x2'[t]^2;
V = 0.5*k*(x2[t] - x1[t] - L);
lag = T - V;
eqn[n_] = EulerEquations[lag, {x1[t], x2[t]}, t];
unstretched length of the spring is L
in these problems, since one always starts from the relaxed position. The initial stretched length of the spring is already account for. also the PE in spring is $\frac{1}{2} k x^2$ ? And do you really need a package to do this? You asked same question mathematica.stackexchange.com/questions/43256/… you just need to use the text book formula. One line per one equation. (if you use the textbook formula, I think you'll understand more than using blackbox function) $\endgroup$