In this section, we have assembled assorted mathematical and plotting techniques that come in handy through out this book.
Spherical trigonometry has widespread applications throughout the book. It is used in the transformations of observed directions to virtual poles (Chapter 2) and transformation of coordinate sytems, to name a few. Here we summarize the two most useful relationships: the Law of Sines and the Law of Cosines.
In Figure A.1, α,β and γ are the angles between the great circles labelled a, b, and c. On a unit sphere, a,b and c are also the angles subtended by radii that intersect the globe at the apices A, B, and C (see inset on Figure A.1). Two formulae from spherical trigonometry come in handy in paleomagnetism, the Law of Sines:
 (A.10) 
and the Law of Cosines:
 (A.11) 

To add the two vectors (see Figure A.2) A and B, we break each vector into components A_{x,y} and B_{x,y}. For example, A_{x} = Acosα,A_{y} = Asinα where A is the length of the vector A. The components of the resultant vector C are: C_{x} = A_{x} + B_{x},C_{y} = A_{y} + B_{y}. These can be converted back to polar coordinates of magnitude and angles if desired, whereby:
To subtract two vectors, compute the components as in addition, but the components of the vector difference C are: C_{x} = A_{x}  B_{x},C_{y} = A_{y}  B_{y}.
There are two ways to multiply vectors. The first is the dot product whereby A ⋅ B = A_{x}B_{x} + A_{y}B_{y}. This is a scalar and is actually the cosine of the angle between the two vectors if the A and B are taken as unit vectors (assume a magnitude of unity in the component calculation.

The other way to perform vector multiplication is the cross product (see Figure A.3), which produces a vector orthogonal to both A and B and whose components are given by:
To calculate the determinant, we follow these rules:
or
Vectors belong to a more general concept called tensors. While a vector describes a magnitude of something in a given direction, tensors allow calculation of magnitudes as a function of orientation. Velocity is a vector relating speed to direction, but speed may change depending on direction, so we might need a tensor to calculate speed as a function of direction. Many properties in Earth science require tensors, like the indicatrix in mineralogy which relates the speed of light to crystallographic direction, or the relationship between stress and strain. Tensors in paleomagnetism are used, for example, to transform coordinate systems and to characterize the anisotropy of magnetic properties such as susceptibility. We will cover transformation of coordinate systems in the following.
We use direction cosines in paleomagnetism in a variety of applications, from mineralogy to transformation from specimen to geographic or stratigraphic coordinate systems. Direction cosines are the cosines of the angles between different axes in given coordinate systems, here X and X′ respectively (see, e.g., Figure A.4a.) The direction cosine a_{12} is the cosine of the angle between the X_{1} and the X′_{2}, α_{12} axes. We can define four of these direction cosines to fully describe the relationship between the two coordinate systems:
The first subscript always refers to the X system and the second refers to the X′.

One application of using direction cosines is the transformation of coordinates systems from one set (X) to a new set X′. To find new coordinates x′_{1},x′_{2},.. from the old (x_{1},x_{2},...), we have:
In three dimensions we have:
which can also be written as:
 (A.12) 
with a short cut notation as: x′_{i} = a_{ij}x_{j}. However we write this, it means that for each axis i, just sum through the j’s for all the dimensions. The matrix a_{ij} is an example of a 3 x 3 tensor and equations of the form A_{i} = B_{ij}C_{j} relating two vectors with a tensor will be used throughout the book. A more common notation is with boldfaced variables which indicate vectors or tensors, e.g., A = B ⋅ C.

Now we would like to apply this to changing coordinate systems for a paleomagnetic specimen in the most general case. The specimen coordinate system is defined by a righthand rule where the thumb (X_{1}) is directed parallel to an arrow marked on the sample, the index finger (X_{2}) is in the same plane but at right angles and clockwise to X_{1} and the middle finger (X_{3}) is perpendicular to the other two (Figure A.5a). The transformation of coordinates (x_{i}) from the X_{i} axes to the coordinates in the desired X′ coordinate system requires the determination of the direction cosines as described in Appendix A.3.5. The various a_{ij} can be calculated using spherical trigonometry as in Appendix A.3.1. For example, a_{11} for the general case depicted in Figure A.5 is cosα, which is given by the Law of Cosines (see Appendix A.3.1) by using appropriate values, or:
The other a_{ij} can be calculated in a similar manner. In the case of most coordinate system rotations used in paleomagnetism, X_{2} is in the same plane as X′_{1} and X′_{2} (and is horizontal) so ψ = 90^{∘}. This problem is much simpler. The directions cosines for the case where ψ = 90^{∘} are:
 (A.13) 
The new coordinates can be obtained from Equation A.12, as follows:
 (A.14) 
The declination and inclination can be calculated by inserting these values in the equations in Chapter 2.
Given the coordinates of the point on the globe P_{p} with latitude λ_{p}, longitude ϕ_{p} the finite rotation pole P_{f} with latitude λ_{f}, longitude ϕ_{f}, the way to transform coordinates is as follows (you should also review Appendix A.3.5).
Table A.4: Finite rotations for selected Gondwana continents.
Rotates continent to South African fixed coordinates.
AUS: Australia, ANT: East Antarctica; IND: India; SAM:
South American Craton. [Rotations of Torsvik et al. (2008)
 see for additional data.]
 
Age  EUR  NAM  GRN  
Ma  λ  ϕ  Ω  λ  ϕ  Ω  λ  ϕ  Ω  
EUR  NAM  GRN  
5  17.9  27.1  0.6  80.9  22.8  1.3  80.9  22.8  1.3  
10  18.4  26.3  1.2  80.9  22.9  2.6  80.9  22.9  2.6  
15  18.9  24.6  1.8  80.9  23.2  4.1  80.9  23.2  4.1  
20  17.2  22.7  2.4  80.6  24.4  5.5  80.6  24.4  5.5  
25  20.7  19  3  79.5  28.1  6.8  79.5  28.1  6.8  
30  24.9  19.5  4.3  77.3  12.5  8.6  77.3  12.5  8.6  
35  27.2  19.3  5.8  75.4  3.5  10.5  74.8  7.2  10.2  
40  28.7  18.5  7.5  74.5  1.1  12.6  72.6  9.5  11.5  
45  30.3  18.2  9  74.3  4.3  14.6  71.4  11.4  12.7  
50  30.8  16.7  10  75.9  3.5  16.2  71  20.7  14.2  
55  32.7  15.4  11.3  79.8  4.1  17.6  71.8  29.6  16.8  
60  34.8  15.7  12.6  81.6  5.1  19.1  71.9  30.5  17.5  
65  36  15.8  13.6  82.6  3.2  20.7  71.3  32.9  17.6  
70  35.4  16.1  14.9  81.6  6.5  22.4  69.8  29  17.9  
75  35.5  15.7  15.5  80.4  13.1  24.6  69  26.6  18.5  
80  36.1  15.2  16.9  78.2  18.8  27.5  67.6  21  19.8  
85  37  14.2  18.8  76.2  21.3  30.5  66.3  16.4  21.5  
90  39.6  13.7  21.9  74.6  23  33.8  65.9  11.5  24.2  
95  39.8  13.7  25.2  72  24.7  36.9  64.2  5.5  26.9  
100  40.2  12.5  28.5  70  24  40.2  62.7  2.8  30.1  
105  41.6  11.2  31.7  69.1  23.3  43.6  62.4  1.6  33.3  
110  42.6  9.8  34.5  68.3  22.6  47  62.1  0.9  36.5  
115  43.4  8.5  37.3  67.6  21.8  50.4  61.8  0.5  39.7  
120  44.5  6.9  40.3  67.1  20.4  53.9  61.8  0.8  43.1  
125  45.3  6.3  42  67  19.7  55.6  61.9  1  44.9  
130  45.9  5.7  43  67  19.1  56.7  62.2  1.3  46  
135  46.6  5.3  44  67.1  18.7  57.9  62.4  1.6  47.1  
140  47.3  4.9  45.2  67.2  18.4  59.2  62.7  1.6  48.4  
145  47.8  4.8  46.4  67.1  18.3  60.5  62.9  1.3  49.7  
150  48.6  4  47.9  67.3  17.6  62.2  63.2  1.8  51.4  
155  49.8  2.2  50  67.6  15.5  64.6  63.7  3.6  53.8  
160  50.6  1.2  52.1  67.6  14.5  66.8  64.1  4.2  56  
165  51.4  0.3  54.2  67.7  13.6  69.1  64.4  4.8  58.3  
170  52.1  0.6  56.3  67.8  12.8  71.4  64.7  5.3  60.6  
175  52.9  1.9  59.6  67.7  11.5  74.8  64.8  6  64.1  
180  53  2  60  67.7  11.5  75.3  64.9  6  64.5  
185  53  2  60.4  67.7  11.5  75.7  64.9  5.9  64.9  
190  53.1  2.1  60.8  67.7  11.5  76.1  65  5.9  65.4  
195  53.2  2.2  61.1  67.7  11.5  76.6  65  5.8  65.8  
200  53.3  2.2  61.5  67.7  11.5  77  65.1  5.8  66.2  
205  53.2  2.6  59.7  67.7  11.5  77.4  65.1  5.7  66.7  
210  53.1  2.9  57.8  67.7  11.5  77.9  65.2  5.7  67.1  
215  53.1  3.3  55.9  67.7  11.5  78.3  65.2  5.6  67.5  
220  52.9  3.6  53.6  67.7  11.5  78.3  65.2  5.6  67.5  
225  52.7  4  51.4  67.7  11.5  78.3  65.2  5.6  67.5  
230  52.4  4.4  49.1  67.7  11.5  78.3  65.2  5.6  67.5  
235  52.2  4.8  46.8  67.7  11.5  78.3  65.2  5.6  67.5  
240  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
245  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
250  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
255  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
260  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
265  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
270  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
275  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
280  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
285  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
290  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
295  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
300  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
305  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
310  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
315  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  
320  51.9  5.3  44.5  67.7  11.5  78.3  65.2  5.6  67.5  

The orientation tensor T (Scheidegger, 1965) (also known as the matrix of sums of squares and products), is extremely useful in paleomagnetism. This is found as follows:
 (A.15) 
where N is the number of data points involved. Note that for unit vectors, the center of mass is the same as the Fisher mean (Chapter 11).
 (A.16) 
where x′_{i} are the transformed coordinates.
 (A.17) 
T is a 3 x 3 matrix, where only six of the nine elements are independent. It is constructed in some coordinate system, such as the geographic or sample coordinate system. Usually, none of the six independent elements are zero. There exists, however, a coordinate system along which the “offaxis” terms are zero and the axes of this coordinate system are called the eigenvectors of the matrix. The three elements of T in the eigenvector coordinate system are called eigenvalues. In terms of linear algebra, this idea can be expressed as:
 (A.18) 
where V is the matrix containing three eigenvectors and τ is the diagonal matrix containing three eigenvalues. Equation A.18 is only true if:
 (A.19) 
If we expand equation A.19, we have a third degree polynomial whose roots (τ) are the eigenvalues:
The three possible values of τ (τ_{1},τ_{2},τ_{3}) can be found with iteration and determination. In practice, there are many programs for calculating τ. My personal favorite is the Numpy Module for Python (see many free websites, especially Scientific Python (SciPy) for hints). Please note that the conventions adopted here are to scale the τ’s such that they sum to one; the largest eigenvalue is termed τ_{1} and corresponds to the eigenvector V_{1}.
Inserting the values for the transformed components calculated in equation A.16 into T gives the covariance matrix for the demagnetization data. The direction of the axis associated with the greatest scatter in the data (the principal eigenvector V_{1}) corresponds to a bestfit line through the data. This is usually taken to be the direction of the component in question. This direction also corresponds to the axis around which the “moment of inertia” is least. The eigenvalues of T are the variances associated with each eigenvector. Thus the standard deviations are σ_{i} = .
We often wish to differentiate a function along three orthogonal axes. For example, imagine we know the topography of a ski area (see Figure A.6). For every location (in say, X and Y coordinates), we know the height above sea level. This is a scalar function. Now imagine we want to build a ski resort, so we need to know the direction of steepest descent and the slope (red arrows in Figure A.6).

To convert the scalar field (height versus position) to a vector field (direction and magnitude of greatest slope) mathematically, we would simply differentiate the topography function. Let’s say we had a very weird two dimensional, sinusoidal topography such that z = f(x) = sinx with z the height and x is the distance from some marker. The slope in the x direction (), then would be d _ dxf(x). If f(x,y,z) were a three dimentional topography then the gradient of the topography function would be:
For short hand, we define a “vector differential operator” to be a vector whose components are
This can also be written in polar coordinates:
The divergence of a vector function (e.g. H) is written as:
The trick here is to treat ∇ as a vector and use the rules for dot products described in Appendix A.3.2. In cartesian coordinates, this is:
Like all dot products, the divergence of a vector function is a scalar.
The name divergence is well chosen because ∇⋅ H is a measure of how much the vector field “spreads out” (diverges) from the point in question. In fact, what divergence quantifies is the balance between vectors coming in to a particular region versus those that go out. The example in Figure A.7 depicts a vector function whereby the magnitude of the vector increases linearly with distance away from the central point. An example of such a function would be v(r) = r. The divergence of this function is:
Now consider Figure A.8, which depicts a vector function that is constant over space, i.e. v(r) = k. The divergence of this function is:
The zero divergence means that for every vector leaving the box, there is an equal and opposite vector coming in. Put another way, no net flux results in a zero divergence. The fact that the divergence of the magnetic field is zero means that there are no point sources (monopoles), as opposed to electrical fields that have divergence related to the presence of electrons or protons.
The curl of the vector function B is defined as ∇× B. In cartesian coordinates we have
Curl is a measure of how much the vector function “curls” around a given point. The function describing the velocity of water in a whirlpool has a significant curl, while that of a smoothly flowing stream does not.
Consider Figure A.9 which depicts a vector function v = y + xŷ. The curl of this function is:
or
The magnetic field has a nonzero curl in the presence of currents or changing electric fields. In free space, away from currents (lightning!!), the magnetic field has zero curl.
Sometimes things just are not normal. Statistically that is. When you can not assume that your data follow some known distribution, like the normal distribution, or the Fisher distribution, what do you do? In this section, we outline a technique called the bootstrap, which allows us to make statistical inferences when parametric assumptions fail. The reader should also refer to Efron and Tibshirani (1993) for a more complete discussion.
In Figure A.10, we illustrate the essentials of the statistical bootstrap. We will develop the technique using data drawn from a normal distribution. First, we generate a synthetic data set by drawing 500 data points from a normal distribution with a mean of 10 and a standard deviation σ of 2. The synthetic data are plotted as a histogram in Figure A.10a. In Figure A.10b we plot the data as a QQ plot (see Appendix B.1.5) against the z_{i} expected for a normal distribution.

The data in Figure A.10a plot in a line on the QQ plot (Figure A.10b). The value for D is 0.0306. Because N = 500, the critical value of D, D_{c} at the 95% confidence level is 0.0396. Happily, our normal distribution simulation program has produced a set of 500 numbers for which the null hypothesis of a normal distribution has not been rejected. The mean of the synthetic dataset is about 10 and the standard deviation is 1.9. The usual Gaussian statistics allow us to estimate a 95% confidence interval for the mean as ±1.96σ∕ or ±0.17.

In order to estimate a confidence interval for the mean using the bootstrap, we first randomly draw a list of N data by selecting data points from the original data set. This list is called a pseudosample of the data. Some data points will be used more than once and others will not be used at all. We then calculate the mean of the pseudosample. We repeat the procedure of drawing pseudosamples and calculating the mean many times (say 10,000 times). A histogram of the “bootstrapped” means is plotted in Figure A.10c. If these are sorted such that the first mean is the lowest and the last mean is the highest, the 95% of the means are between the 250^{th} and the 9,750^{th} mean. These therefore are the 95% confidence bounds because we are approximately 95% confident that the true mean lies between these limits. The 95% confidence interval calculated for the data in Figure A.10 by bootstrap is about ± 0.16 which is nearly the same as that calculated the Gaussian way. However, the bootstrap required orders of magnitude more calculations than the Gaussian method, hence it is illadvised to perform a bootstrap calculation when a parametric one will do. Nonetheless, if the data are not Gaussian, the bootstrap provides a means of calculating confidence intervals when there is no quick and easy way. Furthermore, with a modern computer, the time required to calculate the bootstrap illustrated in Figure A.10 was virtually imperceptible.
In a sun compass problem, we have the direction of the sun’s shadow and an angle between that and the desired direction (α). The declination of the shadow itself is 180^{∘} from the direction toward the sun. In Figure A.11, the problem of calculating declination from sun compass information is set up as a spherical trigonometry problem, similar to those introduced in Chapter 2 and Appendix A.3.1. The declination of the shadow direction β′, is given by 180  β. We also know the latitude of the sampling location L (λ_{L}). We need to calculate the latitude of S (the point on the Earth’s surface where the sun is directly overhead), and the local hour angle H.
Knowing the time of observation (in Universal Time), the position of S (λ_{s} = δ,ϕ_{s} in Figure A.11) can be calculated with reasonable precision (to within 0.01^{∘}) for the period of time between 1950 and 2050 using the procedure recommended in the 1996 Astronomical Almanac:
We can now calculate the Greenwich Hour Angle GHA from the Universal Time U (in minutes) by GHA = (U + E)∕4 + 180. The local hour angle (H in Figure A.11) is GHA + ϕ_{L}. We calculate β using the laws of spherical trigonometry (see Appendix A.3.1). First we calculate θ by the Law of Cosines (remembering that the cosine of the colatitude equals the sine of the latitude):
and finally using the Law of Sines:
If λ_{s} < λ_{L}, then the required angle is the shadow direction β′, given by: β′ = 180  β. The azimuth of the desired direction is β′ plus the measured shadow angle α.