I see this mechanical problem here.

enter image description here

I want to solve this problem with the variational method. The Lagrangian of this system is obtained by subtracting potential energy from kinetic energy.

m = 1;
g = 9.8;
R = 1;
 m*g*R (1 - Cos[θ[t]]) - m*g*R*Cos[θ[t]], θ[
  t], t](*L=T-V or L=kinetic energy - potential energy*)

But the result is $19.6 (\sin (\theta [t]))=0$, which has no significance to solve this problem.

I know that by listing the Lagrangian of this system, we can get the correct equation of motion:

<< VariationalMethods`
L = 1/2 m (R θ'[t])^2 - m g R Cos[θ[t]];
EulerEquations[L, θ[t], t] // 
 FullSimplify[#, Assumptions -> R > 0 && m > 0] &

But before the object moves along the sphere and does not separate, the kinetic energy of the system $ m g R (1-\cos (\theta (t)))=\frac{1}{2} m \left(R \theta '(t)\right)^2$.

I want to know what mistakes I made in listing the following Lagrangian of this system(L= m*g*R (1 - Cos[θ[t]]) - m*g*R*Cos[θ[t]]), and how to use the variational method to solve this problem correctly.

  • 1
    $\begingroup$ what is it you want to "solve" for? Do you want the angle of separation? if so, I can show you how. I solved this same exact problem before. But all by hand, not using the computer, and the package you are using. $\endgroup$
    – Nasser
    Jun 6, 2020 at 10:39
  • 2
    $\begingroup$ @Nasser I think though the question is out of scope of this site (it belongs to physics.SE, I believe), it's relatively clear. OP wants to know what's wrong with the first attempt, and I think I know the answer: "But before the object moves along the sphere and does not separate, the kinetic energy of the system $mgR(1−\cos(θ(t)))=\frac{1}{2}m(Rθ'(t))^2$." This holds only if the initial conditions are $\theta(0)=0$ and $\theta'(0)=0$. If you use these initial conditions for r*θ''[t] == g*Sin[θ[t]], the solution will be $\theta(t)=0$, so the output of the first code sample is correct. $\endgroup$
    – xzczd
    Jun 6, 2020 at 11:35
  • 2
    $\begingroup$ You need to add constraint. So your Lagrangian is missing a constraint $\lambda$. As I said, this is standard problem, was a HW problem for a mechanics class I took few years, and I have the latex solution, but I did not solve it using Mathematica, all by hand. So can't help with using these function you want to use. I can post my solution, but I am afraid it has no Mathematica any thing in it, so I am not sure if one is allowed to do so. If this question was in the Physics form I could do this. $\endgroup$
    – Nasser
    Jun 6, 2020 at 11:42
  • 1
    $\begingroup$ Ok, I can post it. But if someone gets mad, I can tell them you said it is OK to do. $\endgroup$
    – Nasser
    Jun 6, 2020 at 11:47
  • 1
    $\begingroup$ The analysis is just a trivial one based on energy conservation. However, if you ask e.g. "assuming θ[t0]==0, why doesn't L = 1/2 m (R θ'[t0])^2+m*g*R (1 - Cos[θ[t]]) - m*g*R*Cos[θ[t]] work?", as someone never learned about Lagrangian mechanics, I don't know the answer, either. Once again, I believe this should be asked in physics.SE. $\endgroup$
    – xzczd
    Jun 8, 2020 at 6:17

1 Answer 1


This is the problem I solved sometime ago. Same problem as you show. The angle $\theta$ used is measured from x-axis, positive anti-clockwise, as it was simpler to do so, but it does not affect the solution ofcourse. Since there is no Mathematica stuff in this, I can add a Manipulate later on if needed to show the ball falling of?

enter image description here

There are two coordinates $r,\theta$ (polar) which is the position vector of the ball, and one constraint \begin{equation} f\left( r,\theta\right) =r-R=0 \tag{1} \end{equation}

$R$ above is the radius of the hemisphere.

Now we set up the equations of motion for $m$ \begin{align*} T & =\frac{1}{2}m\left( \dot{r}^{2}+r^{2}\dot{\theta}^{2}\right) \\ U & =mgr\sin\theta\\ L & =T-U\\ & =\frac{1}{2}m\left( \dot{r}^{2}+r^{2}\dot{\theta}^{2}\right) -mgr\sin\theta \end{align*} Hence the Euler-Lagrangian equations are (we need to add contraint)

\begin{align} \frac{d}{dt}\frac{\partial L}{\partial\dot{r}}-\frac{\partial L}{\partial r}+\lambda\frac{\partial f}{\partial r} & =0\tag{2}\\ \frac{d}{dt}\frac{\partial L}{\partial\dot{\theta}}-\frac{\partial L} {\partial\theta}+\lambda\frac{\partial f}{\partial\theta} & =0 \tag{3} \end{align} But \begin{align*} \frac{d}{dt}\frac{\partial L}{\partial\dot{r}} & =m\ddot{r}\\ \frac{\partial L}{\partial\dot{\theta}} & =mr^{2}\dot{\theta}\\ \frac{d}{dt}\left( \frac{\partial L}{\partial\dot{\theta}}\right) & =m\left( 2r\dot{r}\dot{\theta}+r^{2}\ddot{\theta}\right) \\ \frac{\partial L}{\partial r} & =mr\dot{\theta}^{2}-mg\sin\theta\\ \frac{\partial L}{\partial\theta} & =-mgr\cos\theta\\ \frac{\partial f}{\partial r} & =1\\ \frac{\partial f}{\partial\theta} & =0 \end{align*} Hence (2) becomes \begin{equation} m\ddot{r}-mr\dot{\theta}^{2}+mg\sin\theta+\lambda=0 \tag{4} \end{equation} And (3) becomes \begin{align} m\left( 2r\dot{r}\dot{\theta}+r^{2}\ddot{\theta}\right) +mgr\cos\theta & =0\nonumber\\ r\ddot{\theta}+2\dot{r}\dot{\theta}+g\cos\theta & =0 \tag{5} \end{align} We now need to solve (1,4,5) for $\lambda$. Now we have to apply the constrain that $r=R$ in the above to be able to solve (4,5) equations. Therefore, (4,5) becomes \begin{align} -mR\dot{\theta}^{2}+mg\cos\theta+\lambda & =0\tag{4A}\\ R\ddot{\theta}+g\cos\theta & =0 \tag{5A} \end{align} Where (4A,5A) were obtained from (4,5) by replacing $r=R$ and $\dot{r}=0$ and $\ddot{r}=0$ since we are using that $r=R$ which is constant (the radius).

From (5A) we see that this can be integrated giving \begin{equation} R\dot{\theta}^{2}+2g\sin\theta+c=0 \tag{6} \end{equation} Where $c$ is constant. Since if we differentiate the above with time, we obtain \begin{align*} 2R\dot{\theta}\ddot{\theta}+2g\dot{\theta}\cos\theta & =0\\ R\ddot{\theta}+g\cos\theta & =0 \end{align*} Which is the same as (5A). Therefore from (6) we find $\dot{\theta}^{2}$ to use in (4A). Hence from (6) $$ \dot{\theta}^{2}=-2\frac{g}{R}\sin\theta+c $$ To find $c$ we use initial conditions. At $t=0$, $\theta=90^{0}$ and $\dot{\theta}\left( 0\right) =0$ hence $$ c=2\frac{g}{R} $$ Therefore \begin{align*} \dot{\theta}^{2} & =-2\frac{g}{R}\sin\theta+2\frac{g}{R}\\ & =2\frac{g}{R}\left( 1-\sin\theta\right) \end{align*} Plugging the above into (4A) in order to find $\lambda$ gives \begin{align*} -mR\left( 2\frac{g}{R}\left( 1-\sin\theta\right) \right) +mg\sin \theta+\lambda & =0\\ \lambda & =m\left( 2g\left( 1-\sin\theta\right) \right) -mg\sin\theta\\ \lambda & =2mg-2mg\sin\theta-mg\sin\theta\\ & =mg\left( 2-3\sin\theta\right) \end{align*} Now that we found $\lambda\,,$we can find the constraint force in the radial direction \begin{align*} N & =\lambda\frac{\partial f}{\partial r}\\ & =mg\left( 2-3\sin\theta\right) \end{align*} The particle will leave when $N=0$ which will happen when \begin{align*} 2-3\sin\theta & =0\\ \theta & =\sin^{-1}\left( \frac{2}{3}\right) \\ & =41.8^{0} \end{align*} Therefore, the angle from the vertical is $$ 90-41.8=48.2^{0} $$

enter image description here


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.