3.1. Constrained Differentiation
In many cases, the expressions for the sensitivity coefficients are obtained by analytic differentiation. That method also works for situations with constrained input quantities [
33].
For the amount fractions forming a composition, the boundaries are that for any amount fraction
x,
[
6] (situations where
or
require a dedicated mathematical treatment and are not relevant for calculating properties of mixtures). The constraint on the other hand, formulated as a function
g, which is equal to zero is given by [
33]
where
denotes the composition, a vector holding the amount fractions of the components in the mixture. In the case of an equation of state, the function
f has two more arguments, namely the pressure
p and temperature
T. These are not constrained, but have bounds (both are non-negative).
Let
denote a small change (perturbation) of the constrained input quantities
, then the change in the output of a function
f,
is given by [
33]
where
P is the orthogonal projection matrix that depends solely on the constraint
g, for a composition given in Equation (
1). The projection
P is for a scalar function
g given by [
33]
where
I denotes the
identity matrix and
the unit normal vector
. For the constraint in Equation (
1),
and the projection matrix equals
where
is an
matrix with ones. Equation (
2) shows how the constrained partial derivatives are different from their unconstrained counterparts. A change in the function value equals
in the unconstrained case. Equation (
5) is the foundation of the LPU [
17,
19], when only the first terms of the Taylor expansion of the measurement model
f are considered [
37].
To illustrate the difference between the two sets of partial derivatives, consider the calculation of the calorific value of a natural gas, as described in ISO 6976. The formula for calculating the calorific value (
) takes the form [
30]
where
denotes the calorific value of component
i (
),
its amount fraction and
N is the number of components in the gas mixture. The calorific values of the components are unconstrained in this measurement model, whereas the amount fractions of all components in the mixture are constrained as discussed previously. The constrained partial derivatives with respect to
, formally denoted by the operator
, are [
33]
where
Both the constrained partial derivatives of Equation (
7) and their counterparts ignoring the constraint lead to exactly the same standard uncertainty
as the calculations in ISO 6976 [
30].
The proof that both kinds of partial derivatives can be used rests on the properties of the covariance matrix associated with the composition [
6,
41]. Let the Jacobian
J be defined as the gradient of the multivariate, differentiable function
, i.e., [
44,
45]
then the covariance matrix associated with the output vector
is obtained as [
19] (clause 6.2.1)
The proof that instead of
J a sensitivity matrix can be used composed of constrained partial derivatives can be given as follows. From the equality constraint
g, it follows that the constraint is in the form of an
-dimensional hyperplane
. For compositions, the constraint is given in Equation (
1) and the normal vector
in Equation (
4). Let the matrix
D be defined as
where
denote
independent directions in the hyperplane
, each perpendicular to the normal vector of the constraint (Equation (
4)).
Now, Equation (
8) can be written as
Now, let
. Furthermore, let
L denote the Cholesky factor of
,
and
. The constraint
, where
is some exactly known constant [
46] and
, implies that
and
and thus
. It then follows that and
From the definition of
D (see Equation (
9)), it is evident that
So,
This result implies that the last column, and by symmetry the last row of
contain only zeros.
Let a directional derivative
at
be defined as [
47]
where
denotes the direction. Now, it is shown that the method does not rely on a particular choice of vectors
by looking at the product
. From calculus, for the directional derivative
of
f in direction
it holds that (Section 12.1, [
47])
so that
Note that all columns of
except the last one can be calculated if
is limited to values in
. However, as the last row and column of
are zero, knowledge about the last column of
is not needed. Let
The result of the generalized algorithm equals
Shortly, the correspondence with the algorithm presented in
Section 3.2 will be explained in more detail. Using the fact that the last row and column of
only contain zeros, it becomes clear that
which shows that the constrained partial differentiation yields the same covariance matrix as using the LPU (see Equation (
8)) with the Jacobian. As no assumptions on the
,
were made except for their independence and perpendicularity to
, the result of the algorithm is independent on the particular choice for the
. The choice between using the unconstrained and constrained partial derivatives does however matter for improperly formed covariance matrices, see also
Appendix A.
3.2. Numerical Constrained Differentiation
Analytic differentiation can become prohibitively difficult for complex measurement models, such as equations of state [
9,
34,
36] or in instances where the measurement model takes the form of an algorithm, such as in the calculation of fluid properties at the vapour–liquid equilibrium [
9,
48]. Numerical differentiation [
44,
45] is a practical alternative for analytic differentiation to obtain values for the sensitivity coefficients used in the LPU.
Numerical differentiation methods use finite differences [
44,
45]. These differences should be formed by appreciating any constraint(s) on the arguments to ensure physically feasible outputs of the function
f. So, the finite differences for
p and
T should be such that the perturbed pressure and temperature are still valid in their own right. The perturbed composition should still meet the constraint in Equation (
1).
At first glance, it is not straightforward to perturb a composition and still satisfy the condition given in Equation (
1). Consider a normalized direction vector
. For constrained differentiation with respect to compositions, it is required that
is also a valid composition for a sufficiently small
. In this case, the constraint (
1) can be expressed as
where
.
is a valid composition if
is orthogonal to
. From the requirement that
is a valid composition, it follows that the sum of the elements of
is zero.
To illustrate how a composition
can be perturbed by a small shift, let us consider a ternary mixture (
),
. A change in
should be compensated by changes in
,
or both, so that the perturbed input vector
should again be a composition. Consequently, the sum of the elements of the perturbation
should be zero. Amongst the infinitely many options to satisfy this condition, one option is to orthogonally project the vectors
and
onto the hyperplane
containing
and with as normal vector
, the gradient of the constraint. Using the resulting projection
P (see also Equation (
3)) yields the normalized perturbation directions
such that it becomes physically meaningful and mathematically feasible to assess the change in the property of interest when the composition is changed from
to either of the compositions
where
and
are some sufficiently small numbers. (The cases that
equals
,
or
would require a different definition of
and
.)
Given a function
f having as one of its arguments a composition
, the derivatives with respect to amount fractions of the components in the composition can be obtained numerically as follows. For the numerical differentiation, instead of computing the limit in Equation (
12), a finite, small value for
will be used instead
To evaluate the partial derivative exactly at the value of the estimates
[
17] (clause 5.2), the directional derivative can be approximated by
For the numerical evaluation of the constrained partial derivatives, the following algorithm can be used:
Choose a small value for so that for all components i
Choose an orthogonal matrix Q with columns , which are all perpendicular to the vector
Compute the directional derivatives
using Equations (
18), or (
19) for symmetric partial derivatives
Now,
where
C denotes the sensitivity matrix in the sense of ISO/IEC Guide 98-3 and ISO/IEC Guide 98-3/Supplement 2 [
17,
19]. (In the case of a scalar function
f, the sensitivity matrix
C takes the form of a row vector, or equivalently, an
matrix.)
The algorithm can be readily further generalized to multivariate functions
, which can be used for propagating measurement uncertainty using the LPU from ISO/IEC Guide 98-3/Supplement 2 [
19].
The matrix
Q can be obtained in different ways. One such way is using a matrix derived from the Helmert matrix [
49], which is available as the function
ilrBase in the
R package ‘compositions’ [
50]. Alternatively, the (modified) Gram–Schmidt algorithm can be used [
51]. For a composition, the following orthogonal matrix can be used. For each column
, the first
j elements are equal to
and the following element is equal to
The remaining elements are zero. For
, using these formulæ,
3.3. Properties of the Numerical Method
The algorithm presented in
Section 3.2 is based on the consideration that if the directions
(see Equation (
9)) are chosen normalized and mutually orthogonal, the matrix
becomes orthogonal so that
. This matrix
enables formulating the particularly form of the algorithm, cf. Equation (
20). In particular, the matrix
Q from the numerical algorithm in
Section 3.2 corresponds to the first
columns of
such that
and let
From Equation (
8), it follows that
So, the algorithm provides a sensitivity matrix
C that matches the descriptions in ISO/IEC Guide 98-3 and ISO/IEC Guide 98-3/Supplement 2 [
17,
19]. In the case that
J cannot be evaluated because the function
f is not defined outside the region defined by the constraint, the covariance matrix associated with
cannot be defined and evaluated by means of Equation (
8). In this case, however, the sensitivity matrix defined in Equation (
20) can be used instead. This case is currently neither covered in ISO/IEC Guide 98-3 nor in ISO/IEC Guide 98-3/Supplement 2 [
17,
19].
A complementary viewpoint to the propagation of measurement uncertainty is obtained by considering the orthogonal projection
P, which was introduced in Equation (
3). Noting that an orthogonal projection fulfills
and
, it follows from Equation (
11) that for a well-formed covariance matrix [
6,
41], it holds that
As a consequence,
where
This matrix
as an orthogonal projection of
J on
offers an alternative definition to the matrix
as constructed in the algorithm.