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

<record version="1" 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-24 04:07:50</modified>
 <type>Topic</type>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>figure update to passive rotation convention</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>
 <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}

Quaternion kinematics gives a continuous differential equation for attitude.
A real navigation computer, flight controller, or simulation must convert that
continuous equation into a discrete update executed at the IMU sample rate.
This is the numerical quaternion propagation problem.

For an inertial measurement unit, the gyroscopes supply the angular-rate
information used for the attitude prediction.  The accelerometers do not
normally determine the high-rate quaternion propagation directly.  Instead,
their measured specific force is rotated by the propagated attitude and used
elsewhere in the navigation state equations, while accelerometer or gravity
information may also be used in a later attitude-correction step.

This entry develops the exact finite-increment update, the small-angle
approximation, forward Euler and Runge--Kutta propagation, gyro bias correction,
delta-angle IMU data, coning effects, sign continuity, and the role of a
quaternion inside a larger inertial-navigation or attitude-estimation state.

\section{Convention declaration}

This article continues the PhysicsLibrary convention used in Q11:
\begin{enumerate}
\item right-handed orthonormal frames;
\item Hamilton multiplication;
\item scalar-first quaternion display,
\begin{equation}
q=
\begin{bmatrix}
q_w&amp;q_x&amp;q_y&amp;q_z
\end{bmatrix}^{T};
\end{equation}
\item the attitude quaternion is
\begin{equation}
q\equiv{}^{I}q_B,
\end{equation}
mapping body-frame coordinates into inertial-frame coordinates;
\item the IMU gyroscope measurement is resolved in body axes unless stated
otherwise.
\end{enumerate}

With body-resolved angular velocity, Q11 derived
\begin{equation}
\boxed{
\dot q=\frac12 q\,\omega^{B},
}
\end{equation}
where $\omega^{B}$ is embedded as a pure quaternion.

\section{A sampled gyroscope model}

A useful first-order gyroscope measurement model is
\begin{equation}
\boxed{
\boldsymbol\omega_m^{B}
=
\boldsymbol\omega^{B}
+
\mathbf b_g
+
\mathbf n_g,
}
\end{equation}
where $\mathbf b_g$ is gyro bias and $\mathbf n_g$ represents measurement
noise.  An estimator or navigation solution uses its current bias estimate
$\widehat{\mathbf b}_g$ to form
\begin{equation}
\boxed{
\boldsymbol\omega_c^{B}
=
\boldsymbol\omega_m^{B}
-
\widehat{\mathbf b}_g.
}
\end{equation}

For a sample interval $\Delta t$, the simplest delta-angle approximation is
\begin{equation}
\boxed{
\Delta\boldsymbol\theta_k
=
\boldsymbol\omega_{c,k}^{B}\Delta t.
}
\end{equation}
If the IMU itself reports integrated delta angles rather than angular rates,
then the measured $\Delta\boldsymbol\theta_k$ may be used directly after
applying the appropriate bias, scale-factor, and calibration corrections.

\section{Exact quaternion increment for a constant sample rate}

Assume that $\boldsymbol\omega_c^{B}$ is constant over one sample.  Define
\begin{equation}
\Delta\theta
=
\left\|
\Delta\boldsymbol\theta
\right\|,
\end{equation}
and, for nonzero $\Delta\theta$,
\begin{equation}
\widehat{\mathbf u}
=
\frac{\Delta\boldsymbol\theta}{\Delta\theta}.
\end{equation}
The exact unit-quaternion increment is
\begin{equation}
\boxed{
\delta q
=
\cos\frac{\Delta\theta}{2}
+
\widehat{\mathbf u}
\sin\frac{\Delta\theta}{2}.
}
\end{equation}
Equivalently, in scalar-first column form,
\begin{equation}
\boxed{
\delta q
=
\begin{bmatrix}
\cos(\Delta\theta/2)\\[1mm]
\dfrac{\sin(\Delta\theta/2)}{\Delta\theta}
\Delta\boldsymbol\theta
\end{bmatrix}.
}
\end{equation}

Because the gyro rate is body-resolved, the increment multiplies the attitude
state on the right:
\begin{equation}
\boxed{
q_{k+1}
=
q_k\,\delta q_k.
}
\end{equation}
This exponential update is exact when the angular velocity is constant over the
sample interval.

\section{Small-angle approximation}

For IMU sampling at sufficiently high rate, the incremental rotation
$\Delta\theta$ is usually small.  Expanding the exact increment gives
\begin{equation}
\cos\frac{\Delta\theta}{2}
=
1-\frac{\Delta\theta^2}{8}
+O(\Delta\theta^4),
\end{equation}
and
\begin{equation}
\frac{\sin(\Delta\theta/2)}{\Delta\theta}
=
\frac12
-
\frac{\Delta\theta^2}{48}
+
O(\Delta\theta^4).
\end{equation}
Thus
\begin{equation}
\delta q
=
\begin{bmatrix}
1-\dfrac{\Delta\theta^2}{8}\\[1mm]
\left(
\dfrac12-\dfrac{\Delta\theta^2}{48}
\right)
\Delta\boldsymbol\theta
\end{bmatrix}
+
O(\Delta\theta^4),
\end{equation}
and the familiar first-order form is
\begin{equation}
\boxed{
\delta q
\approx
\begin{bmatrix}
1\\[1mm]
\dfrac12\Delta\boldsymbol\theta
\end{bmatrix}.
}
\end{equation}

The first-order formula has two important applications, and they should not be
confused.

\subsection*{Application 1: very small IMU propagation increments}

For a sufficiently small gyro increment, one may use
\begin{equation}
q_{k+1}
\approx
q_k
\begin{bmatrix}
1\\[1mm]
\dfrac12\Delta\boldsymbol\theta_k
\end{bmatrix},
\end{equation}
followed by normalization.  This is computationally cheap, but the exact
exponential increment is usually preferable when trigonometric evaluation is
not a burden.

\subsection*{Application 2: local attitude errors}

In an error-state estimator, the nominal attitude remains a full unit
quaternion while a local attitude error is represented by the three-vector
$\delta\boldsymbol\theta$.  From Q12,
\begin{equation}
\boxed{
\delta q_e
\approx
\begin{bmatrix}
1\\[1mm]
\dfrac12\delta\boldsymbol\theta
\end{bmatrix}.
}
\end{equation}
This is a linearization of the error, not a replacement for the nominal
quaternion state.

Figure~\ref{fig:q13-imu} summarizes the distinction between these two uses.

\begin{figure}[h]
\centering
\includegraphics[width=0.98\textwidth]{Q13_imu_quaternion_propagation.png}
\caption{A typical IMU attitude-propagation flow.  Body-frame gyro measurements
are corrected for estimated bias, integrated to a delta angle, converted to an
incremental quaternion, and multiplied on the right of the nominal attitude.
The small-angle quaternion has two distinct uses: approximating a very small
sample increment and representing a local three-component attitude error.}
\label{fig:q13-imu}
\end{figure}

\section{Forward Euler integration}

One may discretize the continuous kinematic equation directly:
\begin{equation}
q_{k+1}^{\mathrm{Euler}}
=
q_k
+
\frac12 q_k\omega_k^{B}\Delta t.
\end{equation}
This is precisely the first-order Taylor approximation to the exponential
update.  The difficulty is that the Euler step does not preserve unit norm
exactly.  Therefore implementations commonly apply
\begin{equation}
\boxed{
q_{k+1}
\leftarrow
\frac{q_{k+1}^{\mathrm{Euler}}}
{\left\|q_{k+1}^{\mathrm{Euler}}\right\|}.
}
\end{equation}

Normalization corrects norm drift, but it does not recover all of the phase
accuracy lost by a low-order integration method.  At high dynamics or long
sample intervals, exact or higher-order propagation is preferable.

\section{Midpoint and exponential propagation}

If the angular rate changes across the sample, a useful second-order strategy is
to approximate the rate at the midpoint:
\begin{equation}
\boldsymbol\omega_{k+1/2}^{B}
\approx
\frac12
\left(
\boldsymbol\omega_k^{B}
+
\boldsymbol\omega_{k+1}^{B}
\right).
\end{equation}
Then form
\begin{equation}
\Delta\boldsymbol\theta_k
=
\boldsymbol\omega_{k+1/2}^{B}\Delta t
\end{equation}
and apply the exact quaternion increment of equation (10).  This retains the
unit-quaternion structure while improving the approximation of a varying rate.

\section{Runge--Kutta propagation}

The differential equation may also be integrated with a standard
Runge--Kutta method.  For example, fourth-order Runge--Kutta evaluates
\begin{equation}
f(q,t)
=
\frac12q\,\omega^{B}(t)
\end{equation}
at four points within the interval.  The resulting quaternion should normally
be normalized after the update because generic numerical integration does not
preserve the unit sphere exactly.

Runge--Kutta is valuable when angular rate is supplied by a continuous model.
For sampled IMU data, however, an exponential or coning-corrected delta-angle
update is often more natural because the sensor already provides discrete
angular information.

\section{A numerical IMU example}

Suppose a body rotates at
\begin{equation}
\boldsymbol\omega^{B}
=
\begin{bmatrix}
0&amp;0&amp;90
\end{bmatrix}^{T}
\text{deg/s}
\end{equation}
and the IMU is sampled at
\begin{equation}
\Delta t=0.01\text{ s}.
\end{equation}
The delta angle per sample is
\begin{equation}
\Delta\boldsymbol\theta
=
\begin{bmatrix}
0&amp;0&amp;0.9^\circ
\end{bmatrix}^{T}
=
\begin{bmatrix}
0&amp;0&amp;0.015708
\end{bmatrix}^{T}\text{ rad}.
\end{equation}
The exact increment is therefore approximately
\begin{equation}
\delta q
=
\begin{bmatrix}
0.999969\\
0\\
0\\
0.007854
\end{bmatrix}.
\end{equation}
Applying this increment 100 times produces a $90^\circ$ rotation about the
body $z$ axis, up to floating-point roundoff.

\section{Bias error and attitude drift}

Gyro bias integrates directly into attitude error.  If an uncorrected constant
bias $\delta\mathbf b_g$ is small, then over a short interval
\begin{equation}
\delta\boldsymbol\theta
\approx
\delta\mathbf b_g\,t.
\end{equation}
Thus even a small gyro bias can create a steadily growing attitude error.

A typical estimator therefore includes gyro bias in the state:
\begin{equation}
\boxed{
\mathbf x
=
\begin{bmatrix}
q&amp;
\mathbf b_g^T&amp;
\cdots
\end{bmatrix}^{T}.
}
\end{equation}
A simple random-walk bias model is
\begin{equation}
\dot{\mathbf b}_g
=
\mathbf n_{bg},
\end{equation}
or in discrete time,
\begin{equation}
\mathbf b_{g,k+1}
=
\mathbf b_{g,k}
+
\mathbf w_{bg,k}.
\end{equation}

\section{Small-angle error-state propagation}

Consider a right, body-resolved attitude error as in Q12:
\begin{equation}
q_{\mathrm{true}}
=
\widehat q\,\delta q_B.
\end{equation}
Let
\begin{equation}
\delta q_B
\approx
\begin{bmatrix}
1\\[1mm]
\dfrac12\delta\boldsymbol\theta^{B}
\end{bmatrix}.
\end{equation}
Define the gyro-bias estimation error as
\begin{equation}
\delta\mathbf b_g
=
\mathbf b_g-\widehat{\mathbf b}_g.
\end{equation}
To first order, a common right-error model satisfies
\begin{equation}
\boxed{
\delta\dot{\boldsymbol\theta}^{B}
\approx
-
[\widehat{\boldsymbol\omega}^{B}]_{\times}
\delta\boldsymbol\theta^{B}
-
\delta\mathbf b_g
-
\mathbf n_g.
}
\end{equation}
A first-order discrete approximation is
\begin{equation}
\boxed{
\delta\boldsymbol\theta_{k+1}^{B}
\approx
\left(
I_3
-
[\widehat{\boldsymbol\omega}_k^{B}]_{\times}\Delta t
\right)
\delta\boldsymbol\theta_k^{B}
-
\delta\mathbf b_{g,k}\Delta t
-
\mathbf n_{g,k}\Delta t.
}
\end{equation}
The signs and multiplication side are convention dependent.  The state,
injection rule, and covariance model must all use the same error convention.

\section{Connection to the rest of an IMU navigation state}

In strapdown navigation, the attitude update is only one part of the state
propagation.  The accelerometer measures specific force in body axes,
$\mathbf f^B$.  The propagated quaternion supplies the rotation
\begin{equation}
\mathbf f^{I}
=
R(q)\mathbf f^{B},
\end{equation}
which then enters the velocity and position equations.  In a simple inertial
frame model,
\begin{equation}
\dot{\mathbf v}^{I}
=
\mathbf f^{I}
+
\mathbf g^{I}.
\end{equation}
More complete navigation equations add Earth rotation, transport rate, gravity
models, and sensor calibration terms.  The important structural point is that
gyro integration propagates the quaternion used to orient the accelerometer
measurement.

\section{Multiple increments and coning}

Rotations do not commute.  Therefore several IMU delta-angle samples cannot in
general be replaced by a simple vector sum.

For two small body-frame increments applied in chronological order,
\begin{equation}
q_{k+2}
=
q_k\,
\delta q_1
\delta q_2.
\end{equation}
Using the first-order quaternion form for each increment and retaining the
leading cross term gives the equivalent small rotation vector
\begin{equation}
\boxed{
\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 first indication of the coning effect.  Practical
strapdown algorithms use more accurate coning corrections that depend on how
the gyro samples or delta angles are accumulated within the update interval.

\section{Sign continuity}

The quaternions $q$ and $-q$ represent the same physical orientation.  A
numerical time history may therefore contain an unnecessary sign jump if a
conversion algorithm chooses the opposite representative at one sample.

A common continuity rule is
\begin{equation}
\boxed{
\text{if }
q_k^T q_{k-1}&lt;0,
\qquad
q_k\leftarrow -q_k.
}
\end{equation}
This does not change the physical attitude.  It simply chooses the quaternion
representative closest to the previous sample, which is useful for plotting,
interpolation, and finite differencing.

\section{Choosing a propagation method}

For many IMU applications the following hierarchy is useful:
\begin{enumerate}
\item use the exact exponential increment when one rate or delta-angle vector is
representative of the sample interval;
\item use a midpoint or coning-corrected increment when angular rate changes
significantly within the interval;
\item use Runge--Kutta when integrating a continuous angular-rate model or when
the system dynamics already use a compatible higher-order integrator;
\item reserve the first-order small-angle update mainly for very small
increments, linearized error-state equations, and analytical derivations.
\end{enumerate}

\section{Common pitfalls}

The most common implementation errors are:
\begin{enumerate}
\item multiplying a body-resolved increment on the left instead of the right;
\item applying the small-angle approximation to a large sample rotation;
\item subtracting no gyro bias, or using the wrong sign for the bias estimate;
\item assuming normalization makes a low-order integrator exact;
\item summing finite delta-angle vectors while ignoring noncommutativity and
coning;
\item confusing the small three-component attitude error with the full nominal
quaternion state;
\item rotating accelerometer specific force with a stale or oppositely defined
attitude quaternion;
\item treating the sign change $q\leftrightarrow -q$ as a physical attitude
jump.
\end{enumerate}

\section{What comes next}

Q14 consolidates the quaternion sequence into a larger graded exercise bank.
The numerical ideas developed here also provide the direct bridge into
strapdown inertial navigation, multiplicative attitude filters, and
quaternion-based simulation states.

\section{Sources and engineering context}

The continuous kinematic equation follows from Q11 and the small-error
representation follows from Q12.  The discrete exponential update is the
finite-rotation form of that same kinematics.  Gyro bias, delta-angle
integration, coning, and attitude-state propagation are standard concerns in
strapdown inertial navigation and spacecraft attitude computation.

\section*{License}

This article is an original synthesis prepared for PhysicsLibrary and intended
for release under CC BY-SA 4.0.</content>
</record>
