How to find the Lagrangian of this system? I am trying to find the Lagrangian $L$ of a system I am studying. The equations of motion is:
$$\left\{
\begin{array}{c l} 
     r \ddot{\phi} + 2\dot{r} \dot{\phi}+k(r) \cdot r \dot{r} \dot{\phi} = 0\\
     \ddot{r} - r \dot{\phi}^2 - k(r) \cdot r^2 \dot{\phi}^2 = 0
\end{array}\right.$$
I have tried a general Ansatz $L=L_1+L_2=\Sigma_{m,n,p,q} C_{m,n,p,q} r^m \dot{r}^n \phi^p 
 \dot{\phi}^q+L_2(k(r))$ and plugged into the Euler-Lagrange equation but find the calculation extremely tedious. Is there some systematic way to find it?
I'd really appreciate any hints. Thank you!

Update:
By a little bit rearrangement,
$$\left\{
\begin{array}{c l} 
     \ddot{\phi} + F(r) \dot{r} \dot{\phi}= 0\\
     \ddot{r} +G(r) \dot{\phi}^2 = 0
\end{array}\right.$$
where
\begin{equation}
F(r)=\frac{2}{r} + k(r), \quad G(r)=-(r+k(r)\cdot r^2)
\end{equation}
If we assume
$$L=A(r) \dot{r}^2 + B(r) \dot{\phi}^2 +C(r) \dot{r} \dot{\phi}$$
(so that I can get the metric easily)
Then
$$\left\{
\begin{array}{c l} 
     \mathscr{L}_r L = 2A \ddot{r} -B_r \dot{\phi}^2+C\ddot{\phi} +A_r \dot{r}^2\\
     \mathscr{L}_\phi L = 2B \ddot{\phi} +2B_r \dot{r}\dot{\phi}+C_r\dot{r}^2 + C \ddot{r}
\end{array}\right.$$
where $\mathscr{L}_q L \equiv \frac{d}{dt} \left(\frac{\partial{L}}{\partial{\dot{q}}}\right)-\frac{\partial{L}}{\partial{q}}$
By comparison with the EOM, it requires
$$\frac{2A}{1}= \frac{-B_r}{G(r)}, \quad \frac{2B}{1}=\frac{2B_r}{F(r)}, \quad C=0, \quad A_r=0$$
It seems fine except for $A_r=0$ is conflicting with the others.
 A: We want to find the metric for these equations:
\begin{align*}
  &\ddot{\varphi} +F(r)\,\dot{\varphi}\,\dot{r}=0&(1) \\
  &\ddot{r}  +G(r)\,\left(\dot{\varphi}\right)^2=0&(2)
\end{align*}
$\textbf{Theory}$
The equations of motions are: (I use the NEWTON EULER method )
\begin{align*}
  &J^T J \,\ddot{\vec{q}}  =- J^T\,\frac{\partial\left( J\,\dot{\vec{q}}\right)}{\partial\vec{q}}\,\dot{\vec{q}}+J^T\,\vec{f_a}&(3)\\
\end{align*}
With vector $\vec{q}$ of the generalized coordinates:
\begin{align*}
\vec{q}=
   \begin{bmatrix}
     \varphi \\
      r \\
   \end{bmatrix}
\end{align*},
the Jacobi-Matrix (Ansatz):
\begin{align*}
  J&=
  \begin{bmatrix}
    r & 0 \\
    \varphi & 1 \\
  \end{bmatrix}
\end{align*}
and the vector $\vec{f_a}$ of the external forces (Ansatz):
\begin{align*}
\vec{f_a}=
   \begin{bmatrix}
     0 \\
      -\frac{\varphi}{r}\,\dot{\varphi}\,\dot{r} \\
   \end{bmatrix}
\end{align*}
We get the equation of motions (with (3)):
\begin{align*}
  &\ddot{\varphi} +\frac{1}{r}\,\dot{\varphi}\,\dot{r}=0& (4)\\
  &\ddot{r}  +\left(\dot{\varphi}\right)^2=0&(5)
\end{align*}
Compare the coefficients of equation (1) with (4) and (2) with (5) we get:
\begin{align*}
  F(r) & =\frac{2}{r}+k_1(r)\overset{!}{=}\frac{1}{r} \,\Rightarrow\quad
  k_1(r)=-\frac{1}{r}\\
  G(r) &=-\left(r+k_2(r)\,r^2\right)\overset{!}{=}1\,\Rightarrow\quad
  k_2(r)=-{\frac {r+1}{{r}^{2}}}
\end{align*}
To fulfill the equations (1) and (2)   I have to take two functions $k_1(r)$ and $k_2(r)$.
$\textbf{Metric}:$
\begin{align*}
&g=J^T\,J=
\begin{bmatrix}
  r^2+\varphi^2 & \varphi \\
  \varphi & 1
\end{bmatrix}
\end{align*}
