<<

of a Gaussian with an exponential (and its application in programs halflife.c/nanofit.f)

Carl Wheldon May 24, 2019 1 Derivation of the convolution

The convolution of a normalised (unit area) Gaussian and an exponential is derived below (special thanks to Dr. Dave Forest (University of Birmingham) for the maths in Section 1. √ Taking a Gaussian , G(x), of full-width at half maximum (FWHM) of 2σ 2 ln(2) = 2.35σ (see Section 2), 1 −x2 G(x) = √ e 2σ2 (1) σ 2π The is defined with decay constant, λ, as,

F (x) = e−λx (2)

The convolution is given by,

∫ ∞ (y−x)2 1 −λx − I(y) = F (x) ∗ G(x) ≡ √ e e 2σ2 dx σ 2π 0 ∫ ∞ 2 2 2 1 − (x +2σ λx−2xy+y ) = √ e 2σ2 dx (3) σ 2π 0 Now use the transformation, 1 ( ) z = √ x − (y − σ2λ) (4) 2σ This yields: √ dx = 2σdz −(y − σ2λ) ⇒ at x = ∞, z = ∞ and at x = 0, z = √ 2σ 2 2 4 2 − 2 − 2 2 (x + y + σ λ 2xy + 2σ λx 2yσ λ z = 2 2σ ( ) (x2 + 2σ2λx − 2xy + y2) σ2λ ⇒ = z2 + λ y − (5) 2σ2 2 The results from Eqns. 5 above, can be substituted into Eqn. 3, leading to, ( ) ∫ σ2λ ∞ 1 −λ y− 2 √ 2 −z I(y) = e − − 2 e dz (6) π (y√ σ λ) 2σ

1 The , erf(x), can be introduced as follows: ∫ x 2 2 erf(x) = √ e−z dz (7) π 0 and corresponds to the area under the Gaussian curve between −x and x. However, erf(x) is defined for all values of x and is an odd function, such that erf(−x) = −erf(x). See Fig. 1. Correspondingly, the complementary error function, erfc(x), is the area outside of −x and x implying, ∫ ∞ 2 2 erfc(x) = 1 − erf(x) = √ e−z dz (8) π x

Figure 1: A plot of the error function, erf(x).

Using the above result (Eqn. 8) in Eqn. 6 leads to, ( ) {√ ( )} 2 2 1 −λ y− σ λ π −(y − σ λ) I(y) = √ e 2 erfc √ π 2 [ ( 2σ )] 2 − − 2 1 −λ(y− σ λ ) (y σ λ) = e 2 1 − erf √ (9) 2 2σ The final result for the convolution is, therefore, [ ( )] 2 − 2 1 −λ(y− σ λ ) (y σ λ) I(y) = e 2 1 + erf √ (10) 2 2σ

For a non-zero offset for the Gaussian centroid, y is replaced by y − k, where k is the offset.

2 Gaussian FWHM

The FWHM is defined as the distance between two points either side of the Gaussian centroid at which the height falls to half of the height at the centroid, i.e.

FWHM = 2|x − y| (11) where the centroid lies at x and the Gaussian fall to half the centroid height at y, Such that,

2 G(x) 1 [G(x) − G(y)] = [G(x) − ] = G(x) [ ] 2 2 1 −x2 −y2 1 −x2 ⇒ √ e 2σ2 − e 2σ2 = √ e 2σ2 σ 2π 2σ 2π 1 −x2 −y2 ⇒ e 2σ2 − e 2σ2 = 1 (12) 2 −x2 −y2 ⇒ e 2σ2 = 2e 2σ2 2 − 2 ⇒ (y x ) 2 = ln(2) ( ) 2σ y2 − x2 = (y − x)(y + x) = |y − x|2 = 2σ2 ln(2) Therefore, √ FWHM = 2σ 2 ln(2) = 2.35σ (13)

3 Programs halflife.c/nanofit.f

In the eval function/subroutine the function is written as the instructions: ------x1 = x - pars(3) ep = (0.5*pars(2))/(pars(1)) xsq = (x1/pars(2)) + ep xt = x1/pars(1) ep = ep*ep e = xt + ep - xsq*xsq fit = 0.5*erfpol(xsq)*exp(e) e = xt + ep fit = exp(e) - fit ------√ where, pars(1) = −τ = −1/λ, pars(2) = 2σ, pars(3) = centroid of Gaussian = offset, k. Firstly, the equations from the code can be rewritten using the standard notation and ignoring k. Proceeding stepwise: x1 = x - pars(3) → x1 = y (14)

√ −λ 2σ ep = (0.5*pars(2))/(pars(1)) → ep = (15) ( 2 ) λ2σ2 ⇒ ep2 = (16) 2 √ y λ 2σ xsq = (x1/pars(2)) + ep → xsq = √ − (17) ( 2σ 2 ) y2 λ2σ2 ⇒ xsq2 = + − yλ (18) 2σ2 2

3 xt = x1/pars(1) → xt = −yλ (19) In the following, remember that the preceding line in the code sets ep to ep2

λ2σ2 y2 λ2σ2 e = xt + ep - xsq*xsq → e = −yλ + − − + yλ 2 2σ2 2 y2 e = − (20) 2σ2

The function erfpol(x) [1], returns [ex2 erfc(|x|)

fit = 0.5*erfpol(xsq)*exp(e)) → ( ) ( √ ) y2 2 2 2 1 + λ σ −yλ − y y λ 2σ 2σ2 2 2 fit1 = e e 2σ erfc √ − (21) 2 2σ 2 ( ) ( ) − − σ2λ − 2 1 λ y 2 y λσ fit1 = e erfc √ (22) 2 2σ

Continuing down the code ( ) σ2λ2 σ2λ e = xt + ep → e = −yλ + = −λ y − (23) 2 2

( ) ( ) ( ) 2 − − σ2λ − y−σ λ − 2 λ y 2 1 λ 2 y σ λ fit = exp(e) - fit → fit2 = e − e erfc √ 2 2σ ( ) [ ( )] − − σ2λ − 2 1 λ y 2 y σ λ fit2 = e 2 − erfc √ (24) 2 2σ

However, substituting from Section 1, Eqn. 8 yields, 2−erfc(x) = 1+(1−erfc(x)) = 1+erf(x). This gives the final result of ( ) [ ( )] − − σ2λ − 2 1 λ y 2 y σ λ fit2 = e 1 + erf √ (25) 2 2σ

This exactly matches the earlier result of Eqn. 10.

References

[1] C. Hastings, Approximations for Digital Computers, Princeton University Press, Prince- ton, New Jersey (1955).

4