Given a profile of unit quaternions $q(t)$ that represents the orientation of a body over time, I like to get the angular acceleration $\dot \omega (t)$. I tried to find a formula myself, but I get two different results for two different derivations.
Derivation 1
Starting from the kinematic equations
$$\omega=2\dot{q}\hat{q}$$
$$\dot{\omega}=2(\ddot{q}\hat{q}+\dot q \hat{\dot{q}})$$
And using the property of conjugate quaternions:
$$\dot\omega=2\ddot q \hat q$$
Derivation 2
Again, taking the kinematic equation
$$\dot q = \frac 1 2 \omega q$$
But now taking the derivative of $q$ w.r.t. $t$ gives
$$ \ddot q=\frac 1 2 (\dot \omega q+\omega\dot q) $$
After substituting the formula for $\omega$
$$ \ddot q=\frac{1}{2} (\dot \omega q+2 \dot q\hat q \dot q)$$
Finally, the result after multiplying both sided by $\hat q$ and rearranging is
$$\dot \omega = 2\ddot q\hat q -2(\dot q \hat q)^2$$
Which of these derivations is correct, and why? I have already consulted several sources, where I seem to find both formulas. For example here for derivation 1 and here for derivation 2. I'm new to using quaternions, so maybe I'm missing some mathematical concept.
I am not a physicist but, to my understanding, both derivations are equal.
In your first derivation you get:
$\dot\omega = 2\ddot q \hat q + 2 \dot q \hat{\dot q} $
In your second derivation you get the same. Departing from the unit quaternion condition:
$q \hat q = 1$
$0 = \frac{d}{dt}(q \hat q) = \dot q \hat q + q \hat{\dot q}$
We get the identity:
$\dot q \hat q = - q \hat{\dot q}$
So the square $(\dot q\hat q)^2 = - \dot q \hat{\dot q}$ because:
$(\dot q\hat q)^2 = \dot q\hat q (\dot q \hat q) = -\dot q \hat q q \hat{\dot q} = - \dot q \hat{\dot q}$
And you get again:
$\dot\omega = 2\ddot q \hat q + 2 \dot q \hat{\dot q} $