L.S.
Currently for my course in Continuum Mechanics, I am asked to calculate the force potential in the configuration as shown in the picture. First I will introduce the full problem, then show my calculations. I hope somebody can help me and show my error as it is hard to get in contact with my professors.
The mechanism is made up of two solid bars, the long one has a length $L$, the short one a length of $L/2$. The reference system used is $\{\mathbf{e}_x, \mathbf{e}_y\}$. One end is locked along $\mathbf{e}_x$ and $\mathbf{e}_y$, the other end is only allowed to slide along $\mathbf{e}_x$. At the connection between the two bars, a torsion spring with a stiffness $\kappa$ is acting. The spring is associated with an angle $\gamma$ and is unstretched for an angle $\gamma_0$. A force $P$ is applied to the mechanism and a mass $m$ is hanging from the end of the long bar. Under the action of the forces, the mechanism moves and its movements are described using an angle $\beta$.
Now my task is to compute the force potential $\mathcal{F}$ associated with forces on the mechanism as a function of $L$, $m$, $\beta$.
\begin{equation} \mathcal{F} = -W_E \end{equation} \begin{equation} W_E = W_P + W_{mg} = \int \mathbf{P} \cdot \text{d}\mathbf{r}_P + \int m\mathbf{g} \cdot \text{d}\mathbf{r}_{mg} \end{equation} \begin{equation} = \int_{\beta_0}^{\beta} \mathbf{P} \cdot \frac{\text{d}(\mathbf{r}_P)}{\text{d}\beta}\text{d}\beta + \int_{\beta_0}^{\beta} m \mathbf{g} \cdot \frac{\text{d}(\mathbf{r}_{mg})}{\text{d}\beta}\text{d}\beta \end{equation}
From the picture I can make out the following position- and forcevectors:
\begin{equation} \mathbf{P} = [-P, 0]^T \end{equation} \begin{equation} \mathbf{g} = [0, -g]^T \end{equation}
\begin{equation} \mathbf{r}_P = L[\cos(\beta), 0]^T \Longrightarrow \frac{\text{d}(\mathbf{r}_P)}{\text{d}\beta} = L[-\sin(\beta), 0]^T \end{equation}
\begin{equation} \mathbf{r}_{mg} = L[\cos(\beta), \sin(\beta)]^T \Longrightarrow \frac{\text{d}(\mathbf{r}_{mg})}{\text{d}\beta} = L[-\sin(\beta),\cos(\beta)]^T \end{equation}
Now if we put this together, we now get
\begin{equation} \mathcal{F} = -W_E = -\left(\left( PL\int_{\beta_0}^{\beta} \sin(\beta) \text{d}\beta \right)+ \left( -mgL\int_{\beta_0}^{\beta} \cos(\beta) \text{d}\beta \right)\right) \end{equation}
If we evaluate the integrals we get
\begin{equation} PL\int_{\beta_0}^{\beta} \sin(\beta) \text{d}\beta = -PL \cos{\beta} \vert_{\beta=\beta_0}^{\beta} \end{equation}
\begin{equation} -mgL\int_{\beta_0}^{\beta} \cos(\beta) \text{d}\beta = -mgL\sin{\beta} \vert_{\beta=\beta_0}^{\beta} \end{equation}
And this gives us \begin{equation} \mathcal{F} = PL (\cos(\beta) - \cos(\beta_0)) + mgL(\sin(\beta) - \sin(\beta_0)) \end{equation}
However the answer the textbook gives me is
\begin{equation} \mathcal{F} = PL (\cos(\beta) - \cos(\beta_0)) - mgL(\sin(\beta) - \sin(\beta_0)) \end{equation}
I believe I have made a mistake in the definition of the position vectors $\mathbf{r}_p$ and/or $\mathbf{r}_{mg}$, but I can't find my mistake.