<?xml version="1.0" encoding="UTF-8"?>

<record version="4" id="1109">
 <title>numerical quaternion propagation and IMU attitude state integration</title>
 <name>NumericalQuaternionPropagationAndIMUAttitudeStateIntegration</name>
 <created>2026-08-24 04:07:50</created>
 <modified>2026-08-28 01:51:20</modified>
 <type>Topic</type>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>updated to point to correct figure name</comment>
 <author id="1" name="bloftin"/>
 <classification>
	<category scheme="pacs" code="45.40.-f"/>
	<category scheme="pacs" code="02.40.Yy"/>
	<category scheme="pacs" code="06.30.Gv"/>
 </classification>
 <related>
	<object name="QuaternionSeriesOverviewAndArticleGuide"/>
	<object name="NotationQuaternionsForPhysicsAndEngineeringOrientation"/>
	<object name="QuaternionDefinitionAndBasicAlgebra"/>
	<object name="ExampleOfQuaternionDefinitionAndBasicAlgebra"/>
	<object name="QuaternionProduct"/>
	<object name="ExampleOfQuaternionProduct"/>
	<object name="QuaternionConjugate"/>
	<object name="ExampleOfQuaternionConjugate"/>
	<object name="QuaternionNorm"/>
	<object name="ExampleOfQuaternionNorm"/>
	<object name="QuaternionInverse"/>
	<object name="ExampleOfQuaternionInverse"/>
 </related>
 <keywords>
	<term>quaternion</term>
	<term>numerical propagation</term>
	<term>IMU</term>
	<term>gyroscope</term>
	<term>attitude state</term>
	<term>delta angle</term>
	<term>small angle approximation</term>
	<term>coning correction</term>
	<term>inertial navigation</term>
	<term>strapdown navigation</term>
 </keywords>
 <preamble>% this is the default PhysicsLibrary preamble.  as your knowledge
% of TeX increases, you will probably want to edit this, but
% it should be fine as is for beginners.

% almost certainly you want these
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

% used for TeXing text within eps files
%\usepackage{psfrag}
% need this for including graphics (\includegraphics).
% If you use \includegraphics{figure} with no file extension, PhysicsLibrary
% will prefer figure.png before falling back to figure.eps.
\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.jpg,.jpeg,.pdf,.eps}
% for neatly defining theorems and propositions
%\usepackage{amsthm}
% making logically defined graphics
%\usepackage{xypic}

% there are many more packages, add them here as you need them

% define commands here</preamble>
 <content>\section*{Numerical Quaternion Propagation and IMU Attitude State Integration}

A gyroscope does not directly measure attitude.  It measures angular motion.
An inertial navigation or attitude system must integrate that angular motion
over time to update an orientation state.

Quaternions are particularly well suited to this task because a unit
quaternion can be updated by a finite incremental rotation without introducing
an Euler angle singularity.

This article develops numerical propagation for the PhysicsLibrary passive
attitude quaternion

\begin{equation}
q
=
{}^{B}q_I,
\end{equation}

which maps coordinates from an inertial or reference frame $I$ into a body
frame $B$.

For body resolved angular velocity,

\begin{equation}
\dot q
=
-\frac12
\omega^B q.
\end{equation}

Over one sample interval, the exact constant rate update is

\begin{equation}
q_{k+1}
=
\delta q_B q_k,
\end{equation}

where

\begin{equation}
\delta q_B
=
\exp
\left(
-\frac12
\Delta\theta^B
\right).
\end{equation}

Thus the numerical implementation must preserve three convention facts:

\begin{enumerate}

\item the body frame increment has a negative quaternion vector part;

\item the body resolved increment multiplies on the left;

\item the propagated quaternion maps reference coordinates into body
coordinates.

\end{enumerate}

\section{Convention declaration}

PhysicsLibrary uses Hamilton multiplication,

\[
\mathbf i\mathbf j=\mathbf k,
\qquad
\mathbf j\mathbf k=\mathbf i,
\qquad
\mathbf k\mathbf i=\mathbf j,
\]

with reversed products changing sign.

Quaternion components are displayed scalar first:

\begin{equation}
q
=
q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k.
\end{equation}

The passive vector transformation is

\begin{equation}
{}^{B}v
=
q\,{}^{I}v\,q^*.
\end{equation}

For a positive frame rotation through angle $\theta$ about unit axis
$\widehat{\mathbf u}$,

\begin{equation}
q
=
\cos\frac{\theta}{2}
-
\widehat{\mathbf u}
\sin\frac{\theta}{2}.
\end{equation}

The corresponding DCM satisfies

\begin{equation}
{}^{B}\mathbf v
=
{}^{B}C_I\,{}^{I}\mathbf v,
\qquad
{}^{B}C_I=C(q).
\end{equation}

\section{From gyroscope measurement to corrected angular rate}

A practical body mounted gyroscope measurement can be modeled as

\begin{equation}
\boldsymbol\omega_m^B
=
{}^{B}\boldsymbol\omega_{B/I}
+
\mathbf b_g
+
\mathbf n_g,
\end{equation}

where

\[
\mathbf b_g
\]

is gyroscope bias and

\[
\mathbf n_g
\]

represents measurement noise.

Given a current bias estimate $\widehat{\mathbf b}_g$, form

\begin{equation}
\widehat{\boldsymbol\omega}^B
=
\boldsymbol\omega_m^B
-
\widehat{\mathbf b}_g.
\end{equation}

For a simple zero order hold over sample interval $\Delta t$, the corresponding
body resolved delta angle is

\begin{equation}
\Delta\boldsymbol\theta^B
=
\widehat{\boldsymbol\omega}^B
\Delta t.
\end{equation}

If the IMU itself supplies a delta angle measurement, that integrated quantity
should normally be used directly after the appropriate bias correction and
manufacturer specified compensation rather than unnecessarily converting it
to a rate and integrating it again.

\section{Exact exponential increment}

Let

\begin{equation}
\Delta\theta
=
\left\lVert
\Delta\boldsymbol\theta^B
\right\rVert.
\end{equation}

If

\[
\Delta\theta\neq0,
\]

define the unit increment axis

\begin{equation}
\widehat{\mathbf u}
=
\frac{
\Delta\boldsymbol\theta^B
}{
\Delta\theta
}.
\end{equation}

The exact passive body increment is

\begin{equation}
\delta q_B
=
\cos\frac{\Delta\theta}{2}
-
\widehat{\mathbf u}
\sin\frac{\Delta\theta}{2}.
\end{equation}

Equivalently,

\begin{equation}
\delta q_B
=
\exp
\left(
-\frac12
\Delta\boldsymbol\theta^B
\right).
\end{equation}

In scalar first array notation,

\begin{equation}
\delta\mathbf q_B
=
\begin{bmatrix}
\cos(\Delta\theta/2)
\\
-\dfrac{
\sin(\Delta\theta/2)
}{
\Delta\theta
}
\Delta\boldsymbol\theta^B
\end{bmatrix}.
\end{equation}

The limiting value at $\Delta\theta=0$ is the identity quaternion.

\section{Why body increments left multiply}

During sample $k$, the old attitude maps

\[
I\rightarrow B_k.
\]

The measured body increment maps

\[
B_k\rightarrow B_{k+1}.
\]

The complete passive frame chain is therefore

\[
I
\rightarrow
B_k
\rightarrow
B_{k+1}.
\]

PhysicsLibrary quaternion frame composition gives

\begin{equation}
{}^{B_{k+1}}q_I
=
{}^{B_{k+1}}q_{B_k}
\,{}^{B_k}q_I.
\end{equation}

Thus

\begin{equation}
q_{k+1}
=
\delta q_{B,k}
q_k.
\end{equation}

The side of multiplication is a consequence of the declared frame map, not a
change to Hamilton multiplication.

\section{Propagation flow}

The following diagram summarizes the passive IMU attitude state propagation
chain.

% PhysicsLibrary image file expected:
% Q13_imu_attitude_state_propagation.png
%
% Legacy L2H note:
% Keep this as a simple inline include.  Do not wrap it in a figure
% environment and do not use caption, label, or ref macros here.

\begin{center}
\includegraphics[width=0.97\textwidth]{Q13_imu_attitude_state_propagation.png}
\end{center}

\noindent\textbf{Figure.}
A body mounted IMU supplies angular motion and specific force.  Gyroscope bias
is removed, a passive incremental quaternion is formed, and the increment left
multiplies the inertial to body attitude quaternion.  The updated or
appropriately time centered attitude is then used to transform body specific
force into the navigation or inertial frame.  A multiplicative estimator may
carry a three component local error state while the nominal orientation
remains a full unit quaternion.

\section{Small angle increment}

For sufficiently small $\Delta\theta$,

\[
\cos\frac{\Delta\theta}{2}
\approx
1
\]

and

\[
\sin\frac{\Delta\theta}{2}
\approx
\frac{\Delta\theta}{2}.
\]

Therefore

\begin{equation}
\delta q_B
\approx
1
-
\frac12
\Delta\boldsymbol\theta^B.
\end{equation}

The corresponding first order update is

\begin{equation}
q_{k+1}
\approx
\left(
1
-
\frac12
\Delta\boldsymbol\theta^B
\right)
q_k.
\end{equation}

This is useful for analysis and for sufficiently small sample increments, but
the exact trigonometric increment is inexpensive and generally preferable
when the delta angle is already available.

\section{Forward Euler integration}

Starting from

\[
\dot q
=
-\frac12
\omega^B q,
\]

a forward Euler step is

\begin{equation}
q_{k+1}^{E}
=
q_k
-
\frac12
\omega_k^B q_k
\Delta t.
\end{equation}

If

\[
\Delta\boldsymbol\theta_k^B
=
\omega_k^B\Delta t,
\]

then

\begin{equation}
q_{k+1}^{E}
=
\left(
1
-
\frac12
\Delta\boldsymbol\theta_k^B
\right)
q_k.
\end{equation}

Thus forward Euler is equivalent to using the first order incremental
quaternion without normalization.

\section{Why forward Euler leaves unit norm}

The exact quaternion derivative is tangent to the unit quaternion three
sphere.

A forward Euler method advances along the tangent line:

\[
q_{k+1}^{E}
=
q_k+\dot q_k\Delta t.
\]

For unit $q_k$,

\[
q_k^T\dot q_k=0.
\]

Therefore

\[
\begin{aligned}
\left\lVert
q_{k+1}^{E}
\right\rVert^2
&amp;=
\left(
q_k+\dot q_k\Delta t
\right)^T
\left(
q_k+\dot q_k\Delta t
\right)
\\
&amp;=
1
+
\left\lVert
\dot q_k
\right\rVert^2
\Delta t^2.
\end{aligned}
\]

Hence

\begin{equation}
\left\lVert
q_{k+1}^{E}
\right\rVert
&gt;
1
\end{equation}

for a nonzero rate and nonzero step.

The norm defect is second order for one step but accumulates during repeated
propagation.

\section{Normalization}

A common numerical correction is

\begin{equation}
q
\leftarrow
\frac{q}{\lVert q\rVert}.
\end{equation}

Normalization restores the unit quaternion constraint and is generally
appropriate after an approximate propagation method or after finite precision
arithmetic.

However, normalization does not make an approximate integration method
identical to the exact exponential update.  It restores the manifold
constraint but does not reconstruct higher order phase terms omitted by the
integrator.

For an exact unit incremental quaternion multiplying an exactly unit state,
the product is analytically unit:

\begin{equation}
\lVert
\delta q_Bq_k
\rVert
=
1.
\end{equation}

Practical software may still normalize occasionally or every sample to control
floating point drift.

\section{A numerically stable small angle evaluation}

Directly evaluating

\[
\frac{\sin(\Delta\theta/2)}{\Delta\theta}
\]

can lose numerical quality when $\Delta\theta$ is extremely small.

Its Taylor expansion is

\begin{equation}
\frac{
\sin(\Delta\theta/2)
}{
\Delta\theta
}
=
\frac12
-
\frac{
\Delta\theta^2
}{48}
+
\frac{
\Delta\theta^4
}{3840}
+
O(\Delta\theta^6).
\end{equation}

Similarly,

\begin{equation}
\cos\frac{\Delta\theta}{2}
=
1
-
\frac{
\Delta\theta^2
}{8}
+
\frac{
\Delta\theta^4
}{384}
+
O(\Delta\theta^6).
\end{equation}

A robust implementation may switch to such series below a small threshold.

\section{Runge Kutta propagation}

A higher order integrator can be applied directly to

\begin{equation}
\dot q=f(q,t)
=
-\frac12
\omega^B(t)q.
\end{equation}

For classical fourth order Runge Kutta,

\begin{equation}
k_1
=
f(q_k,t_k),
\end{equation}

\begin{equation}
k_2
=
f
\left(
q_k+\frac{\Delta t}{2}k_1,
t_k+\frac{\Delta t}{2}
\right),
\end{equation}

\begin{equation}
k_3
=
f
\left(
q_k+\frac{\Delta t}{2}k_2,
t_k+\frac{\Delta t}{2}
\right),
\end{equation}

\begin{equation}
k_4
=
f
\left(
q_k+\Delta t\,k_3,
t_k+\Delta t
\right),
\end{equation}

and

\begin{equation}
q_{k+1}
=
q_k
+
\frac{\Delta t}{6}
\left(
k_1+2k_2+2k_3+k_4
\right).
\end{equation}

The resulting quaternion should be normalized.

Runge Kutta methods are useful when an angular rate model can be evaluated
inside the interval.  If an IMU supplies only one integrated delta angle per
sample, the exact finite incremental quaternion is often a more natural
attitude update.

\section{Exact update for a constant positive \(z\) rate}

Suppose

\[
q_0=1
\]

and the body rotates at constant positive rate

\[
\omega^B
=
\Omega\mathbf k.
\]

Over one interval,

\[
\Delta\boldsymbol\theta^B
=
\Omega\Delta t\,\mathbf k.
\]

The increment is

\begin{equation}
\delta q_B
=
\cos\frac{\Omega\Delta t}{2}
-
\mathbf k
\sin\frac{\Omega\Delta t}{2}.
\end{equation}

After $N$ equal intervals,

\begin{equation}
q_N
=
\cos\frac{\Omega N\Delta t}{2}
-
\mathbf k
\sin\frac{\Omega N\Delta t}{2}.
\end{equation}

At a total positive frame rotation of $90^\circ$,

\begin{equation}
q
=
\frac{
1-\mathbf k
}{
\sqrt2
}.
\end{equation}

This is the same passive convention diagnostic used throughout the preceding
PhysicsLibrary quaternion series.

\section{Using IMU supplied delta angles}

Many inertial sensors report integrated angular increments directly:

\begin{equation}
\Delta\boldsymbol\theta_m^B.
\end{equation}

Such an output may already incorporate internal high rate sampling and
manufacturer specific coning processing.

If the bias estimate is expressed as an angular rate and is approximately
constant over the sample, a simple correction is

\begin{equation}
\Delta\widehat{\boldsymbol\theta}^B
=
\Delta\boldsymbol\theta_m^B
-
\widehat{\mathbf b}_g
\Delta t.
\end{equation}

The corrected delta angle is then converted directly to the passive
incremental quaternion.

The device documentation must be checked to determine whether its reported
increment is raw, internally compensated, expressed in a beginning sample
frame, expressed in an ending sample frame, or uses another convention.

\section{Gyroscope bias accumulation}

If an uncompensated constant gyro bias has magnitude $b$, then for a simple
single axis case the attitude error grows approximately as

\begin{equation}
\delta\theta(t)
\approx
bt.
\end{equation}

For example, a bias of

\[
0.1^\circ/\mathrm{s}
\]

accumulates approximately

\[
60^\circ
\]

of angle error in ten minutes.

This simple calculation explains why accurate bias initialization, online
bias estimation, temperature modeling, and external aiding are important in
inertial systems.

\section{Two successive body increments and coning}

Consider two small chronological body frame increments

\[
\Delta\boldsymbol\theta_1
\]

followed by

\[
\Delta\boldsymbol\theta_2.
\]

The passive incremental quaternions are

\[
\delta q_1
\approx
1-\frac12\Delta\boldsymbol\theta_1
\]

and

\[
\delta q_2
\approx
1-\frac12\Delta\boldsymbol\theta_2.
\]

Because body increments left multiply, the chronological combined update is

\begin{equation}
q_2
=
\delta q_2
\delta q_1
q_0.
\end{equation}

Expand the increment product through second order:

\[
\begin{aligned}
\delta q_2\delta q_1
\approx{}&amp;
1
-
\frac12
\left(
\Delta\boldsymbol\theta_1+
\Delta\boldsymbol\theta_2
\right)
\\
&amp;
+
\frac14
\Delta\boldsymbol\theta_2
\Delta\boldsymbol\theta_1.
\end{aligned}
\]

The vector part of the last product is

\[
\frac14
\left(
\Delta\boldsymbol\theta_2
\times
\Delta\boldsymbol\theta_1
\right)
=
-
\frac14
\left(
\Delta\boldsymbol\theta_1
\times
\Delta\boldsymbol\theta_2
\right).
\]

Matching the passive first order form

\[
1-\frac12
\Delta\boldsymbol\theta_{\mathrm{eq}}
\]

gives the leading equivalent physical rotation vector

\begin{equation}
\Delta\boldsymbol\theta_{\mathrm{eq}}
\approx
\Delta\boldsymbol\theta_1
+
\Delta\boldsymbol\theta_2
+
\frac12
\Delta\boldsymbol\theta_1
\times
\Delta\boldsymbol\theta_2.
\end{equation}

The cross product term is the leading coning contribution.

\section{Why coning matters}

If the body rotates alternately about different axes during a sample interval,
the vector sum of the measured increments is not generally the exact net
rotation.

The missing information appears first through cross products of successive
angular increments.

High accuracy strapdown inertial algorithms therefore use multiple subsamples
or compensated delta angles to account for noncommutativity.

A simple one sample exponential update is exact for a constant rotation vector
over the interval.  It is not automatically exact for arbitrary high
frequency motion occurring within that interval.

If an IMU already reports a coning compensated delta angle, applying an
additional naive coning correction may double count the effect.

\section{Attitude sign continuity}

The unit quaternions

\[
q
\]

and

\[
-q
\]

represent the same physical orientation.

A numerical quaternion time history may therefore contain equivalent samples
with alternating overall signs.

For plotting, interpolation, finite differencing, or optimization, choose the
representative nearest the previous sample.

If

\begin{equation}
q_{k+1}^Tq_k&lt;0,
\end{equation}

replace

\begin{equation}
q_{k+1}
\leftarrow
-q_{k+1}.
\end{equation}

This does not change the physical attitude.

Sign continuity is a representation choice.  It is distinct from quaternion
normalization and from selecting the principal error quaternion in a local
attitude error calculation.

\section{Specific force transformation}

An accelerometer rigidly attached to the body reports specific force resolved
in body coordinates:

\begin{equation}
{}^{B}\mathbf f.
\end{equation}

The passive attitude quaternion maps inertial coordinates into body
coordinates, so the inverse DCM maps body coordinates back into inertial
coordinates:

\begin{equation}
{}^{I}\mathbf f
=
{}^{I}C_B
\,{}^{B}\mathbf f
=
({}^{B}C_I)^T
{}^{B}\mathbf f.
\end{equation}

Since

\[
{}^{B}C_I=C(q),
\]

we have

\begin{equation}
{}^{I}\mathbf f
=
C(q)^T
{}^{B}\mathbf f.
\end{equation}

The equivalent quaternion sandwich is

\begin{equation}
{}^{I}f
=
q^*
\,{}^{B}f
\,q.
\end{equation}

This inversion is important: the quaternion used for attitude propagation
maps $I\rightarrow B$, while navigation mechanization often needs to rotate a
measured body vector $B\rightarrow I$.

\section{Velocity and position propagation}

In a simple inertial frame model,

\begin{equation}
{}^{I}\dot{\mathbf v}
=
{}^{I}\mathbf f
+
{}^{I}\mathbf g,
\end{equation}

and

\begin{equation}
{}^{I}\dot{\mathbf r}
=
{}^{I}\mathbf v.
\end{equation}

In a rotating navigation frame, Earth rotation, transport rate, Coriolis
terms, and the chosen gravity model must also be included.

A typical strapdown propagation cycle is therefore:

\begin{enumerate}

\item read gyroscope and accelerometer information;

\item correct the gyroscope data for estimated bias;

\item form or accept a corrected body delta angle;

\item update the passive attitude quaternion;

\item obtain an attitude appropriate to the accelerometer integration time;

\item transform specific force from body coordinates into the navigation or
inertial frame;

\item add gravity and required rotating frame terms;

\item integrate velocity and position;

\item propagate bias and other estimator states.

\end{enumerate}

\section{Why time centered attitude can matter}

Using only the beginning or ending attitude to transform accelerometer data
introduces an error when the body rotates appreciably during the sample.

For constant body rate, a midpoint quaternion can be formed as

\begin{equation}
q_{k+1/2}
=
\delta q_{1/2}
q_k,
\end{equation}

where

\begin{equation}
\delta q_{1/2}
=
\exp
\left(
-\frac14
\Delta\boldsymbol\theta^B
\right).
\end{equation}

The corresponding midpoint DCM can then be used for a simple time centered
specific force transformation.

High accuracy inertial algorithms develop this idea further through sculling
compensation and multiple sample integration.

\section{Nominal quaternion and three component error state}

A navigation filter can propagate the nominal attitude as a full unit
quaternion while carrying only three attitude error states.

For example, using the passive small error convention from the preceding
article,

\begin{equation}
\delta q
\approx
\begin{bmatrix}
1\\
-\frac12
\delta\boldsymbol\theta
\end{bmatrix}.
\end{equation}

The nominal quaternion supplies a globally nonsingular orientation
representation, while

\[
\delta\boldsymbol\theta
\]

is a local three component perturbation suitable for linear covariance
propagation.

The chosen left or right error definition must remain consistent with the
filter Jacobians and the side used for correction injection.

\section{Direct small increment versus error state small angle}

The same small angle expansion appears in two distinct roles.

In direct IMU propagation,

\[
\delta q_B
\approx
1-\frac12
\Delta\boldsymbol\theta^B
\]

approximates the actual physical incremental rotation during one sample.
Its accuracy depends on the size and variation of the sample motion.

In an error state filter,

\[
\delta q
\approx
1-\frac12
\delta\boldsymbol\theta
\]

represents a deliberately local estimation error around a nominal full
attitude quaternion.

The nominal vehicle attitude itself may be very large even when the local
error state is small.

These two uses should not be conflated.

\section{Normalization versus sign continuity}

Two common operations have different purposes.

Normalization,

\[
q
\leftarrow
\frac{q}{\lVert q\rVert},
\]

restores the unit norm constraint.

Sign continuity,

\[
q_k\leftarrow-q_k
\]

when needed, chooses one of two equivalent quaternion representatives.

Neither operation substitutes for an accurate attitude integration method.

\section{Example propagation step}

Suppose

\[
q_k=1,
\]

\[
\boldsymbol\omega_m^B
=
\begin{bmatrix}
0.01\\
-0.02\\
0.53
\end{bmatrix}
\mathrm{rad/s},
\]

and

\[
\widehat{\mathbf b}_g
=
\begin{bmatrix}
0.01\\
-0.02\\
0.03
\end{bmatrix}
\mathrm{rad/s}.
\]

The corrected rate is

\begin{equation}
\widehat{\boldsymbol\omega}^B
=
\begin{bmatrix}
0\\
0\\
0.50
\end{bmatrix}
\mathrm{rad/s}.
\end{equation}

For

\[
\Delta t=0.1\ \mathrm{s},
\]

the delta angle is

\begin{equation}
\Delta\boldsymbol\theta^B
=
\begin{bmatrix}
0\\
0\\
0.05
\end{bmatrix}
\mathrm{rad}.
\end{equation}

Therefore

\begin{equation}
\delta q_B
=
\cos0.025
-
\mathbf k\sin0.025.
\end{equation}

Numerically,

\begin{equation}
\delta\mathbf q_B
\approx
\begin{bmatrix}
0.999687516\\
0\\
0\\
-0.024997396
\end{bmatrix}.
\end{equation}

Since the initial attitude is the identity,

\begin{equation}
q_{k+1}
=
\delta q_Bq_k
=
\delta q_B.
\end{equation}

\section{Forward Euler comparison for the same step}

The forward Euler result is

\[
q_{k+1}^{E}
=
1
-
\frac12
(0.05\mathbf k),
\]

so

\begin{equation}
q_{k+1}^{E}
=
1
-
0.025\mathbf k.
\end{equation}

Its norm is

\begin{equation}
\left\lVert
q_{k+1}^{E}
\right\rVert
=
\sqrt{1.000625}
\approx
1.000312451.
\end{equation}

After normalization,

\begin{equation}
\widehat{\mathbf q}_{k+1}^{E}
\approx
\begin{bmatrix}
0.999687646\\
0\\
0\\
-0.024992191
\end{bmatrix}.
\end{equation}

This is close to, but not identical with, the exact exponential result.

\section{Implementation pseudocode}

A minimal constant rate passive update can be expressed conceptually as:

\begin{verbatim}
omega_B = gyro_B - bias_hat_B
dtheta_B = omega_B * dt
a = norm(dtheta_B)

if a is very small:
    s = 0.5 - a*a/48
    c = 1.0 - a*a/8
else:
    s = sin(a/2) / a
    c = cos(a/2)

dq = [c, -s*dtheta_B]
q_new = dq * q_old
q_new = q_new / norm(q_new)

if dot(q_new, q_old) &lt; 0:
    q_new = -q_new
\end{verbatim}

The product in the line

\[
\texttt{q\_new = dq * q\_old}
\]

is the Hamilton product with scalar first semantic components.

Software whose array order is scalar last may use different memory indices
without changing the physical equations.

\section{Common pitfalls}

\begin{enumerate}

\item \textbf{Using the old inverse attitude convention.}

The present PhysicsLibrary state is

\[
q={}^Bq_I,
\]

not ${}^Iq_B$.

\item \textbf{Using a positive vector part for a positive body frame
increment.}

The passive increment is

\[
\delta q_B
=
\cos\frac{\Delta\theta}{2}
-
\widehat{\mathbf u}
\sin\frac{\Delta\theta}{2}.
\]

\item \textbf{Right multiplying body resolved increments.}

For the passive inertial to body state,

\[
q_{k+1}
=
\delta q_Bq_k.
\]

\item \textbf{Assuming normalization makes Euler integration exact.}

Normalization repairs norm, not truncation error.

\item \textbf{Ignoring gyro bias.}

Even a small constant rate bias integrates into a large attitude error over
time.

\item \textbf{Applying a simple vector sum to substantial multi axis motion.}

Successive rotations do not commute.  Coning terms matter.

\item \textbf{Applying coning correction twice.}

Determine whether the sensor supplied delta angle already contains internal
compensation.

\item \textbf{Using the inertial to body quaternion in the wrong direction
for accelerometer data.}

Body specific force is transformed to inertial coordinates with $q^*$ on the
left and $q$ on the right, or with $C(q)^T$.

\item \textbf{Interpreting quaternion sign flips as attitude jumps.}

$q$ and $-q$ represent the same orientation.

\item \textbf{Treating the three component filter attitude error as the
nominal attitude itself.}

The error vector is local; the nominal quaternion carries the global
orientation.

\end{enumerate}

\section{Verification battery}

A numerical implementation should be checked against:

\begin{enumerate}

\item zero angular rate;

\item constant positive rotations about $+x$, $+y$, and $+z$;

\item exact exponential propagation from the identity;

\item equality of $C(q_{k+1})$ with the equivalent DCM increment;

\item preservation of unit norm for exact increments;

\item expected norm drift for unnormalized forward Euler;

\item gyro bias accumulation;

\item body increment multiplication on the left;

\item sign continuity with $q$ versus $-q$;

\item two noncommuting increments and the leading coning term;

\item specific force transformation with the inverse attitude map;

\item consistency with the passive error state sign from Q12.

\end{enumerate}

\section{Relationship to adjacent PhysicsLibrary entries}

The preceding article, \emph{Relative Attitude and Error Quaternions},
establishes multiplicative left and right errors and the passive local relation

\[
\delta q
\approx
1-\frac12\delta\boldsymbol\theta.
\]

The present article combines that convention with the quaternion kinematics
from \emph{Quaternion Kinematics and Angular Velocity} to form sampled IMU
attitude propagation.

A separate companion entry,
\emph{Numerical Quaternion Propagation and IMU Attitude State Integration:
Examples, Exercises, and Solutions}, provides the Q13E self study problem
bank.

\section{Sources and convention notes}

Quaternion propagation equations cannot be imported safely without identifying
the represented frame map, the resolution of angular velocity, and the
quaternion multiplication convention.

Sommer and coauthors provide a modern discussion of convention management.
Sol\`a provides a detailed treatment of quaternion kinematics and IMU error
state filtering.  Titterton and Weston provide a broad engineering treatment
of strapdown inertial navigation.  Savage develops the classical strapdown
attitude integration framework, including coning compensation.

The equations in this entry are translated into the PhysicsLibrary passive
inertial to body convention.

\begin{thebibliography}{9}

\bibitem{Sommer2018}
H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto,
``Why and How to Avoid the Flipped Quaternion Multiplication,''
\emph{Aerospace}, vol. 5, no. 3, article 72, 2018.
Published under CC BY 4.0.
\PMlinkexternal{Publisher article}
{https://www.mdpi.com/2226-4310/5/3/72}

\bibitem{Sola2017}
J. Sol\`a,
``Quaternion Kinematics for the Error State Kalman Filter,''
arXiv:1711.02508, 2017.
\PMlinkexternal{arXiv preprint}
{https://arxiv.org/abs/1711.02508}

\bibitem{TittertonWeston}
D. H. Titterton and J. L. Weston,
\emph{Strapdown Inertial Navigation Technology},
2nd ed.,
The Institution of Engineering and Technology, 2004/2005.
Engineering reference.
\PMlinkexternal{IET book page}
{https://shop.theiet.org/strapdn-inertial-navig-t-2ed}

\bibitem{Savage1998}
P. G. Savage,
``Strapdown Inertial Navigation Integration Algorithm Design Part 1:
Attitude Algorithms,''
\emph{Journal of Guidance, Control, and Dynamics},
vol. 21, no. 1, pp. 19--28, 1998.
\PMlinkexternal{DOI record}
{https://doi.org/10.2514/2.4228}

\end{thebibliography}

\section*{License}

Unless otherwise noted, this PhysicsLibrary entry is intended for release under
the Creative Commons Attribution ShareAlike 4.0 International license.</content>
</record>
