On page 22 of Sussman & Wisdom's Structure and Interpretation of Classical Mechanics it is given the example of a harmonic oscillator to demonstrate how to find the path that a body will follow.
The authors have chosen the Lagragian
$$L(t) = 0.5 m (v\cdot v) - 0.5 k q^2$$
where $q(t) = (x(t), y(t), z(t))$ and $v = Dq$, and $m=k=1$. Then, by the least action theorem, they argued that the trajectory of the body will be the function $q(t)$ that minimises
$$S(t_1, t_2) = \int_{t_1}^{t_2} 0.5 m v^2 - 0.5 k q^2$$
Therefore, I thought that in order to find the $q$ that minimises $S$, I can look for the functions $x(t), y(t), z(t)$ that makes $\frac{\partial S }{\partial w} = 0$, where $w = x,y$ or $z$.
So just for simplicity, lets work only on 1-dimensional problem; Then
$$\frac{\partial S }{\partial x} = 0.5 \int_{t_1}^{t_2} 2\cdot Dx *D^2x * Dx - 2*x = 0$$
but we already know that the solution is a function of the form $x(t) =\lambda t$, $\lambda \in \mathbb{R}$, but then $$\frac{\partial S }{\partial x} = 0.5 * \lambda * (t_2 - t_1)^2 \not = 0.$$
So what I'm doing wrong in here ?