# Equation of motions for simple pendulum in cartesian coordinates instead of generalized coordinates [closed]

I am trying to write the equation of motions for a simple pendulum but instead of writing them in generalized coordinates ($$\theta$$), I want to write them in cartesian coordinates (x, y), as I will need them later for further research.

I am writing this matrix in python and it's driving an openGL simulator, this is how I am testing it.

I think my constraint equations are wrong. This is the problem definition I have:

I have a simple pendulum, hinged at (0,0), with an arm of length L with no mass, and on the other end at position (x,y) there is a mass m. The two forces applied on m are g (pointing downards) (0, -g) and $$F_{pend}$$ (pointing to 0,0) ($$F_{pend}^x, F_{pend}^y$$)

The 4 unknowns are $$\ddot x, \ddot y, F_{pend}^x, F_{pend}^y$$.

Newton's Law gives us the first two equations:

$$m \ddot x - F_{\text{pend}}^x = 0$$

$$m \ddot y - F_{\text{pend}}^y = -mg$$

The constraint on the length of the arm gives us the third equation, after taking the second derivative:

$$x^2 + y^2 - l^2 = 0$$

$$2 x \dot x + 2 y \dot y = 0$$

$$2 \dot x^2 + 2 x \ddot x + 2 \dot y^2 + 2 y \ddot y = 0$$

$$x \ddot x + y \ddot y = - \dot x^2 - \dot y^2$$

At this point I need the 4th equation, which I have no idea what it could be. I currently think is:

$$F_{pend} · \langle-y, x\rangle = 0$$

$$F_{pend}^x (- y) + F_{pend}^y (x) = 0$$

This makes the matrix Ax=b for which we can run it to compute x:

$$A = \begin{bmatrix} m & 0 & -1 & 0\\ 0 & m & 0 & -1\\ x & y & 0 & 0\\ 0 & 0 & -y & x \end{bmatrix}$$

$$x^T = \begin{bmatrix} \ddot x & \ddot y & F_{pend}^x & F_{pend}^y \end{bmatrix}$$

$$b^T = \begin{bmatrix} 0 & -mg & - \dot x^2 - \dot y^2 & 0 \end{bmatrix}$$

The way I run the simulator is the following:

Initialize: $$(x, y) = (-L, 0)$$, $$(\dot x, \dot y) = (0, 0)$$, $$dt = 0.001$$

Loop forever:

• Run matrix to compute $$(\ddot x, \ddot y)$$
• Update position $$(x, y) = (x, y) + (\dot x, \dot y) * dt$$
• Update velocity $$(\dot x, \dot y) = (\dot x, \dot y) + (\ddot x, \ddot y) * dt$$

I know this is wrong because when I run this in the simulator I get a very weird motion that looks nothing like a pendulum and the mass drops forever.

Could anyone help me in finding the 4th equation, or even tell me if there are errors in my reasoning?

• You can try a different version of your second equation:$$x=\sqrt(l^2 -y^2)$$, since your current one contains no information about the length $l$ (I am not sure it makes a difference because I was not able to find other solutions to equation 3, but you can try). Moreover, your 4-the equation should contain the velocity and not the positions (I know that the orthogonal vector will be given by that, but it might be easier to debug if you have a problem updating something).What are the initial conditions you used for the pendulum force and did you plot the evolution of the force of the pendulum?
– JGBM
Jan 20, 2021 at 12:09
• I don't have initial conditions for the pendulum force as I don't ned to keep track of it. From my understanding after I solve for x the system Ax=b, I can just take care of $\ddot x$ and $\ddot y$. Jan 20, 2021 at 12:59
• And how do you solve Ax=b?
– JGBM
Jan 20, 2021 at 13:23
• Ok I think I solved it. There was a mismatch in how openGL was displaying the coordinates of the arm and the mass. Jan 20, 2021 at 13:26
• I solve Ax=b as x=numpy.linalg.solve(A, b) Jan 20, 2021 at 13:26

If the goal is to obtain the movement equations in cartesian coordinates a good procedure is to use the lagrarangian formulation. Thus calling $$p=(x,y)$$ we have

$$L = \frac 12 m \dot p\cdot\dot p - m g (y-l_0)+\lambda(x^2+y^2-l_0^2)$$

The movement equations give

$$\cases{ m\ddot x - 2\lambda x = 0\\ m\ddot y -2\lambda y + m g = 0\\ x^2+y^2-l_0^2=0 }$$

now deriving the last equation twice regarding $$t$$ and solving for $$\ddot x,\ddot y,\lambda$$ we have

$$\left\{ \begin{array}{rcl} l_0^2x''(t) & = & x(t) \left(g y(t)-x'(t)^2-y'(t)^2\right) \\ l_0^2y''(t) & = & y(t) \left(x'(t)^2+y'(t)^2\right) - g x(t)^2\\ 2l_0^2\lambda & = & m \left(g y(t)-x'(t)^2-y'(t)^2\right) \\ \end{array} \right.$$

here $$\lambda$$ represents the tension on the rope.