This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

A two-domain MATLAB implementation
for efficient computation of the
Voigt/complex error function

Sanjar M. Abrarov, Rehan Siddiqui, Rajinder K. Jagpal
and Brendan M. Quine
(October 5, 2022)
Abstract

In this work we develop a new algorithm for the efficient computation of the Voigt/complex error function. In particular, in this approach we propose a two-domain scheme where the number of the interpolation grid-points is dependent on the input parameter yy. The error analysis we performed shows that the MATLAB implementation meets the requirements for radiative transfer applications involving the HITRAN molecular spectroscopic database. The run-time test shows that this MATLAB implementation provides rapid computation, especially at smaller ranges of the parameter xx.
Keywords: complex error function; Faddeeva function; Voigt function; interpolation

1 Introduction

The complex error function, also known as the Faddeeva function, is defined as [1, 2, 3, 4]

w(z)=ez2(1+2iπ0zet2𝑑t),w\left(z\right)=e^{-z^{2}}\left(1+\frac{2i}{\sqrt{\pi}}\int\limits_{0}^{z}{e^{t^{2}}dt}\right), (1)

where z=x+iyz=x+iy is a complex argument. The complex error function w(z)w\left(z\right) is closely related to the complex probability function [2]

W(z)=iπet2zt𝑑t.W\left(z\right)=\frac{i}{\pi}\int\limits_{-\infty}^{\infty}{\frac{e^{-t^{2}}}{z-t}}dt.

The complex probability function can be written in terms of its real and imaginary parts [2]

W(z)=K(x,y)+iL(x,y)W\left(z\right)=K\left(x,y\right)+iL\left(x,y\right)

such that

K(x,y)=Re[W(z)]=yπet2y2+(xt)2𝑑tK\left(x,y\right)=\operatorname{Re}\left[W\left(z\right)\right]=\frac{y}{\pi}\int\limits_{-\infty}^{\infty}{\frac{e^{-t^{2}}}{y^{2}+{\left(x-t\right)^{2}}}}dt (2)

and

L(x,y)=Im[W(z)]=1πet2(xt)y2+(xt)2𝑑t.L\left(x,y\right)=\operatorname{Im}\left[W\left(z\right)\right]=\frac{1}{\pi}\int\limits_{-\infty}^{\infty}{\frac{e^{-t^{2}}\left(x-t\right)}{y^{2}+\left(x-t\right)^{2}}}dt. (3)

Both functions w(z)w\left(z\right) and W(z)W\left(z\right) are equal to each other on the upper half of the complex plane, when y=Im[z]>0y=\operatorname{Im}\left[z\right]>0 [2]. Consequently, it follows that

w(z)=K(x,y)+iL(x,y),y>0.w\left(z\right)=K\left(x,y\right)+iL\left(x,y\right),\qquad y>0.

Further we will imply that the parameter y=Im[z]y=\operatorname{Im}\left[z\right] is always greater than zero.

The real part of the complex error function K(x,y)K\left(x,y\right) is known as the Voigt function [1, 2, 3, 4] that is widely used in Atmospheric Science to describe emission and absorption of the photons by atmospheric molecules [5, 6, 7, 8, 9, 10, 11, 12]. Specifically, the Voigt function is used to compute wavelength-dependent absorption coefficients by using the HITRAN molecular spectroscopic database [13]. The imaginary part of the complex error function L(x,y)L\left(x,y\right) is also used in many applications. For example, it can describe the spectral behavior of the index of refraction in various materials [14, 15].

Despite simple representations, the integrals (1), (2) and (3) do not have analytical solutions and must be computed numerically. Many approximations are available in the scientific literature [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]. Although this problem has been known for many decades, the derivation of new approximations for the complex error function w(z)w\left(z\right) and the development of their efficient algorithms still remain an interesting topic [30, 31, 32, 33, 34, 35, 36, 37].

In our previous publication we proposed an algorithm for the efficient computation of the complex error function based on a single-domain implementation with vectorized interpolation [33]. However, despite rapid performance it has some limitations, including a limited range for the parameter xx as well as restrictions for the input array type. As a further development, in this work we present a new MATLAB implementation without those drawbacks. The numerical analysis and computational tests we performed show that the proposed algorithmic implementation meets all the requirements in terms of accuracy and run-time performance for the efficient computation of the Voigt/complex error function in the radiative transfer applications.

2 Approximations

2.1 Sampling Based Approximation

In our work [29] we have proposed a new sampling method based on incomplete cosine expansion of the sinc function. In particular, it is shown that, using a new sampling method based on incomplete cosine expansion of the sinc function, we can obtain the following approximation

w(z)m=1Mam+bm(z+iς/2)cm2(z+iς/2)2,w\left(z\right)\approx\sum\limits_{m=1}^{M}{\frac{a_{m}+b_{m}\left(z+i\varsigma/2\right)}{c_{m}^{2}-\left(z+i\varsigma/2\right)^{2}}}, (4)

where the expansion coefficients are given by

am=π(m1/2)2M2hn=NNeς2/4n2h2sin(π(m1/2)(nh+ς/2)Mh),a_{m}=\frac{\sqrt{\pi}\left(m-1/2\right)}{2M^{2}h}\sum\limits_{n=-N}^{N}{e^{{\varsigma^{2}}/4-{n^{2}}{h^{2}}}\sin\left(\frac{\pi\left(m-1/2\right)\left(nh+\varsigma/2\right)}{Mh}\right)},
bm=iMπn=NNeς2/4n2h2cos(π(m1/2)(nh+ς/2)Mh),b_{m}=-\frac{i}{M\sqrt{\pi}}\sum\limits_{n=-N}^{N}{e^{\varsigma^{2}/4-n^{2}h^{2}}\cos\left(\frac{\pi\left(m-1/2\right)\left(nh+\varsigma/2\right)}{Mh}\right)},
cm=π(m1/2)2Mπ,c_{m}=\frac{\pi\left(m-1/2\right)}{2M\pi},

with parameters NN, MM, hh and ς\varsigma that can be taken as 2323, 2323, 0.250.25 and 2.752.75, respectively.

For more rapid performance in algorithmic implementation, it is reasonable to define the function

Ω(z)=m=1Mam+bmzcm2z2,\Omega\left(z\right)=\sum\limits_{m=1}^{M}{\frac{a_{m}+b_{m}z}{c_{m}^{2}-z^{2}}},

such that Equation (4) can be represented as [30]

w(z)Ω(z+iς/2).w\left(z\right)\approx\Omega\left(z+i\varsigma/2\right). (5)

Overall, approximation (5) is highly accurate. However, its accuracy deteriorates with decreasing parameter yy. In order to resolve this problem we can use the following approximation [30]

w(z)ez2+zm=1M+2αmβmz2γmθmz2+z4,w\left(z\right)\approx e^{-z^{2}}+z\sum\limits_{m=1}^{M+2}{\frac{\alpha_{m}-\beta_{m}z^{2}}{\gamma_{m}-\theta_{m}z^{2}+z^{4}}}, (6)

where the expansion coefficients are

αm=bm[cm2(ς22)2]+iαmς,\alpha_{m}=b_{m}\left[c_{m}^{2}-\left(\frac{\varsigma^{2}}{2}\right)^{2}\right]+i\alpha_{m}\varsigma,
βm=bm,\beta_{m}=b_{m},
γm=cm4+cm2ς22+ς416\gamma_{m}=c_{m}^{4}+\frac{c_{m}^{2}\varsigma^{2}}{2}+\frac{\varsigma^{4}}{16}

and

θm=2cm2ς22.\theta_{m}=2c_{m}^{2}-\frac{\varsigma^{2}}{2}.

It is interesting to note that this approximation of the complex error function is obtained by substituting approximation (4) into the right side of the identity (see [30] for details in derivation)

w(z)=ez2+w(z)w(z)2.w\left(z\right)=e^{-z^{2}}+\frac{w\left(z\right)-w\left(-z\right)}{2}.

For |z|>8\left|z\right|>8 one of the best choices is the approximation based on the Laplace continued fraction [1, 3]. In particular, in our algorithm we used

w(z)(i/π)z1/2z1z3/2z2z5/2z37/2z49/2z5z11/2z.w\left(z\right)\approx\frac{\left(i/\sqrt{\pi}\right)}{z-\frac{1/2}{z-\frac{1}{z-\frac{3/2}{z-\frac{2}{z-\frac{5/2}{z-\frac{3}{\frac{7/2}{z-\frac{4}{\frac{9/2}{z-\frac{5}{z-\frac{11/2}{z}}}}}}}}}}}}. (7)

This algorithm is implemented in MATLAB as a script file fadsamp.m that utilizes three approximations (5), (6) and (7) as follows [30]

w(z){Equation(5),if(|x+iy|8)(y>0.05x),Equation(6),if(|x+iy|8)(y0.05x),Equation(7),otherwise.w\left(z\right)\approx\left\{\begin{aligned} {\rm{Equation~{}\eqref{eq_5}}},&\quad{\rm if}\>(\left|x+iy\right|\leq 8)\,\cap\,(y>0.05x),\\ {\rm{Equation~{}\eqref{eq_6}}},&\quad{\rm if}\>(\left|x+iy\right|\leq 8)\,\cap\,(y\leq 0.05x),\\ {\rm{Equation~{}\eqref{eq_7}}},&\quad{\rm otherwise.}\end{aligned}\right. (8)

As we have shown in our publication [30], approximation (8) provides highly accurate and rapid computation of the complex error function without poles and can be used to cover the entire complex plane.

2.2 Modified Trapezoidal Rule

In 1945, English mathematician and cryptanalyst Alan Turing, who succeeded to decrypt sophisticated machine codes of the Enigma during the Second World War [38], published an interesting paper where he proposed an elegant method of numerical integration for some class of integrals [39]. Nowadays, his method of the numerical integration that involves the residue calculus is regarded as the modified trapezoidal rule [40] or the generalized trapezoidal rule [37]. The comprehensive and detailed description of Turing’s method of integration may be found in literature [40].

In 1949, Goodwin showed how to implement Turing’s idea to the integrals of kind [41]

f(x)ex2𝑑x.\int\limits_{-\infty}^{\infty}{f\left(x\right)e^{-x^{2}}dx}.

Using the method described by Goodwin, Chiarella and Reichel in their work [42] derived the series expansion for the following integral

Ψ(x,t)=U(x,t)+iV(x,t)=Ω(x,t)(4πt)1/2eu2u2+Ω2(x,t)𝑑u,\Psi\left(x,t\right)=U\left(x,t\right)+iV\left(x,t\right)=\frac{\Omega\left(x,t\right)}{\left(4\pi t\right)^{1/2}}\int\limits_{-\infty}^{\infty}{\frac{e^{-u^{2}}}{u^{2}+\Omega^{2}\left(x,t\right)}du},

where Ω(x,t)=(1ix)/(2t1/2)\Omega\left(x,t\right)=\left(1-ix\right)/\left(2t^{1/2}\right). In particular, they showed that that the function Ψ(x,t)\Psi\left({x,t}\right) can be approximated as a series

Ψ(x,t)hΩ(x,t)(4πt)1/2+2hΩ(x,t)(4πt)1/2n=1en2h2Ω2(x,t)+n2h2+πeΩ2(x,t)(πt)1/2(1e2πΩ(x,t)/h)H(th2π2),\begin{gathered}\Psi\left(x,t\right)\approx\frac{h}{\Omega\left(x,t\right)\left(4\pi t\right)^{1/2}}+\frac{2h\Omega\left(x,t\right)}{\left(4\pi t\right)^{1/2}}\sum\limits_{n=1}^{\infty}{\frac{e^{-n^{2}h^{2}}}{\Omega^{2}\left(x,t\right)+n^{2}h^{2}}}\\ +\frac{\pi e^{\Omega^{2}\left(x,t\right)}}{\left(\pi t\right)^{1/2}\left(1-e^{2\pi\Omega\left(x,t\right)/h}\right)}H\left(t-\frac{h^{2}}{\pi^{2}}\right),\\ \end{gathered} (9)

where hh is a small fitting parameter and H(t)H\left(t\right) is the Heaviside step function defined as

H(t)={0,ift<0,1/2,ift=0,1,ift>0.H\left(t\right)=\left\{\begin{aligned} 0,&\quad{\rm if}\>t<0,\\ 1/2,&\quad{\rm if}\>t=0,\\ 1,&\quad{\rm if}\>t>0.\end{aligned}\right.

Thus, due to Heaviside step function, Equation (9) can be separated into three parts

Ψ(x,t)hΩ(x,t)(4πt)1/2+2hΩ(x,t)(4πt)1/2n=1en2h2Ω2(x,t)+n2h2,t<h2π2,\Psi\left(x,t\right)\approx\frac{h}{\Omega\left(x,t\right)\left(4\pi t\right)^{1/2}}+\frac{2h\Omega\left(x,t\right)}{\left(4\pi t\right)^{1/2}}\sum\limits_{n=1}^{\infty}{\frac{e^{-n^{2}h^{2}}}{\Omega^{2}\left(x,t\right)+n^{2}h^{2}}},\quad t<\frac{h^{2}}{\pi^{2}}, (10)
Ψ(x,t)\displaystyle\Psi\left(x,t\right)\approx hΩ(x,t)(4πt)1/2+2hΩ(x,t)(4πt)1/2n=1en2h2Ω2(x,t)+n2h2\displaystyle\frac{h}{\Omega\left(x,t\right)\left(4\pi t\right)^{1/2}}+\frac{2h\Omega\left(x,t\right)}{\left(4\pi t\right)^{1/2}}\sum\limits_{n=1}^{\infty}{\frac{e^{-n^{2}h^{2}}}{\Omega^{2}\left(x,t\right)+n^{2}h^{2}}} (11)
+πeΩ2(x,t)2(πt)1/2(1e2πΩ(x,t)/h),t=h2π2,\displaystyle+\frac{\pi e^{\Omega^{2}\left(x,t\right)}}{2\left(\pi t\right)^{1/2}\left(1-e^{2\pi\Omega\left(x,t\right)/h}\right)},\qquad t=\frac{h^{2}}{\pi^{2}},
Ψ(x,t)\displaystyle\Psi\left(x,t\right)\approx hΩ(x,t)(4πt)1/2+2hΩ(x,t)(4πt)1/2n=1en2h2Ω2(x,t)+n2h2\displaystyle\frac{h}{\Omega\left(x,t\right)\left(4\pi t\right)^{1/2}}+\frac{2h\Omega\left(x,t\right)}{\left(4\pi t\right)^{1/2}}\sum\limits_{n=1}^{\infty}{\frac{e^{-n^{2}h^{2}}}{\Omega^{2}\left(x,t\right)+n^{2}h^{2}}} (12)
+πeΩ2(x,t)(πt)1/2(1e2πΩ(x,t)/h),t>h2π2.\displaystyle+\frac{\pi e^{\Omega^{2}\left(x,t\right)}}{\left(\pi t\right)^{1/2}\left(1-e^{2\pi\Omega\left(x,t\right)/h}\right)},\qquad t>\frac{h^{2}}{\pi^{2}}.

Equation (11) deals only with a single point h2/π2h^{2}/\pi^{2} for the parameter tt and does not represent any practical interest. Therefore, further we will consider only two equations, Equations (10) and (12).

Mata and Reichel [43] showed the relations

K(x,y)=1yπU(xy,14y2)K\left(x,y\right)=\frac{1}{y\sqrt{\pi}}U\left(\frac{x}{y},\frac{1}{4y^{2}}\right)

and

L(x,y)=1yπV(xy,14y2)L\left(x,y\right)=\frac{1}{y\sqrt{\pi}}V\left(\frac{x}{y},\frac{1}{4y^{2}}\right)

that link both functions Ψ(x,t)\Psi\left(x,t\right) and w(x,y)w\left(x,y\right) with each other. Consequently, using these relations the series expansions (10) and (12) can be reformulated as

w(z)2ihzπk=0Netk2z2tk2w\left(z\right)\approx\frac{2ihz}{\pi}\sum\limits_{k=0}^{N}{\frac{e^{-t_{k}^{2}}}{z^{2}-t_{k}^{2}}} (13)

and

w(z)2ez21+e2iπz/h+2ihzπk=0Netk2z2tk2,w\left(z\right)\approx\frac{2e^{-z^{2}}}{1+e^{-2i\pi z/h}}+\frac{2ihz}{\pi}\sum\limits_{k=0}^{N}{\frac{e^{-t_{k}^{2}}}{z^{2}-t_{k}^{2}}}, (14)

respectively, where tk=(k+1/2)ht_{k}=\left(k+1/2\right)h and hh can be chosen to be equal to π/(N+1)\sqrt{\pi/\left(N+1\right)} [37].

Consider an expansion series for the complementary error function that was reported by Hunter and Regan [44] (see also [37])

erfc(z)2hzez2πk=1Ne(k1/2)2h2z2+(k1/2)2h2+21+e2πz/h,x<πh.{\rm erfc}\left(z\right)\approx\frac{2hze^{-z^{2}}}{\pi}\sum\limits_{k=1}^{N}{\frac{e^{-\left(k-1/2\right)^{2}h^{2}}}{z^{2}+\left(k-1/2\right)^{2}h^{2}}}+\frac{2}{1+e^{2\pi z/h}},\qquad x<\frac{\pi}{h}.

Using the identity relating complex error function and complementary error function [3]

w(z)=ez2erfc(iz),w\left(z\right)=e^{-z^{2}}{\rm erfc}\left(-iz\right),

we obtain

w(z)2ez21+e2iπz/h+ihπz+2ihzπk=1Neτk2z2τk2,w\left(z\right)\approx\frac{2e^{-z^{2}}}{1+e^{-2i\pi z/h}}+\frac{ih}{\pi z}+\frac{2ihz}{\pi}\sum\limits_{k=1}^{N}{\frac{e^{-\tau_{k}^{2}}}{z^{2}-\tau_{k}^{2}}}, (15)

where τk=kh\tau_{k}=kh [37].

Equations (13) and (14) have poles at z=tkz=t_{k} while Equation (15) has poles at z=τkz=\tau_{k}. Furthermore, each of these equations can cover with high accuracy only in the corresponding domain. However, Al Azah and Chandler-Wilde [37] recently proposed the following approximation

w(z){Equation(13),ifymax(π,x),Equation(15),ify<x1/4φ(x/h)3/4,Equation(14),otherwise,w\left(z\right)\approx\left\{\begin{aligned} {\rm Equation~{}(13)},&\qquad{\rm if}\>y\geq\max\left(\pi,x\right),\\ {\rm Equation~{}(15)},&\qquad{\rm if}\>y<x\cap 1/4\leq\varphi\left(x/h\right)\leq 3/4,\\ {\rm Equation~{}(14)},&\qquad{\rm otherwise,}\end{aligned}\right. (16)

where φ(t)=tt[0,1)\varphi\left(t\right)=t-\left\lfloor t\right\rfloor\in\left[0,1\right), that appeared to be very efficient since it can be used for rapid and highly accurate computation without poles at N=11N=11. This is possible to achieve since, according to approximation (16), Equations (13), (14) and (15) are used interchangeably depending on the domain over the entire complex plain.

3 Algorithmic Implementation

Previously we have reported a new algorithm based on a vectorized interpolation over a single-domain [33]. Such an approach provides accuracy better than 10610^{-6} at y108y\geq 10^{-8} for the HITRAN [13] applications. However, this implementation has several limitations. In particular, there is a limitation |x|105\left|x\right|\leq 10^{5}. Although it is possible to increase the range for more than 10510^{5}, it requires to introduce more interpolation grid-points for precomputation. Furthermore, this MATLAB implementation accepts an input only as a vector (one dimensional array) or as a scalar.

One of the ways to implement an efficient algorithm is to use an approximation based on the two-domain scheme that we proposed in our earlier publication [23]

K(x,y){interpolation,x2272+y21521a1+b1x2a2+b2x2+x4,x2272+y2152>1,K\left({x,y}\right)\approx\left\{\begin{aligned} &{\rm interpolation,}&&\qquad\frac{x^{2}}{27^{2}}+\frac{y^{2}}{15^{2}}\leq~{}1\\ &\frac{a_{1}+b_{1}x^{2}}{a_{2}+b_{2}x^{2}+x^{4}},&&\qquad\frac{x^{2}}{27^{2}}+\frac{y^{2}}{15^{2}}>1,\end{aligned}\right.

where the coefficients are [20]

a1=y/(2π)+y3/π0.2820948y+0.5641896y3\displaystyle a_{1}=y/\left(2\sqrt{\pi}\right)+y^{3}/\sqrt{\pi}\approx 0.2820948y+0.5641896y^{3}
b1=y/π0.5641896y\displaystyle b_{1}=y/\sqrt{\pi}\approx~{}0.5641896y
a2=0.25+y2+y4\displaystyle a_{2}=0.25+y^{2}+y^{4}
b2=1+2y2\displaystyle b_{2}=-1+2y^{2}

such that

a1+b1x2a2+b2x2+x4=Re{(i/π)z1/2z}.\frac{a_{1}+b_{1}x^{2}}{a_{2}+b_{2}x^{2}+x^{4}}=\operatorname{Re}\left\{\frac{\left(i/\sqrt{\pi}\right)}{z-\frac{1/2}{z}}\right\}.

Consequently, the complex error function can also be approximated as [33]

w(z)=K(x,y)+iL(x,y){interpolation,x2272+y21521(i/π)z1/2z,x2272+y2152>1.w\left(z\right)=K\left(x,y\right)+iL\left(x,y\right)\approx\left\{\begin{aligned} &{\rm interpolation,}&&\qquad\frac{x^{2}}{27^{2}}+\frac{y^{2}}{15^{2}}\leqslant~{}1\\ &\frac{\left(i/\sqrt{\pi}\right)}{z-\frac{1/2}{z}},&&\qquad\frac{x^{2}}{27^{2}}+\frac{y^{2}}{15^{2}}>1.\end{aligned}\right.

Although the algorithms for the Voigt and complex error functions, built on Equations (3) and (3) can provide rapid computations, their accuracies deteriorate at y<106y<10^{-6}.

In order to resolve this problem we developed a new algorithm that utilizes the internal MATLAB built-up features. Unlike interpolation algorithms shown in [23, 33], the proposed approach implies that the number of the interpolation grid-points required for precomputation is not constant and dependent on the input parameter yy such that

Ngp=1y+δ,N_{gp}=\frac{1}{\sqrt{y}}+\delta, (18)

where δ\delta is the offset that was found experimentally to be 5×1035\times 10^{3}. The corresponding interpolation grid-points range is bounded by [r,r]\left[-r,r\right], where r=35r=35 is the radius that was also found experimentally. The interpolation grid-points are distributed non-equidistantly in logarithmic scale to increase their density near the origin along the xx axis.

Equation (18) is entirely empirical. It is reasonable to suggest that the number of the interpolation grid-points should be increased with decreasing yy. However, taking the reciprocal of yny^{n}, such that n1n\geq 1, results in a very rapid increase of the interpolation grid-points NgpN_{gp} with decreasing yy. Our experimental results show that a more or less optimal value NgpN_{gp} can be found by taking the reciprocal of y\sqrt{y}. The parameter δ\delta in Equation (18) is to provide a sufficient number of the interpolation grid-points NgpN_{gp} within the internal domain |x+iy|r|x+iy|\leq r as parameter yy increases.

The use of Equation (18) is given as a basic for applications. If higher accuracy is required, the number of the interpolation grid-points NgpN_{gp} can be further increased by using, for example, a modified form of the equation above

Ngp=2y+3δ.N_{gp}=\frac{2}{\sqrt{y}}+3\delta.

Such a modification improves accuracy by an order of the magnitude.

The algorithm utilizes two domains, internal and external, that are bounded by a circle of radius |x+iy|=r\left|x+iy\right|=r. The internal domain is situated within the circle while the external domain is situated outside of it.

All points within internal domain |x+iy|r\left|x+iy\right|\leq r are computed by the MATLAB built-in interpolation function interp1 though interpolation grid-points that are computed by using the function file fadsamp.m provided in our article [30]. The spline method was found to be the best for interpolation.

All points outside external domain |x+iy|>r\left|x+iy\right|>r are computed by the following approximation

w(z)(i/π)z1/2z1z3/2zw\left(z\right)\approx\frac{\left(i/\sqrt{\pi}\right)}{z-\frac{1/2}{z-\frac{1}{z-\frac{3/2}{z}}}}

that represents a simplified version of Equation (7) above.

The parameter yy is dependent on temperature and pressure. Therefore, it is related to the atmospheric height. In a radiative transfer model, the atmospheric column is sliced into layers [5, 6]. The layers can be considered homogeneous if their thicknesses are small enough. Typically, a thickness of 50m50\>m (or 2020 layers per kmkm) is sufficient to consider the layer homogeneous for atmospheric modeling. This implies that, within a given layer, the temperature and pressure are constants. Since the density of air in the mesosphere is extremely low, its contribution to the radiance is practically negligible. Consequently, taking into consideration that only the troposphere and stratosphere, with an atmospheric column corresponding to a height of up to 40–50 km, actually contribute to the radiance, we can conclude that the total number of layers as well as elements for parameter yy does not exceed 10001000 per gas in atmosphere. However, in many practical tasks, for a single value yy at a given atmospheric temperature and pressure, we may need to cover a wide spectral range with high resolution. This signifies that the number of elements for parameter xx can exceed a million. Since the number of elements for parameter yy is much smaller than the number of elements for parameter xx, it is reasonable to implement a configuration in which parameter xx is an array and parameter yy is a scalar. This approach is more rapid in the MATLAB implementation since the application of a 2D array M×NM\times N, where NN and MM are numbers of elements for parameters xx and yy, respectively, requires considerably more computer memory.

As it has been mentioned above, the computation of the interpolation grid-points in its original version of the function file w2dom.m is performed by external function fadsamp.m. However, any other MATLAB function file that can provide highly accurate computation of the complex error function may also be used for computation of interpolation grid-points. For example, the function files such as fadf.m [27] and fadfunc.m [31] can also be used as alternatives. The script of the function file w2dom.m is given in Appendix A.

4 Error Analysis

In order to exclude the rounding and truncation errors in computation by using the most recent HITRAN database [13], the values of the K(x,y)K\left(x,y\right) and L(x,y)L\left(x,y\right) functions with 66 or more accurate decimal digits in their mantissas are required. Therefore, in radiative transfer applications involving the HITRAN database, the accuracy of computation of these functions has to be better than 10610^{-6}.

[Uncaptioned image]

Fig. 1. Absolute difference for the real part K(x,y)K\left(x,y\right) of the complex error function.

Figure 1 shows the absolute difference |Kref.(x,y)K(x,y)|\left|K_{ref.}\left(x,y\right)-K\left(x,y\right)\right|, where Kref.(x,y)K_{ref.}\left(x,y\right) is a highly accurate reference, in the range 5x5-5\leq x\leq 5 at y=108y=10^{-8}. As we can see, the absolute difference does not exceed 2.5×10132.5\times 10^{-13}.

Figure 2 shows the absolute difference |Lref.(x,y)L(x,y)|\left|L_{ref.}\left(x,y\right)-L\left(x,y\right)\right|, where Lref.(x,y)L_{ref.}\left(x,y\right) is a highly accurate reference, in the range 5x5-5\leq x\leq 5 also at y=108y=10^{-8}. We can see that for the imaginary part the absolute difference also does not exceed 2.5×10132.5\times 10^{-13}.

[Uncaptioned image]

Fig. 2. Absolute difference for the imaginary part L(x,y)L\left(x,y\right) of the complex error function.

For more rigorous error analysis, we can apply the following relative errors

ΔRe=|Kref.(x,y)K(x,y)|Kref.(x,y)\Delta_{\operatorname{Re}}=\frac{\left|K_{ref.}\left(x,y\right)-K\left(x,y\right)\right|}{K_{ref.}\left(x,y\right)}

and

ΔIm=|Lref.(x,y)L(x,y)|Lref.(x,y)\Delta_{\operatorname{Im}}=\frac{\left|L_{ref.}\left(x,y\right)-L\left(x,y\right)\right|}{L_{ref.}\left(x,y\right)}

for the real and imaginary parts of the complex error function w(z)w\left(z\right), respectively.

Figure 3 depicts the relative error for the real part of the complex error function Re[z]=K(x,y)\operatorname{Re}\left[z\right]=K\left(x,y\right) in the domain 0x500\leq x\leq 50 and 0y101.6990\leq y\leq 10^{1.699}, where 101.6995010^{1.699}\approx 50. Inset in Figure 3 shows the smaller domain near the origin 0x5.50\leq x\leq 5.5 and 0y100.740\leq y\leq 10^{0.74}, where 100.745.510^{0.74}\approx 5.5. Beyond this smaller domain the observed color is blue indicating that the relative error is below 101210^{-12}. As we can see from Figure 3, the relative error does not exceed \sim101010^{-10}.

[Uncaptioned image]

Fig. 3. Relative error for the real part K(x,y)K\left(x,y\right) of the complex error function.

[Uncaptioned image]

Fig. 4. Relative error for the imaginary part L(x,y)L\left(x,y\right) of the complex error function.

Figure 4 illustrates the relative error for the imaginary part of the complex error function Im[z]=L(x,y)\operatorname{Im}\left[z\right]=L\left(x,y\right) in the domain 0x500\leq x\leq 50 and 0y101.6990\leq y\leq 10^{1.699}. Inset in Figure 4 shows the smaller domain near origin 0x5.50\leq x\leq 5.5 and 0y100.740\leq y\leq 10^{0.74}. Beyond this smaller domain the color is blue and the relative error is below 101210^{-12}. As we can see from Figure 4, the relative error is generally lower in the imaginary part and does not exceed 1011\sim 10^{-11}.

It is commonly known that the accuracy of K(x,y)K\left(x,y\right) and L(x,y)L\left(x,y\right) functions tend to deteriorate when yy decreases [2, 16, 21, 22, 28]. However, from Figures 3 and 4 we can see that the decrease of the parameter yy does not deteriorate the accuracy. This is possible to achieve since in accordance with Equation (18) the number of the interpolation grid-points NgpN_{gp} increases with decreasing yy. Therefore, this technique enables us to resolve efficiently this problem in computation of the complex error function w(z)w\left(z\right).

5 Run-Time Test

The run-time test was performed with MATLAB function files wTrap.m [37], fadsamp.m [31] and w2dom.m at equidistantly distributed 1010 million points for parameter xx at y=108y=10^{-8}. The results of the run-time test are shown in Table 1.

Algorithm Run-time in seconds
x[10,10]x\in\left[-10,10\right] x[102,102]x\in\left[-10^{2},10^{2}\right] x[103,103]x\in\left[-10^{3},10^{3}\right]
wTrap.m 2.41 2.55 2.45
fadsamp.m 4.14 1.78 1.54
w2dom.m 1.23 1.04 0.98
Table 1: Run-time of algorithms for 1010 million points at three different ranges.

It has been reported that both algorithms wTrap.m and fadsamp.m are highly accurate in computation [37]. In particular, the maximum values in relative errors for the algorithms wTrap.m and fadsamp.m are found to be \sim101510^{-15} and \sim101410^{-14}, respectively. However, the computational speed of these two algorithms differs depending on the range for the input parameter xx. In particular, Table 1 shows that at smaller range for parameter xx the function file wTrap.m performs computation faster than the function file fadsamp.m. However, as the range for parameter xx increases, our algorithm fadsamp.m becomes faster. The run-time test also reveals that the algorithm w2dom.m is always faster regardless of the chosen range. This is particularly evident when the range for the input parameter xx is smaller.

Table 2 shows the results of the run-time test at 3030 million equidistantly distributed points for parameter xx at y=108y=10^{-8}. As we can see, the algorithm w2dom.m remains more rapid proportionally at extended size of the input array as compared to the wTrap.m and fadsamp.m algorithms.

Algorithm Run-time in seconds
x[10,10]x\in\left[-10,10\right] x[102,102]x\in\left[-10^{2},10^{2}\right] x[103,103]x\in\left[-10^{3},10^{3}\right]
wTrap 8.38 8.33 8.42
fadsamp 14.37 6.02 5.21
w2dom 3.78 3.07 2.86
Table 2: Run-time of algorithms for 3030 million points at three different ranges.

The MATLAB code for the run-time test is provided in Appendix B. The scripts of function files wTrap.m and fadsamp.m can be accessed from the cited literature [37, 30], respectively.

6 Conclusions

A new algorithm for the efficient computation of the Voigt/complex error function is shown. We propose a two-domain scheme where the number of interpolation grid-points NgpN_{gp} is dependent on parameter yy. The error analysis shows that our MATLAB implementation meets the requirements for radiative transfer applications utilizing the HITRAN molecular spectroscopic database. The run-time test we performed shows that this MATLAB implementation can provide rapid computation especially at smaller ranges of parameter xx.

Acknowledgments

This work is supported by the National Research Council Canada, Thoth Technology Inc., York University, Epic College of Technology and Epic Climate Green (ECG) Inc.

Appendix A


function FF = w2dom(x,y,opt)

% SYNOPSIS:
%          x   - array or scalar
%          y   - scalar
%          opt - option for the real and imaginary parts
%
% opt = 1 returns value(s) for the Voigt function, K(x,y)-function
% opt = 2 returns value(s) for the L(x,y)-function
% opt = 3 returns value(s) for the complex error function
%
% This code is primarily intended to work in the range y >= 1e-8 for the
% HITRAN applications for accelerated computation of the Voigt/complex
% error function.
%
% -------------------------------------------------------------------------
% Example:
%          x = linspace(-10,10,1e7); y = 1e-8; tic; w2dom(x,y); toc
% -------------------------------------------------------------------------
if ~isscalar(y)
    disp(’Input parameter y must be a scalar’)
    return % terminate computation if y is not a scalar
end

if nargin == 2
    opt = 3;
    disp(’Default value opt = 3 is assigned.’)
end

if opt ~= 1 && opt ~= 2 && opt ~= 3
    disp([’Wrong parameter opt = ’,num2str(opt),’! Use 1, 2 or 3.’])
    return
end

if y < 1e-8
    if opt == 1
        FF = real(fadsamp(x+1i*y));
    elseif opt == 2
        FF = imag(fadsamp(x+1i*y));
    else
        FF = fadsamp(x+1i*y);
    end
    return
end

FF = zeros(size(x));
radius = 35; % define radius
ind = abs(x + 1i*y) <= radius;

gp =[-radius,radius]; % define grid-points
if ~isempty(x(ind))

    offset = 5*1e3; % assign offset
    nump = 1/sqrt(y) + offset; % assign number of points
    % For better accuracy use for example nump = 2/sqrt(y) + 3*offset;

    gp = radius*(logspace(log10(1 + eps),log10(2),nump) ...
    - 1); % notice the log scale

    gp = [flip(-gp),gp];
end

switch opt
    case 1
        FF(ind) = real(internD(x(ind),y,gp));
        FF(~ind) = real(externD(x(~ind) + 1i*y));
    case 2
        FF(ind) = imag(internD(x(ind),y,gp));
        FF(~ind) = imag(externD(x(~ind) + 1i*y));
    otherwise
        FF(ind) = internD(x(ind),y,gp);
        FF(~ind) = externD(x(~ind) + 1i*y);
end

    function IntD = internD(x,y,gp) % internal domain
        IntD = interp1(gp,fadsamp(gp + 1i*y),x, ...
            ’spline’); % interpolated values
    end

    function ExtD = externD(z) % external domain

        num = 1:4; % define a row vector
        num = num/2;

        ExtD = num(end)./z; % start computing from the end
        for m = 1:length(num) - 1
            ExtD = num(end - m)./(z - ExtD);
        end
        ExtD = 1i/sqrt(pi)./(z - ExtD);
    end
end

Appendix B


clear
clc

% Table for run-time in seconds
tab{1,1}=’Algorithm’;
tab{1,2}=’-10 to 10’; % range 1
tab{1,3}=’-10^2 to 10^2’; % range 2
tab{1,4}=’-10^3 to 10^3’; % range~3

tab{2,1}=’wTrap’;
tab{3,1}=’fadsamp’;
tab{4,1}=’w2dom’;

y=1e-8; % smallest value for the parameter y
maxN=10; % max number of~cycles

for k=[1,3] % k is a factor
    for m=1:3 % three ranges
        x0=10^m; x=linspace(-x0,x0,k*1e7); % 1 and 3 are for 1e7 and 3*1e7 ...
                                           % points, respectively

        if k==1
            disp([’10 million points in range ’,num2str(m)])
        else
            disp([’30 million points in range ’,num2str(m)])
        end
        disp(’Computing, please wait!’)

        tic; for n=1:maxN; wTrap(x+1i*y,11); end; tab{2,m+1}=toc/maxN;
        tic; for n=1:maxN; fadsamp(x+1i*y); end; tab{3,m+1}=toc/maxN;
        tic; for n=1:maxN; w2dom(x,y); end; tab{4,m+1}=toc/maxN;

        clc
    end
    if k==1; tab1=tab; else tab2=tab; end % assign tab1 or tab2
end

disp(’Displaing Table 1:’)
disp(tab1)

disp(’Displaing Table 2:’)
disp(tab2)

References

  • [1] Faddeyeva, V.N.; Terent’ev, N.M. Tables of the Probability Integral w(z)=ez2(1+2iπ0zet2𝑑t)w\left(z\right)=e^{-z^{2}}\left(1+\frac{2i}{\sqrt{\pi}}\int_{0}^{z}e^{t^{2}}dt\right) for Complex Argument; Pergamon Press: Oxford, UK, 1961.
  • [2] Armstrong, B.H. Spectrum line profiles: The Voigt function. J. Quant. Spectrosc. Radiat. Transf. 1967, 7, 61–88. [CrossRef]
  • [3] Gautschi, W. Efficient computation of the complex error function. SIAM J. Numer. Anal. 1970, 7, 187–198. [CrossRef]
  • [4] Abramowitz, M.; Stegun, I.A. Error Function and Fresnel Integrals. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, 9th ed.; Cambridge University Press: New York, NY, USA, 1972; pp. 297–309.
  • [5] Edwards, D.P. Atmospheric transmittance and radiance calculations using line-by-line computer models. Proc. SPIE Model. Atmos. 1988, 928, 94–116. [CrossRef]
  • [6] Quine, B.M.; Drummond, J.R. GENSPECT: A line-by-line code with selectable interpolation error tolerance. J. Quantit. Spectrosc. Radiat. Transf. 2002, 74, 147–165. [CrossRef]
  • [7] Jagpal, R.K.; Quine, B.M.; Chesser, H.; Abrarov, S.; Lee, R. Calibration and in-orbit performance of the Argus 1000 spectrometer—The Canadian pollution monitor. J. Appl. Remote Sens. 2010, 4, 049501. [CrossRef]
  • [8] Berk, A.; Hawes, F. Validation of MODTRAN®6 and its line-by-line algorithm. J. Quant. Spectrosc. Radiat. Transf. 2017, 203, 542–556. [CrossRef]
  • [9] Pliutau, D.; Roslyakov, K. Bytran -|\left|\right.- spectral calculations for portable devices using the HITRAN database. Earth Sci. Inform. 2017, 10, 395–404. [CrossRef]
  • [10] Siddiqui, R.; Jagpal, R.; Quine, B.M. Short wave upwelling radiative flux (SWupRF) within near infrared (NIR) wavelength bands of O2\rm{O_{2}}, H2O\rm{H_{2}O}, CO2\rm{CO_{2}}, and CH4\rm{CH_{4}} by Argus 1000 along with GENSPECT line by line radiative transfer model. Canad. J. Remote Sens. 2017, 43, 330–344. [CrossRef]
  • [11] Siddiqui, R.; Jagpal, R.K.; Abrarov, S.M.; Quine, B.M. Efficient application of the Radiance Enhancement method for detection of the forest fires due to combustion-originated reflectance. J. Environ. Protect. 2021, 12, 717–733. [CrossRef]
  • [12] Jagpal, R.K.; Siddiqui, R.; Abrarov, S.M.; Quine, B.M. Effect of the instrument slit function on upwelling radiance from a wavelength dependent surface reflectance. Nature Sci. 2022, 14, 133–147. [CrossRef]
  • [13] Hill, C.; Gordon, I.E.; Kochanov, R.V.; Barrett, L.; Wilzewski, J.S.; Rothman, L.S. HITRANonline: An online interface and the flexible representation of spectroscopic data in the HITRAN database. J. Quant. Spectrosc. Radiat. Transf. 2016, 177, 4–14. [CrossRef]
  • [14] Balazs, N.L.; Tobias, I. Semiclassical dispersion theory of lasers. Phil. Trans. R. Soc. Lond. A 1969, 264, 1–29. [CrossRef]
  • [15] Chan, L.K.P. Equation of atomic resonance for solid-state optics. Appl. Opt. 1986, 25, 1728–1730. [CrossRef] [PubMed]
  • [16] Humlíček, J. Optimized computation of the Voigt and complex probability functions. J. Quant. Spectrosc. Radiat. Transf. 1982, 27, 437–444. [CrossRef]
  • [17] Drummond, J.R.; Steckner, M. Voigt-function evaluation using a two-dimensional interpolation scheme. J. Quant. Spectrosc. Radiat. Transf. 1985, 34, 517–521. [CrossRef]
  • [18] Poppe, G.P.M.; Wijers, C.M.J. More efficient computation of the complex error function. ACM Transact. Math. Software 1990, 16, 38–46. [CrossRef]
  • [19] Schreier, F. The Voigt and complex error function: A comparison of computational methods. J. Quant. Spectrosc. Radiat. Transf. 1992, 48, 743–762. [CrossRef]
  • [20] Kuntz, M. A new implementation of the Humlicek algorithm for calculation of the Voigt profile function. J. Quant. Spectrosc. Radiat. Transf. 1997, 51, 819–824. [CrossRef]
  • [21] Wells, R.J. Rapid approximation to the Voigt/Faddeeva function and its derivatives. J. Quant. Spectrosc. Radiat. Transf. 1999, 62, 29–48. [CrossRef]
  • [22] Letchworth, K.L.; Benner, D.C. Rapid and accurate calculation of the Voigt function. J. Quant. Spectrosc. Radiat. Transf. 2007, 107, 173–192. [CrossRef]
  • [23] Abrarov, S.M.; Quine, B.M.; Jagpal, R.K. A simple interpolating algorithm for the rapid and accurate calculation of the Voigt function. J. Quant. Spectrosc. Radiat. Transf. 2009, 110, 376–383. [CrossRef]
  • [24] Pagnini, G.; Mainardi, F. Evolution equations for the probabilistic generalization of the Voigt profile function. J. Comput. Appl. Math. 2010, 233, 1590–1595. [CrossRef]
  • [25] Imai, K.; Suzuki, M.; Takahashi, C. Evaluation of Voigt algorithms for the ISS/JEM/SMILES L2 data processing system. Adv. Space Res. 2010, 45, 669–675. [CrossRef]
  • [26] Zaghloul, M.R.; Ali, A.N. Algorithm 916: Computing the Faddeyeva and Voigt Functions. ACM Trans. Math. Software 2011, 38, 15. [CrossRef]
  • [27] Abrarov, S.M.; Quine, B.M. Efficient algorithmic implementation of the Voigt/complex error function based on exponential series approximation. Appl. Math. Comput. 2011, 218, 1894–1902. [CrossRef]
  • [28] Amamou, H.; Ferhat, B.; Bois, A. Calculation of the Voigt Function in the region of very small values of the parameter aa where the calculation is notoriously difficult. Am. J. Anal. Chem. 2013, 4, 725–731. [CrossRef]
  • [29] Abrarov, S.M.; Quine, B.M. Sampling by incomplete cosine expansion of the sinc function: Application to the Voigt/complex error function. Appl. Math. Comput. 2015, 258, 425–435. [CrossRef]
  • [30] Abrarov, S.M.; Quine, B.M.; Jagpal, R.K. A sampling-based approximation of the complex error function and its implementation without poles. Appl. Num. Math. 2018, 129, 181–191. [CrossRef]
  • [31] Abrarov, S.M.; Quine, B.M. A rational approximation of the Dawson’s integral for efficient computation of the complex error function. Appl. Math. Comput. 2018, 321, 526–543. [CrossRef]
  • [32] Wang, S.; Huang, S. Evaluation of the numerical algorithms of the plasma dispersion function. J. Quant. Spectrosc. Radiat. Transf. 2019, 234, 64–70. [CrossRef]
  • [33] Abrarov, S.M.; Quine, B.M.; Siddiqui, R.; Jagpal, R.K. A single-domain implementation of the Voigt/complex error function by vectorized interpolation. Earth Sci. Res. 2019, 8, 52–63. [CrossRef]
  • [34] Kumar, R. The generalized modified Bessel function and its connection with Voigt line profile and Humbert functions. Adv. Appl. Math. 2020, 114, 101986. [CrossRef]
  • [35] Nordebo, S. Uniform error bounds for fast calculation of approximate Voigt profiles. J. Quant. Spectrosc, Radiat. Transf. 2021, 270, 107715. [CrossRef]
  • [36] Pliutau, D. Combined “Abrarov/Quine-Schreier-Kuntz (AQSK)” algorithm for the calculation of the Voigt function. J. Quant. Spectrosc. Radiat. Transf. 2021, 272, 107797. [CrossRef]
  • [37] Al Azah, M.; Chadler-Wilde, S.N. Computation of the complex error function using modified trapezoidal rules. SIAM J. Numer. Anal. 2021, 59, 2346–2367. [CrossRef]
  • [38] Copeland, B.J. The Essential Turing: Seminal Writings in Computing, Logic, Philosophy, Artificial Intelligence, and Artificial Life: Plus the Secrets of Enigma; Oxford University Press Inc.: New York, NY, USA, 2004.
  • [39] Turing, A.M. A method for the calculation of the zeta-function. Proc. Lond. Math. Soc. 1945, s2-48, 180–197. [CrossRef]
  • [40] Trefethen, L.N.; Weideman, J. The exponentially convergent trapezoidal rule. SIAM Rev. 2014, 56, 385–458. [CrossRef]
  • [41] Goodwin, E. The evaluation of integrals of the form f(x)ex2𝑑x\int_{-\infty}^{\infty}{f\left(x\right)e^{-x^{2}}dx}. Math. Proc. Cambridge Phil. Soc. 1949, 45, 241–245. [CrossRef]
  • [42] Chiarella, C.; Reichel, A. On the evaluation of integrals related to the error function. Math. Comput. 1968, 22, 137–143. [CrossRef]
  • [43] Matta, F.; Reichel, A. Uniform computation of the error function and other related functions. Math. Comp. 1971, 25, 339–344. [CrossRef]
  • [44] Hunter, D.; Regan, T. A note on the evaluation of the complementary error function. Math. Comp. 1972, 26, 539–541. [CrossRef]