# Derivative of a position constraint in a DAE

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 $$$$q_1 q_1' + q_2 q_2' = 0.$$$$

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.
• Yes. The algebraic constraints are invariants of the solutions (having the value $0$) and thus differentiation along a solution, i.e., with respect to time, is zero as well. May 25, 2014 at 10:21
• Yes and no. The sum of the derivatives on the left is meaningless and wrong in this formula. The time derivatives are missing. The right side is what I gave above for $\frac{dp}{dt}$. May 25, 2014 at 10:52