I have an action integral that I want to optimize of the form $$ S = \int_0^T \left( a(t)q^2 -2b(t)q + \gamma \dot{q}^2 \right) dt \,. $$ I know that in fact $\dot{q} = 0$, in which case the critical points can easily be found by plugging this in, setting $\frac{d S}{dq}=0$, and solving for $q$. This gives the result, $$ q = \left( \int_0^T a(t)dt \right)^{-1} \int_0^T b(t) dt. $$ Suppose instead that I want to solve this with the Euler-Lagrange equation. The fact that $q$ is constant can be imposed by the constraint $f(q)=q-c=0$. Applying the Euler-Lagrange equations gives $$ 2a(t)q - 2b(t) - 2 \gamma \ddot{q} = \lambda \,. $$ Differentiating the constraint equation twice shows that $\ddot{q}=0$. Plugging this in gives $$ 2a(t)q - 2 b(t) = \lambda \,,$$ from which it is already apparent that there is a problem since the left-hand side is a function of $t$ and the right hand side is not. This can be solved by taking the derivative of both sides and solving for $q$, which results in $$ q = \frac{\dot{b}}{\dot{a}} \,,$$ which is incorrect. What have I done incorrectly here?
Edit: The reason I am asking is that I have a similar problem where $q$ and $b$ are vectors, $a$ is a matrix, and I know that some of the entries of $q$ are constant while others are not. So I need to make sure that I am handling the constant entries correctly when using the Euler-Lagrange equations.
Note on boundary conditions: I don't know if this matters, but there are no natural constraints to impose on $q$ at the boundaries, so the boundaries are free, which leads to the requirement of the Transversality conditions $\frac{\partial L}{\partial \dot{q}}\big|_{t=0} = 0$ and $\frac{\partial L}{\partial \dot{q}}\big|_{t=T} = 0$, where the Lagrangian $L$ is given by $2b(t)q^2 -2a(t) + \gamma \dot{q}^2$. This imposes the boundary conditions $\dot{q}(T)=\dot{q}(0)=0$.