Suppose I have a particle with mass $m$ situated on a frictionless line which we can model using $\mathbb{R}$. Suppose that we supply/push the particle $m$ with a force $f(t)$. Let the position of this mass be denoted as $p$. The particle moves horizontally along the line.
I wish to derive the equation $m \ddot p(t) = f(t)$ using Lagrangian mechanics.
To do this, I need to identify the kinetic and potential energy, and then substitute the Lagrangian into the Euler-Lagrange equation, which are from these slides on page 3: https://publish.illinois.edu/ece470-intro-robotics/files/2021/10/ECE470FA21Lec16.pdf
$$f= \dfrac{d}{dt} \dfrac{\partial L}{\partial \dot q}- \dfrac{\partial L}{\partial q}$$ where $f$ is the external force, $L$ is the Lagrangian, and $q$ is the generalized variable.
The kinetic energy is simple: $T = \dfrac{1}{2}m \dot p^2$. The external force is $f(t)$, which appears at the left-hand-side of my equation. However, I cannot figure out what is the potential energy $P$ in order to form $L$.
Please assist!
well it depends on whether that force is conservative or not. However, in both cases the result is the same. I will change your notation and use $q$ as coordinate.
a) Conservative force: In this case $f := -\partial P(q) / \partial q $. Thus applying the Euler-Lagrange equation to $L=T-P$, you obtain the result.
b) Non-conservative force: In this case $f := d(\partial L / \partial \dot{q}) /d{t} - \partial L / \partial q$ and $P:=0$ which implies $L=T$.
Note that the only different thing is how you interpret the origin of $f$ but the computations are the same. In general, a generalized force $f(q,\dot{q},t)$ can be written as $$ f(q,\dot{q},t) := d(\partial L / \partial \dot{q}) /d{t} - \partial L / \partial q, $$ which of course, includes conservative forces.