Point particle sliding down an arbitrary curve (no departure) Consider a point-particle $p$ on an arbitrary curve defined by the function $f(x)$. It's constrained to always live within the curve. I.e; it always has coordinates $(x, f(x))$ and hence cannot "fly off". It experiences gravity and friction.

I'd be surprised if this hasn't been asked yet, but I'm baffled that not only can I not seem to derive a differential equation that describes the system, but I cannot find an answer that includes both friction and the constraint that it's bounded to the curve.
This question describes a similar scenario, however that system is frictionless and (as far as I can tell) doesn't constrain the particle to the curve.
My attempt
First things first, the kinematics is highly dependent on the instantaneous angle of the curve $\theta$, which can be defined through the identity $\tan\theta=\frac{dy}{dx}$, relating it to the slope. Before that's used, it's relatively trivial to find the net acceleration in each the $x$ and $y$ directions.
$$\Sigma_xF=|F_g|\sin\theta-|F_f|\cos\theta$$
$$\Sigma_xF=mg\sin\theta-\mu mg\cos\theta$$
$$\implies a_x=g(\sin\theta-\mu \cos\theta)$$
$$\Sigma_yF=|F_n|\cos\theta-|F_g|$$
$$\Sigma_yF=mg\cos^2\theta-mg$$
$$\implies a_y=-mg\sin^2\theta$$
(Where $F_g$ is the force of gravity, $g$ is the acceleration of gravity, $F_f$ is the force of friction, $\mu$ is the coefficient of friction, $m$ is the mass, and $F_n$ is the normal force.)
I assume the next steps are to substitute trigonometric identities such as
$$\cos(\theta)=\cos\Big(\tan^{-1}\Big(\frac{dy}{dx}\Big)\Big)=\frac{\frac{dy}{dx}}{\sqrt{\Big(\frac{dy}{dx}\Big)^2+1}}$$
and differentiation rules such as
$$\frac{dy}{dx}=\frac{\frac{dy}{dt}}{\frac{dx}{dt}}$$
to finally find a time-dependent equation for the motion of $p$ along the $x$-axis (because it's vertical coordinate is dependent on it's $x$-coordinate, by the curve-bounding constraint). However it's at this point my brain shuts off and I can't remember basic calculus and kinematics; especially with the added difficulty of not allowing the particle to fly off the curve. Beyond the scope of my question, is this still solvable if $f$ is also dependent on time?
 A: Start with the position  vector to the particle
$$\mathbf R=\left[ \begin {array}{c} x\\ f \left( x \right) 
\end {array} \right] 
$$
from here
the velocity
$$\mathbf v=\left[ \begin {array}{c} {\dot x}\\  \left( {\frac 
{d}{dx}}f \left( x \right)  \right) {\dot x}\end {array} \right] 
$$
the kinetic energy
$$T=\frac m2 (v_x^2+v_y^2)$$
the potential energy
$$U=-m\,g\,f(x)$$
and with Euler Langrage  the equation of motion
$$\ddot x=-{\frac { \left( {\frac {d}{dx}}f \left( x \right)  \right)  \left( {{
\dot x}}^{2}{\frac {d^{2}}{d{x}^{2}}}f \left( x \right) +g \right) }{1
+ \left( {\frac {d}{dx}}f \left( x \right)  \right) ^{2}}}
$$
with friction:
the friction force $~F_\mu$ interact toward the tangential vector which is
$${\mathbf{t}}_g=\frac{\partial \mathbf R}{\partial x}=\left[ \begin {array}{c} 1\\{\frac {d}{dx}}f
 \left( x \right) \end {array} \right] 
$$
you can obtain the equation of motion with EL and external force $~\mathbf F_e$
$$ \mathbf F_e= F_\mu\,\frac{\mathbf t_g}{|\mathbf t_g|}$$
$\Rightarrow$
the EOM
$$\ddot x={\frac {F_{{\mu}}}{\sqrt {1+ \left( {\frac {d}{dx}}f \left( x \right) 
 \right) ^{2}}m}}-{\frac { \left( {\frac {d}{dx}}f \left( x \right) 
 \right)  \left( {{\dot x}}^{2}{\frac {d^{2}}{d{x}^{2}}}f \left( x
 \right) +g \right) }{1+ \left( {\frac {d}{dx}}f \left( x \right) 
 \right) ^{2}}}
$$
with $~F_\mu=-\mu\,|N|\,\text{sgn}(\mathbf v\,\cdot \mathbf t_g)~$ and $~N~$ the normal force. the "sgn"  function causes that the friction force act always to the opposite direction of the tangential velocity.
$$N={\frac { \left( {{\dot x}}^{2}{\frac {d^{2}}{d{x}^{2}}}f \left( x
 \right) +g \right) m}{\sqrt {1+ \left( {\frac {d}{dx}}f \left( x
 \right)  \right) ^{2}}}}
$$
Example:
$$f(x)=a\,x^2$$
$$\ddot x={\frac {F_{{\mu}}}{\sqrt {1+4\,{a}^{2}{x}^{2}}m}}-2\,{\frac {a\,x
 \left( 2\,{{\dot x}}^{2}a+g \right) }{1+4\,{a}^{2}{x}^{2}}}
$$
$$N={\frac { \left( 2\,{{\dot x}}^{2}a+g \right) m}{\sqrt {1+4\,{a}^{2}{x}
^{2}}}}
$$
Simulation with friction

The Euler Langrage equation:
$$\frac{d}{dt}\left(\frac{\partial \mathcal L}{\partial \dot x}\right)-
\left(\frac{\partial \mathcal L}{\partial x}\right)=\left(\frac{\partial \mathbf R}{\partial  x}\right)^T\,\mathbf F_e$$
