Appendix C
Useful Formulae

 C.1 3D Quantities and Volume Integrals
  C.1.1 Differential Operators
   C.1.1.1 Gradient
   C.1.1.2 Laplacian
   C.1.1.3 Divergence
   C.1.1.4 Curl
  C.1.2 Vectorial Analysis
  C.1.3 Integral Theorems
  C.1.4 Dust Heating and Cooling: Two Ways of Slicing the Pis
   C.1.4.1 Solution 1
   C.1.4.2 Solution 2
 C.2 Statistics
  C.2.1 General Formulae
   C.2.1.1 Moments of a PDF
   C.2.1.2 Marginalization
   C.2.1.3 Variable Change
   C.2.1.4 Combining Uncertainties
  C.2.2 Useful Probability Distributions
   C.2.2.1 Binomial Distribution
   C.2.2.2 Poisson Distribution
   C.2.2.3 Gaussian Distribution
   C.2.2.4 Student’s t Distribution
   C.2.2.5 Split-Normal Distribution
   C.2.2.6 Lorentzian Distribution
  C.2.3 Drawing random variables from an arbitrary distribution
   C.2.3.1 The Rejection Method
   C.2.3.2 Inverting the CDF
 C.3 Trigonometry
  C.3.1 Transformations
   C.3.1.1 Rotations
   C.3.1.2 Relations Between Functions
  C.3.2 Addition
   C.3.2.1 Summing Angles
   C.3.2.2 Inverse Relations
  C.3.3 Linearization
   C.3.3.1 Squares and Cubes
   C.3.3.2 Inverse Relations

There is no royal road to science, and only those who do not dread the fatiguing climb of its steep paths have a chance of gaining its luminous summits.
 
(Karl MARX;  Marx, 1872)

This appendix contains various unrelated formulae that I find useful in my daily practice, but that I do not necessarily remember. The problem is that gathering them here suppresses any incentive to memorize them, therefore making it essential to have them written here.

C.1 3D Quantities and Volume Integrals

C.1.1 Differential Operators

The three most common coordinate systems are represented in Fig. C.1. In what follows, we express the differential operators in these systems.

PIC

dV = dx.dy.dz

dV = dρ.dϕ.dz

dV = dr.dϕ.d cos 𝜃

Figure C.1: Most common coordinate systems. Licensed under CC BY-SA 4.0.
C.1.1.1 Gradient
Cartesian:
U = U x x̂ + U y ŷ + U z . (C.1)
Cylindrical:
U = U ρ ρ̂ + 1 ρ U ϕ ϕ̂ + U z . (C.2)
Spherical:
U = U r r̂ + 1 r U 𝜃 𝜃̂ + 1 r sin 𝜃 U ϕ ϕ̂. (C.3)

C.1.1.2 Laplacian
Cartesian:
2U = 2U x2 + 2U y2 + 2U z2 . (C.4)
Cylindrical:
2U = 1 ρ ρ ρU ρ + 1 ρ2 2U ϕ2 + 2U z2 . (C.5)
Spherical:
2U = 1 r 2 r2 rU + 1 r2 sin 𝜃 𝜃 sin 𝜃U 𝜃 + 1 r2 sin 2𝜃 2U ϕ2 . (C.6)

C.1.1.3 Divergence
Cartesian:
.A = Ax x + Ay y + Az z . (C.7)
Cylindrical:
.A = 1 ρ ρ ρAρ + 1 ρ Aϕ ϕ + Az z . (C.8)
Spherical:
.A = 1 r2 r r2A r + 1 r sin 𝜃 𝜃 sin 𝜃A𝜃 + 1 r sin 𝜃 Aϕ ϕ . (C.9)

C.1.1.4 Curl
Cartesian:
A = Az y Ay z x̂ + Ax z Az x ŷ + Ay x Ax y . (C.10)
Cylindrical:
A = 1 ρ Az ϕ Aϕ z ρ̂ + Aρ z Az ρ ϕ̂ + 1 ρ ρAϕ ρ Aρ ϕ . (C.11)
Spherical:
A = 1 r sin 𝜃 sin 𝜃Aϕ 𝜃 A𝜃 ϕ r̂ + 1 r sin 𝜃 Ar ϕ sin 𝜃rAϕ r 𝜃̂ + 1 r rA𝜃 r Ar 𝜃 ϕ̂. (C.12)

C.1.2 Vectorial Analysis

A. B C = B. C A = C. A B (C.13) A B C = A.CB A.BC (C.14) A B. C D = A.C B.D A.D B.C (C.15) ψ = 0 (C.16) . A = 0 (C.17) A = .A 2A (C.18) . ψA = A.ψ + ψ.A (C.19) ψA = ψ A + ψ A (C.20) A.B = A.B + B.A + A B + B A (C.21) . A B = B. A A. B (C.22) A B = A .B B .A + B.A A.B (C.23)

C.1.3 Integral Theorems

V .AdV = A.dS (C.24) V ψdV = ψdS (C.25) V AdV = A dS (C.26) V ϕ2ψ + ϕ.ψdV = ϕψ.dS (C.27) V ϕ2ψ ψ2ϕdV = ϕψ ψϕ.dS (C.28) S A.dS = CA.dl (C.29) Sψ dS = Cψdl (C.30)

C.1.4 Dust Heating and Cooling: Two Ways of Slicing the Pis

One of the most elementary equations for a grain is the relation between its absorption efficiency and the power it absorbs or emits, given in Eq. (1.77) and Eq. (1.78). Yet, it often causes problems to newcomers, who, by trying to visualize the rays, get the numerical factor in the integrand (4π2a2) wrong. I have seen several improper values: 16π2a2, 4πa2, etc. The solution is of course to explicitly write the integral, which I do below. I also provide two alternative visual solutions to count the factor the right way.

PIC

Figure C.2: Two ways of slicing the πs. This figure represents the two possible orders to integrate the power absorbed by a grain. For the emitted power, the direction of the arrows is simply reversed. Licensed under CC BY-SA 4.0.

The power absorbed by a spherical grain of radius a, exposed to an isotropic ISRF with mean intensity Jν, Pabs, can expressed as:

dPabs(a,𝜃,ϕ) = 0Q abs(a,ν)Jν(ν)dνdAdΩ, (C.31)

where dA and dΩ = d cos 𝜃dϕ are the grain surface and solid angle elements. Ω indicates the direction of the incident rays. The possible orders of the integrals over these two elements is illustrated in Fig. C.2.

C.1.4.1 Solution 1

The case represented in Fig. C.2.a corresponds to the case where we first integrate over dA. Thus, parallel rays with a given direction (𝜃,ϕ) intercept the grain on a surface πa2:

dPabs(a,𝜃,ϕ) = πa2 0Q abs(a,ν)Jν(ν)dνdΩ. (C.32)

Then, we need to integrate over all the possible ray directions:

Pabs(a) = πa2 0Q abs(a,ν)Jν(ν)dν spheredΩ = 04π2a2Q abs(a,ν)Jν(ν)dν. (C.33)

C.1.4.2 Solution 2

The case represented in Fig. C.2.b corresponds to the case where we first integrate the flux over the ray directions, on an incident surface:

dPabs(a) = 0Q abs(a,ν)Jν(ν)dν01 cos 𝜃d cos 𝜃02πdϕ = π 0Q abs(a,ν)Jν(ν)dν. (C.34)

There is only a π factor here, as we integrate the flux on a surface element, somewhere on the grain. The rest of the grain shields this surface from the radiation coming from the other hemisphere. In addition, this integration is weighted by the inclination of the rays on the surface (this is the classical flux formula). We thus have the flux received by a surface element of the grain, from all possible ray directions. We now simply need to integrate over the whole grain surface: 4πa2:

Pabs(a) =04π2a2Q abs(a,ν)Jν(ν)dν. (C.35)

C.2 Statistics

C.2.1 General Formulae

C.2.1.1 Moments of a PDF

Definitions. If we have a joint PDF, p(x,y), of two variables, X and Y , the first moments are the following.

Normalization:
1 = p(x,y)dxdy. (C.36)
Mean:
X xp(x,y)dxdy. (C.37)
Variance:
V (X) x X2p(x,y)dxdy. (C.38)
Skewness:
γ1(X) x X σ(X) 3p(x,y)dxdy. (C.39)
Covariance:
V (X,Y ) x X× y Y p(x,y)dxdy. (C.40)
Standard-deviation:
σ(X) V (X). (C.41)
Correlation coefficient:
ρ(X) V (X,Y )σ(X)σ(Y ). (C.42)

Estimators. The most commonly used non-robust estimators are the following.

Mean:
X 1 N i=1Nx i ± σ N. (C.43)
Standard-deviation:
σ(X) 1 N 1 i=1N xi X2 ± σ 2(N 1) . (C.44)
Skewness:
γ1(X) N (N 1)(N 2) i=1N xi X σ(X) 3. (C.45)
Correlation coefficient:
ρ(X,Y ) 1 N 1 i=1N xi X σ(X) yi Y σ(Y ) . (C.46)

C.2.1.2 Marginalization

Marginalizing over a parameter, 𝜃:

p(y) =p 𝜃p y|𝜃d𝜃. (C.47)

Comparing two data sets, y and :

p |y =p |𝜃p 𝜃|yd𝜃. (C.48)

C.2.1.3 Variable Change

If we have two sets of random variables, u and v, such that v = f(u), then the relation between their PDF is:

pv v = |𝕁|× pu f1 v, (C.49)

where the Jacobian of the transformation is:

𝕁i,j ui vj. (C.50)

C.2.1.4 Combining Uncertainties

If we have a set of random variables, x, the uncertainty of an arbitrary function of these parameters, f(x), is given by:

σ2 f(x) = f(x) T 𝕍f(x), (C.51)

where 𝕍 is the covariance matrix of the variable set. In the 2D case, posing x = (a,b), we have:

f = f a f b & 𝕍 = σa2 ρσ aσb ρσaσb σb2 , (C.52)

and Eq. (C.51) gives the usual expression:

σf(x)2 = f a2σ a2 + f b2σ b2 + 2 f a f bρσaσb. (C.53)

Similarly, the covariance of two functions of the parameter set, f(x) and g(x), is:

V (f(x),g(x)) = f(x) T 𝕍g(x). (C.54)

Rant about systematics. There is a long-lasting laboratorian legend that “systematics must be non-quadratically summed”. This is true in some cases and false in others. Everything depends on what we are talking about.

1.
If we are measuring a flux, F, with noise, σnoise, and calibration uncertainty (systematics), σcal, the total uncertainty on the flux will be, according to Eq. (C.53): σtot = σnoise 2 + σcal 2. This is because ρ = 0. The fluctuations of the detector’s signal at the time of the observation do not have anything to do with the error the instrument’s team made by deriving the calibration factor.
2.
Now, if we are summing the flux in two pixels with same flux and noise levels, we will get, using Eq. (C.53): σtot = 2σnoise 2 + 4σcal 2, because the calibration factors of the pixels were correlated. The total calibration uncertainty is this time linearly summed: σcaltot = 2σcal, because ρ = 1 (the error due to the calibration uncertainty is the same for both pixels).
3.
If we are now summing two systematics, such as the calibration and the background subtraction uncertainties, σcal and σback, we will sum them quadratically: σsyst = σcal 2 + σback 2. This is because the error the instrument’s team made deriving the calibration factor is independent of the error we have made by selecting a region in one of the corners of our map, assuming it was free of galaxy emission.

C.2.2 Useful Probability Distributions

C.2.2.1 Binomial Distribution

Discrete probability distribution to get r successes out of n tries, each one having a probability p:

Pbinomial(r|p,n) Crnpr(1 p)nr = n! r!(n r)!pr(1 p)nr, (C.55)

with r = np and σ(r) = np(1 p).

C.2.2.2 Poisson Distribution

Discrete probability distribution to get r events per unit time knowing the mean expected number, λ, of such events per unit time:

PPoisson(r|λ) eλλr r! , (C.56)

with r = λ and σ(r) = λ. The superposition of two Poissonian events (λa,λb) is also Poissonian with mean λ = λa + λb. It is the limit of the binomial distribution to large numbers:

PPoisson(r|λ) = lim nPbinomial r|λ n,n. (C.57)

C.2.2.3 Gaussian Distribution
PGauss(x|μ,σ) 1 2πσ exp (x μ)2 2σ2 , (C.58)

with x = μ, σ(x) = σ and all superior moments equal to 0. It is the limit of a Poisson distribution when λ » 1: PPoisson(r|λ) = lim λ»1PGauss r|λ,λ.

Multivariate form. A multivariate normal law of mean μ and covariance matrix 𝕍 is defined as:

PGauss(x|μ, 𝕍) 1 (2π)n2|𝕍| exp 1 2 x μT 𝕍1 x μ. (C.59)

Error function. Noting Φ(x) the CDF of a reduced normal law, the error function is defined such that:

Φ(x) = 1 2 1 + erf x 2 . (C.60)

It is thus:

erf (x) 2 π0xet2 dt = 2Φ x2 1. (C.61)

C.2.2.4 Student’s t Distribution

It is defined as:

PStudent(x|f) 1 fπ Γ f + 1 2 Γ f 2 1 + x2 f f+1 2 , (C.62)

with f > 0 being the degree of freedom. Its mean is 0 and its standard-deviation, for f > 2, is σ = f(f 2).

C.2.2.5 Split-Normal Distribution

It is, to my mind, the most convenient asymmetric distribution:

Psplitnorm(x|μ,λ,τ) 2 π 1 λ(1 + τ)× exp 1 2 x μ λ 2  if x μ exp 1 2 x μ λτ 2  if x > μ. (C.63)

Posing:

b = π 2 π (τ 1)2 + τ, (C.64)

the first moments are:

X = μ + 2 πλ(τ 1) σ(X) = bλ γ1(X) = b32 2 π(τ 1) × 4 π 1 (τ 1)2 + τ. (C.65)

C.2.2.6 Lorentzian Distribution
PLorentz(x|μ,γ) 2 πγ 1 1 + x μ γ2 2. (C.66)

Its mean is μ, its FWHM is γ, but its standard-deviation is not defined.

C.2.3 Drawing random variables from an arbitrary distribution

C.2.3.1 The Rejection Method

The rejection method is a widely used technique to draw a random variable, x, from an arbitrary PDF, f(x). It requires the ability to easily draw a random variable, x1, from a proposal distribution, g(x), such that g(x) f(x) x. In case f(x) is finite over [xmin,xmax], we can take:

g(x) = max (f)  for xmin x xmax 0  elsewhere.  (C.67)

The algorithm is the following.

1.
Draw a random variable x1 from g(x).
2.
Draw a uniform random variable between 0 and 1, Θ1.
3.
If Θ1 < f(x1)g(x1), then x = x 1 is accepted. Otherwise, if Θ1 f(x1)g(x1), this draw is rejected, and we need to go back to the first step.

The closer g(x) is from f(x), the lower the rejection rate will be, and the faster the method will be. It is illustrated in Fig. C.3.a.

PIC PIC
Figure C.3: Methods for drawing random numbers from arbitrary distributions. Panel (a) represents the rejection method applied to the distribution in blue, with the proposal in red. We have represented a first rejected draw and a second accepted one. Panel (b) represents the CDF method applied to the distribution in panel (a). Licensed under CC BY-SA 4.0.

C.2.3.2 Inverting the CDF

A general Monte-Carlo technique to draw a random variable, x, from an arbitrary PDF, f(x), consists in drawing a uniform random variable between 0 and 1, Θ, and inverting the Cumulative Distribution Function (CDF) of f(x):

F(x) xf(y)dy. (C.68)

The desired random variable is then simply:

x = F1(Θ). (C.69)

It is illustrated in Fig. C.3.b.

C.3 Trigonometry

cos a = cos b a = b[2π] a = b[2π] (C.70) sin a = sin b a = b[2π] a = π b[2π] (C.71) tan a = tan b a = b[2π] (C.72)

C.3.1 Transformations

C.3.1.1 Rotations

cos π 2 + x = sin x sin π 2 + x = cos x (C.73) cos π 2 x = sin x sin π 2 x = cos x (C.74) cos (π x) = cos x sin (π x) = sin x (C.75) cos (π + x) = cos x sin (π + x) = sin x (C.76) cos (x) = cos x sin (x) = sin x (C.77)

C.3.1.2 Relations Between Functions

cos 2x + sin 2x = 1 1 + tan 2x = 1 cos 2x (C.78) cos (2x) = 1 tan 2x 1 + tan 2x sin (2x) = 2 tan x 1 + tan 2x tan (2x) = 2 tan x 1 tan 2x (C.79)

C.3.2 Addition

C.3.2.1 Summing Angles

cos (a b) = cos a. cos b + sin a. sin b cos (a + b) = cos a. cos b sin a. sin b (C.80) sin (a b) = sin a. cos b cos a. sin b sin (a + b) = sin a. cos b + cos a. sin b (C.81) tan (a b) = tan a tan b 1 + tan a. tan b tan (a + b) = tan a + tan b 1 tan a. tan b (C.82)

C.3.2.2 Inverse Relations
cos a. cos b = 1 2 cos (a b) + cos (a + b) (C.83)
cos a. sin b = 1 2 sin (a + b) sin (a b) (C.84)
sin a. sin b = 1 2 cos (a b) cos (a + b) (C.85)

cos a + cos b = 2 cos a + b 2 cos a b 2 cos a cos b = 2 sin a + b 2 sin a b 2 (C.86) sin a + sin b = 2 sin a + b 2 cos a b 2 sin a sin b = 2 sin a b 2 cos a + b 2 (C.87)

C.3.3 Linearization

C.3.3.1 Squares and Cubes

cos 2x = 1 + cos (2x) 2 sin 2x = 1 cos (2x) 2 tan 2x = 1 cos (2x) 1 + cos (2x) (C.88) cos 3x = cos (3x) + 3 cos x 4 sin 3x = sin (3x) + 3 sin x 4 tan 3x = sin (3x) + 3 sin x cos (3x) + 3 cos x (C.89)

C.3.3.2 Inverse Relations
cos (2x) = cos 2x sin 2x = 2 cos 2x 1 = 1 2 sin 2x (C.90)
sin (2x) = 2 sin x. cos x tan (2x) = 2 tan x 1 tan 2x (C.91)
cos (3x) = 4 cos 3x 3 cos x sin (3x) = 3 sin x 4 sin 3x tan (3x) = 3 tan x tan 3x 1 3 tan 2x (C.92)