I was going through Landau & Lifshitz Classical Mechanics where it is stated that
Now I get that $\delta S= \delta S' =0$, for this to be true $\delta f(q^{(2)}, t_2) =\delta f(q^{(1)}, t_1)$.
$$
\frac{\partial f(q,t_2)}{\partial q} dq = \frac{\partial f(q,t_1)}{\partial q}dq $$
Now my claim is that $dq$ is zero at the endpoints since endpoints are fixed (because $t1$ and $t2$ are fixed) (we use this fact while deriving the Lagrangian equations as well). And hence the Lagrangian differing by the the time derivative of any function are equivalent. Is my reasoning correct? The start and end times being fixed doesn't necessarily imply start and end points are fixed. My mathematical proof is not rigorous enough. Does anyone else have a better explanation?
