What does "up to a total derivative" really mean and how should I know when to use it? I am a mathematician who is taking a quantum field theory course without much prior pyhsics. We have had the term "up to a total derivative" a few times, yet every time I asked what it meant I didn't really grasp it.
As an example, for our last tutorial we were given the Lagrangian
$$ \mathcal{L} = i\psi^*\partial_0\psi - \frac{1}{2m}\nabla\psi^*\cdot\nabla\psi,\tag{1}
$$
but then immediately in the tutorial it was given that this is equivalent (up to a total derivative) to
$$ \mathcal{L} = \frac{i}{2}(\psi^*\partial_0\psi - (\partial_0\psi^*)\psi) - \frac{1}{2m}\nabla\psi^*\cdot\nabla\psi.\tag{2}
$$
The things I really don't understand are:


*

*how exactly are these things the same? (/what does "up to total derivative" mean)

*how do I know when I should try to convert something to another thing through a total derivative?
 A: *

*The Euler-Lagrange (EL) equations are not affected by total derivative terms, cf. e.g. this Phys.SE post.

*In OP's concrete example the Lagrangian density (2) is preferred as it is manifestly real. See also this related Phys.SE post.
A: Since the Lagrangian density (which is confusingly also referred as a Lagrangian) is defined as a function which is integrated on, we may always think the  $\mathcal{L}$ in inside a 4D integral, since the action is defined via
$$
S = \exp \left( \int d^4x \mathcal{L} \right).
$$
Now, we may decompose the term to two identical parts and integrating one of them by parts,
\begin{align*}
 \int dt i\psi^*\partial_0\psi &= \int dt\frac{1}{2}i\psi^*\partial_0\psi + \int dt\frac{1}{2}i\psi^*\partial_0\psi\\
&=\int dt\frac{1}{2}i\psi^*\partial_0\psi + \left. \frac{1}{2}i\psi^*\psi \right|_{\pm \infty} - \int dt\frac{1}{2}i\partial_0(\psi^*)\psi \\
&= \int dt\frac{i}{2}(\psi^*\partial_0\psi - (\partial_0\psi^*)\psi) 
\end{align*}
where the substitution term vanishes, since the field values are considered to vanish at infinity: $\psi(\pm \infty) \rightarrow 0$. This is the total derivative term.
