I'm trying to understand Example 9.7 from Ascher & Petzold's "Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations."
A simple mechanical system is given, with $\mathbf{q}$ representing the position coordinates and $\mathbf{v}=\mathbf{q}'$ the velocities. In the first step, the differential-algebraic equation is written as a first-order system
$$\begin{align}q_1' &= v_1,\\ q_2' &= v_1, \\ v_1' &= -\lambda q_1, \\ v_2' &= -\lambda q_2 - g, \\ 0 &= q_1^2 + q_2^2 - 1 \end{align}$$
In the second step, the position constraint $ 0 = q_1^2 + q_2^2 - 1 $ is differentiated once to give $$ \begin{equation} q_1 q_1' + q_2 q_2' = 0.\end{equation} $$
I'm going to ask at the risk of embarrassment how the single differentiation of $ 0 = q_1^2 + q_2^2 - 1 $ should result in $q_1 q_1' + q_2 q_2' = 0.$ I would go about it this way:
$$ \begin{align}p &= q_1^2 + q_2^2 - 1 \\ \frac{\partial p}{\partial q_1} &= 2q_1 \\ \frac{\partial p}{\partial q_2} &= 2q_2\end{align} $$
and thus expect to get $$ \frac{dp}{dq} = 2q_1 + 2q_2 $$
If I apply the product rule, I end up with (for example) $\frac{\partial p}{\partial q_1} = 2q_1 q_1'$, which still doesn't fit.
What have I missed here?
EDIT: Is it legal for me to arrive at this using the product rule without considering time, or am I deceiving myself? For example, with the product rule I would get $$\frac{\partial p}{\partial q_1} + \frac{\partial p}{\partial q_2} = 2q_1 q_1' + 2q_2 q_2'$$ Here, the right hand side is the same as
$$2(q_1 q_1' + q_2 q_2')$$
and since the position constraint $p$ must equal zero, its derivative must also equal zero, and it follows that $q_1 q_1' + q_2 q_2' = 0$.
You are computing the time derivative of $p$, so the chain rule applies $$ \frac{dp}{dt}=\frac{∂p}{∂q_1}\frac{dq_1}{dt}+\frac{∂p}{∂q_2}\frac{dq_2}{dt}. $$
Note that $$ \frac{∂p}{∂q}=\left(\frac{∂p}{∂q_1},\frac{∂p}{∂q_2}\right),\qquad so\quad \frac{dp}{dt}=\frac{∂p}{∂q}\frac{dq}{dt}, $$ there is no sum there in the first expression, just a row vector.