149 7 5MB
English Pages 300 [287] Year 2021
Wolfgang Schweizer
Special Functions in Physics with MATLAB
Special Functions in Physics with MATLAB
Wolfgang Schweizer
Special Functions in Physics with MATLAB
Wolfgang Schweizer Tübingen, Germany
ISBN 978-3-030-64231-0 ISBN 978-3-030-64232-7 (eBook) https://doi.org/10.1007/978-3-030-64232-7 © The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. This Springer imprint is published by the registered company Springer Nature Switzerland AG. The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
Special functions arise in many applications of physics, mathematics, chemistry, and engineering. When writing such a book, one is faced with numerous decisions, such as: Which special functions and topics should be included? and What should be assumed about the readers’ prior knowledge? This book is not elementary. The reader should have a background in mathematics, physics, and programming with MATLAB.1 This book deals with computational methods for evaluating special functions in the real and complex domains. MATLAB was used as programming language. MATLAB is established at many universities, research institutes, and in industry. The book comes with an additional toolbox called SPECFUNPHYS toolbox, extending MATLAB’s capabilities with respect to special functions. The book covers more than 170 special functions mostly in the complex domain, which are either not covered by standard MATLAB or in standard MATLAB restricted to the real domain. The presentation of the special functions is organized in 23 chapters, each related to a family of special functions together with examples or applications. Each chapter starts with a brief introduction and an overview of the related SPECFUNPHYS toolbox functions. Numerical and, respectively, computational aspects are added, and the corresponding SPECFUNPHYS functions are explained in detail, and some examples or applications are added.
Content Overview Chapter 1 covers gamma functions and beta functions and related functions in the complex domain. Error functions and Fresnel integrals are the topic of Chap. 2, as well as spectral line profiles such as the Voigt profile and the line broadening function. Legendre functions and related functions play an important role in quantum mechanics, electrodynamics, and so forth and will be discussed in Chap. 3. Bessel studied the astronomical three-body problem—still a challenge— and established the Bessel functions in the context of planetary perturbations.
1 M ATLAB
is a registered trademark of MathWorks, Inc. v
vi
Preface
Chapter 4 covers Bessel functions, Airy functions, and related functions. In Chap. 5, Struve functions and related functions are presented, which are solutions of nonhomogenous generalizations of Bessel’s differential equation. Hypergeometric functions play an important role in many areas of mathematical physics and numerical approximations. Chapters 6–8 are treating confluent hypergeometric functions, Coulomb wave functions, and Gauss hypergeometric functions and related functions, for example, the Whittaker functions. θ functions have been, for example, applied to soliton theory and quantum field theory or in evaluating elliptic functions. Applications of Jacobi elliptic functions, or elliptic integrals, appear in a variety of engineering and science problems. Weierstraß functions can be found, for example, in astrophysical applications, in solving supra-conductivity problems, and so forth. This family of functions and related functions will be discussed in Chaps. 9–12. Solving the Helmholtz differential equation in parabolic cylinder coordinates will lead to parabolic cylinder functions, topic of Chap. 13. Physical questions related to the solution of the Helmholtz equation in elliptical cylindrical coordinates lead to the Mathieu functions. Mathieu functions and related functions are treated in Chap. 14. In the realm of orthogonal polynomials are numerous applications in computational physics. A general discussion of orthogonal polynomials can be found in Chap. 15, as well as Jacobi polynomials and Gegenbauer polynomials. Hermite polynomials, Laguerre polynomials, Chebyshev polynomials, and related functions are topics of Chaps. 16–18. The polynomials and, respectively, functions are as well extended to the complex domain and to non-integer indices. Bernoulli numbers and Euler numbers and the related polynomials are treated in Chap. 19. Applications can be found, for example, in statistical physics. Computational applications in quantum physics, chaotic systems, and string theory, to list only a few, are applying Riemann zeta functions, which is the topic of Chap. 20. Piecewise interpolation polynomials are discussed in Chap. 21. One of the many numerical applications of piecewise interpolation polynomials are finite element approximations of the Schrödinger equation. As an example, this application of piecewise interpolation polynomials will be discussed for the hydrogen atom. Angular momenta and their coupling play a crucial role in quantum dynamics. Clebsch-Gordan coefficients and Wigner symbols are presented in Chap. 22. The last chapter is devoted to various coordinate systems, with the focus on those coordinate systems for which the three dimensional Laplace–Beltrami operator becomes separable. Many special functions are related to one of these coordinate systems. In Chap. 23, we derive MATLAB code for the corresponding coordinate transformations. Despite all of my effort, the book is likely to contain some typos, hopefully no errors, and you—the reader—might miss some special functions. Any comment or suggestion will be appreciated, and I will maintain a list of errata on my home page: https://wolfgang-schweizer.de.
Preface
vii
Function List The following tables list in alphabetic order the special functions discussed in the book. In some cases, codes for the logarithm of a function or its first derivative are as well developed. These additional functions and the coordinates treated in Chap. 23 are not listed in the tables. The first table column shows the name, the second column uncovers the corresponding mathematical symbol, and the last column lists where this function lives in the book (Tables 1, 2, 3, and 4).
The SPECFUNPHYS Toolbox The book comes with an additional MATLAB-based toolbox, called SPECFUNPHYS toolbox. The source codes are readable and not write protected, thus can be modified by the reader. If this should be necessary, I recommend first to copy the SPECFUNPHYS function under an new name and to modify this copy, because other SPECFUNPHYS programs might depend on the function in quest. For example, the SPECFUNPHYS gamma function, Γ (x), covers as well the complex domain and will be called by many other SPECFUNPHYS functions. The toolbox should be part of the MATLAB search path, because the SPECFUNPHYS functions live in different folders. The SPECFUNPHYS toolbox comes in addition with a detailed html-based documentation. By double-clicking onto the file SpecFunPhys.mltbx, the SPECFUNPHYS toolbox will be installed. Path settings are automatically adjusted as needed. On the MATLAB-documentation, a Supplemental Software link appears at the bottom of the documentation home page. Clicking this link opens the documentation with a link to the Content Guide, an overview of the content, and a link to all supported special functions. Both links lead to the html description of the various toolbox functions and classes. The documentation is searchable due to an additional search database. Thus, entering a keyword in the search box (Search Help) will list all hits. The html-based function description can be automatically opened in the MATLAB documentation window via >> web function_name.html, for example, >> web gammaC.html. These html files are for convenience also added as complementary m-files with the additional name doc. Therefore, for example, >> edit gammaCdoc will open this m-files for direct access of the examples related to the SPECFUNPHYS class gammaC. The SPECFUNPHYS toolbox is based on MATLAB version R2018b and tested under Windows and Linux operating systems. No other MATLAB toolbox is necessary for using this toolbox. The SPECFUNPHYS toolbox can be downloaded from my web page https://wolfgang-schweizer.de and from the MathWorks web site https://mathworks.com under User Community—File exchange.
viii
Preface
Table 1 Special functions A–C Function name
Notation
Section
Airy function
Ai(z)
4.2
Airy function
Bi(z)
4.2
Anger function
Jν (z)
5.3
Bernoulli polynomials Bernoulli numbers
Bn (x) Bn
19.1 19.1
Beta function
B(z, w)
1.7
Beta function, incomplete
Bx (z, w)
1.7
Bessel function, first kind
Jν (z)
4.3
Bessel function, modified first kind Bessel function, modified second kind
Iν (z) Kν (z)
4.3 4.3
Bessel function, second kind
Yν (z)
4.3
Bessel function, spherical first kind
jn (z)
4.3.3
Bessel function, spherical second kind
yn (z)
4.3.3
Bessel function, spherical third kind
hn (z), n ∈ {1, 2}
(n)
4.3.3
Bessel function, spherical
(n) in (z), n
4.3.3
Bessel function, spherical
kn (z)
4.3.3
Bessel function, third kind
Hν(n) (z), n ∈ {1, 2}
4.3
Burlirsch’s elliptic integrals
el1(x, kc), el2(x, kc, a, b)
11.2
Burlirsch’s elliptic integrals
el3(x, kc, a, b), cel(kc, p, a, b)
11.2
Carlson’s elliptic function Carlson’s elliptic integral of first kind
RC(x, y) RF (x, y, z)
11.2 11.2
Carlson’s elliptic integral of second kind
RG(x, y, z), RD(x, y, z)
11.2
Carlson’s elliptic integral of third kind
RJ (x, y, z, p)
11.2
Charlier polynomial
Cn (x; a)
6.4
Chebyshev polynomial first kind, shifted Chebyshev polynomial second kind, shifted
Tn (x), Tn∗ (x) Un (x), Un∗ (x)
18.1 18.1
Chebyshev polynomial third kind, shifted
Vn (x), Vn∗ (x)
18.1
Chebyshev polynomial fourth kind, shifted
Wn (x), Wn∗ (x)
18.1
Clebsch-Gordan coefficient
C(·j ·; ·m·)
22.1.2
Coherent states Confluent hypergeometric function, first kind
|α 1 F1 (a, b, z)
16.3 6.1
Confluent hypergeometric function, second kind
U (a, b, z)
6.1
Confluent hypergeometric limit function
0 F1 (a, b, z) μ P 1 (z) − 2 +iτ
6.2
μ (z) − 12 +iτ
3.4
Conical function, first kind
∈ {1, 2}
3.4
Conical function, second kind
Q
Coulomb wave function, irregular
Hl± (γ , ρ)
7.2.1
Coulomb wave function, irregular
hl ( , ζ )
7.2.1
Coulomb wave function, irregular
G± l (γ , ρ)
7.2.1
Coulomb wave function, regular
Fl± (γ , ρ)
7.2.1
Coulomb wave function, regular
fl± ( , ζ )
7.2.1
Coulomb wave function, parabolic
ψk (r)
7.2.2
Cylinder function
Jν (z)
4.3
Preface
ix
Table 2 Special functions D–H Function name Dawson integral Dedekind’s η function Digamma function Discriminant Elliptic integral of first kind Elliptic integral of second kind Elliptic integral of third kind Elliptic integral, symmetric Elliptic modular function Error function Error function, complementary Euler polynomial Euler number Fresnel integral Fresnel integral, cosine Fresnel integral, sine Gamma function Gamma function, incomplete Gamma function, inverse incomplete Gauss hypergeometric function Gegenbauer polynomial Hankel function Harmonic oscillator states Hermite interpolation polynomial
Notation F (z) η(τ ) ψ(z) Δ(Ω1 , Ω3 ) K(k), F (φ, k) E(k), E(φ, k) Π (n, k), Π (φ, n, k) D(φ, k) λ(τ ) erf (z) erf c(z) En (x) En FF (z) C(z) S(z) Γ (z) Γ (z, a) 2 F1 (a, b; c; z) Cnλ (x) Hν(n) (z), n ∈ {1, 2} ψn (x) ¯ Φ(x), Φ(x)
Section 2.2 9.3 1.4 12.2 11.2 11.2 11.2 11.2 12.2 2.2 2.2 19.2 19.2 2.4 2.4 2.4 1.2 1.5 1.5 8 15.4 4.3 16.3 21.1
Hermite interpolation polynomial, extended
¯¯ ¯ Φ(x) Φ(x), Φ(x)
21.1
Hermite polynomials Heumann’s lambda function Hypergeometric function Hypergeometric function
Hn (x) Λ0 (β, k) 2 F0 (a, b, z) 2 F1 (a, b; c; z)
16.2 11.2 6.1 8
x
Preface
Table 3 Special functions J–M Function name Jacobi elliptic function Jacobi elliptic function Jacobi elliptic function Jacobi elliptic function Jacobi elliptic function Jacobi elliptic function
Notation sn(z, k), ns(z, k) cn(z, k), nc(z, k) dn(z, k), nd(z, k) sd(z, k), ds(z, k) cd(z, k), dc(z, k) sc(z, k), cs(z, k)
Jacobi polynomial
Pn
Jacobi elliptic function Jacobi symbol
am(z, k) a
Jacobi ϑ functions Jacobi zeta function Kelvin functions Kelvin functions Klein’s complete invariant Krawtchonk polynomials Lagrange interpolation polynomial Laguerre polynomial Lattice invariants Lattice roots Legendre function, second kind Legendre function, second kind Legendre function, second kind Legendre function, associate Legendre function, associate Legendre elliptic integral of first kind Legendre elliptic integral of second kind Legendre elliptic integral of third kind Legendre polynomial Mathieu function Mathieu function Mathieu function, second solution Modified Mathieu function Modified Mathieu function Modified Mathieu function, second solution
ϑn (z, τ ), n ∈ {1, 2, 3, 4} Z(β, k) beiν (z), berν (z) keiν (z), kerν (z) J (τ ) Kn (x; p, N) Φ(x) Lαn (x) g2(Ω1 , Ω3 ), g3(Ω1 , Ω3 ) ei (Ω1 , Ω3 ), i ∈ {1, 2, 3} Qn (x) Qm l (x) μ Qν (x) Plm (x) μ Pν (z) K(k), F (φ, k) E(k), E(φ, k) Π (n, k), Π (φ, n, k) Pn (x) ceν (q, z), seν (q, z) meν (q, z) f en (q, z), gen (q, z) Ceν (q, z), Seν (q, z) Meν (q, z) F en (q, z), Gen (q, z)
Mehler function, first kind
P
μ (z) − 12 +iτ
3.4
Mehler function, second kind
μ Q 1 (z) − 2 +iτ
3.4
Meixner polynomial Meixner–Pollaczek polynomial
Mn (x; β, c) Pnλ (x; Φ)
8.3 8.3
(α,β)
(x)
b
Section 10.2 10.2 10.2 10.2 10.2 10.2 15.5 10.2 9.4 9.2 11.2 4.3.4 4.3.4 12.2 8.3 21.1 17.1 12.2 12.2 3.2 3.3 3.4 3.3 3.4 11.2 11.2 11.2 3.2 14.2 14.2 14.2 14.2 14.2 14.2
Preface
xi
Table 4 Special functions N–Z Function name Neumann function Oblate spheroidal function Oblate spheroidal function Pochhammer symbol Psi function Riemann zeta function
Notation Yν (z) Rnm (x) Tnm (x) (z)w ψ(z) ζ(s)
Section 4.3 3.4 3.4 1.3 1.4 20.1
Ring function, first kind
P
Ring function, second kind
Q
Scorer function Scorer function Spherical harmonics
Gi(z) H i(z) Ylm (θ, φ)
4.2 4.2 3.3
Struve function Struve function ϑ functions
Hν (z) Kν (z) ϑn (z, τ ), n ∈ {1, 2, 3, 4}
5.2 5.2 9.2
Toroidal function, first kind
P
Toroidal function, second kind
Q
Voigt profile Voigt profile Voigt profile, line broadening Wave function, radial Weber function Weierstraß elliptic functions Whittaker function Whittaker function Wigner function
U (x, t) V (x, t) H (a, u) Rn,l (r) Eν (z) ℘ (z), σ (z), ζ(z) Ma,b (z) Wa,b (z) W (q, p)
2.3 2.3 2.3 17.1 5.3 12.2 6.3 6.3 16.3
Wigner rotation function
l dm,m (β)
15.5
Wigner 3j-symbol Wigner 6j-symbol Wigner 9j-symbol Zernike polynomial
(· · · ) {· · · } {· · · } Znm (ρ, φ)
22.1.2 22.1.3 22.1.4 15.3.1
μ (z) − 12 +τ
3.4
μ (z) − 12 +τ
3.4
μ (z) − 12 +τ
3.4
μ (z) − 12 +τ
3.4
Contents
1
Gamma Functions, Beta Functions, and Related . . .. . . . . . . . . . . . . . . . . . . . 1.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.2 Gamma Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.2.1 Fundamental Equations . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.2.2 Computation of the Gamma Function .. . . . . . . . . . . . . . . . . . . . 1.2.3 The Class gammalnC and gammaC . . .. . . . . . . . . . . . . . . . . . . . 1.3 The Pochhammer Symbol . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.4 The psi Function.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.5 The Incomplete Gamma Functions .. . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.5.1 Fundamental Equations . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.5.2 Computational Aspects . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.5.3 Related Programs .. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.6 Applications: Examples .. . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.6.1 Examples .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.7 The Beta Function .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.7.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.7.2 The Class betalnC and betaC. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.8 The Incomplete Beta Function.. . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.8.1 Fundamental Equations . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.8.2 Computational Aspects . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1.8.3 The Class incbetaC . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
1 1 3 3 4 5 6 7 8 8 9 11 13 13 15 15 16 16 16 17 20 21
2
Error Functions and Fresnel Integrals .. . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 2.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 2.2 Error Functions .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 2.2.1 Fundamental Equations and Computation.. . . . . . . . . . . . . . . . 2.2.2 erfComp and Applications . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 2.3 Voigt Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 2.4 Fresnel Integrals .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
23 23 24 24 26 28 30 31
3
Legendre Polynomials and Legendre Functions . . . .. . . . . . . . . . . . . . . . . . . . 3.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 3.2 Legendre Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
33 33 35 xiii
xiv
Contents
3.3
Legendre Functions of Integer Type .. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 3.3.1 Fundamental Equations and Computation.. . . . . . . . . . . . . . . . 3.3.2 Application: Spherical Harmonics .. . . .. . . . . . . . . . . . . . . . . . . . 3.4 Associate Legendre Functions with Complex Indices .. . . . . . . . . . . . . 3.4.1 Fundamental Equations . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 3.4.2 Conical or Mehler Functions .. . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 3.4.3 Complex Legendre Functions .. . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
41 42 45 46 46 51 57 63
4
Bessel and Airy Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.2 Airy Functions and Related Functions . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.2.1 The Scorer Functions .. . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.3 Bessel Functions and Related Functions . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.3.1 Bessel and Hankel Functions . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.3.2 Modified Bessel Functions .. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.3.3 Spherical Bessel Functions .. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.3.4 Kelvin Functions.. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 4.4 The SPECFUNPHYS-Class Bessel . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
65 66 66 69 71 71 74 76 77 78 80
5
Struve Functions and Related Functions . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.2 Struve Functions.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.2.1 Struve Functions H and K . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.2.2 Modified Struve Functions L and M . .. . . . . . . . . . . . . . . . . . . . 5.2.3 The Class Struve .. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.3 The Anger Function and the Weber Function .. .. . . . . . . . . . . . . . . . . . . . 5.3.1 Anger Function . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.3.2 Weber Function .. . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 5.3.3 The Class Angweb.. . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . Reference .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
81 81 82 82 83 85 86 87 87 88 89
6
Confluent Hypergeometric Function . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 6.1 Confluent Hypergeometric Function of 1st and 2nd Kind.. . . . . . . . . 6.1.1 The Function 1F1 . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 6.1.2 The Function U and 2F0 . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 6.2 The Confluent Hypergeometric Limit Function . . . . . . . . . . . . . . . . . . . . 6.3 The Whittaker Functions .. . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 6.4 The SPECFUNPHYS Class conhyp.. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
91 92 92 94 96 97 97 99
7
Coulomb Wave Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 7.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 7.2 The Coulomb Wave Functions.. . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 7.2.1 Partial Wave Coulomb Function . . . . . . .. . . . . . . . . . . . . . . . . . . . 7.2.2 Coulomb Wave Function: Parabolic Coordinates . . . . . . . . .
101 103 103 103 105
Contents
xv
7.3
Program Details and Applications .. . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 7.3.1 The SPECFUNPHYS Class coulombwave.. . . . . . . . . . . . . . 7.3.2 The SPECFUNPHYS Class coulombscatt .. . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
106 106 109 111
8
Hypergeometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 8.1 The Hypergeometric Series . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 8.2 Method of Computation.. . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 8.3 The SPECFUNPHYS-Class Gausshyp . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
113 113 116 119 121
9
ϑ Functions .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 9.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 9.2 Jacobi ϑ Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 9.2.1 General Equations and Computational Aspects . . . . . . . . . . . 9.2.2 TheSPECFUNPHYS Class jacobiTheta . . . . . . . . . . . . . . . 9.3 Dedekind’s η Function . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 9.4 The Jacobi Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
123 123 124 124 127 128 128 129
10 Jacobi Elliptic Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 10.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 10.2 The Elliptic Functions.. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 10.2.1 Equations and Computational Aspects . . . . . . . . . . . . . . . . . . . . 10.3 The Class ellipFun . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
131 132 133 133 135 138
11 Elliptic Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 11.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 11.2 Equations and Computation . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 11.3 Programs .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
139 139 140 149 151
12 Weierstraß Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 12.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 12.2 Fundamental Equations and Computation . . . . . .. . . . . . . . . . . . . . . . . . . . 12.3 The Class ellipWeier . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . Reference .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
153 153 154 157 160
13 Parabolic Cylinder Functions . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 161 13.1 Equations and the Class paracylFun.. . . . . . . .. . . . . . . . . . . . . . . . . . . . 162 References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 164 14 Mathieu Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 14.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 14.2 Fundamental Equations and Computation . . . . . .. . . . . . . . . . . . . . . . . . . . 14.2.1 Mathieu Differential Equation . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 14.2.2 Modified Mathieu Differential Equation . . . . . . . . . . . . . . . . . .
165 166 166 166 172
xvi
Contents
14.3 Programs .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 14.3.1 The SPECFUNPHYS Class Mathieufun .. . . . . . . . . . . . . . . . . . . 14.3.2 Additional SPECFUNPHYS Functions .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
174 174 177 179
15 Orthogonal Polynomials: General Aspects . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.2 General Definitions.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.3 The Classes orthpoly and polymeth . . . . . .. . . . . . . . . . . . . . . . . . . . 15.3.1 The Class orthpoly .. . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.3.2 The Class polymeth .. . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.4 Gegenbauer Polynomials . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.4.1 The SPECFUNPHYS Class gegenbauerpoly and gegenbauerx .. . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.5 Jacobi Polynomials .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 15.5.1 The SPECFUNPHYS Class Jacobipoly and Jacobix . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
181 182 182 185 185 186 189 190 192 194 197
16 Hermite Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 16.1 Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 16.2 Hermite Polynomials .. . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 16.2.1 The SPECFUNPHYS Class hermitepoly.. . . . . . . . . . . . . . 16.2.2 Evaluating Hermite Polynomials . . . . . .. . . . . . . . . . . . . . . . . . . . 16.3 Oscillator Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 16.3.1 Applications.. . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
199 199 200 202 202 203 204 210
17 Laguerre Polynomials .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 17.1 Laguerre Polynomials .. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 17.1.1 General Aspects . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 17.1.2 Related Programs .. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
211 212 212 213 214
18 Chebyshev Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 18.1 Basic Properties and Formulae . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 18.1.1 Definition and Recurrence Formula . . .. . . . . . . . . . . . . . . . . . . . 18.1.2 The Shifted Chebyshev Polynomials . .. . . . . . . . . . . . . . . . . . . . 18.1.3 Miscellaneous .. . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 18.2 Computational Aspects and Programs . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 18.2.1 Computational Aspects . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 18.2.2 Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
215 216 216 218 219 219 219 221 224
19 Bernoulli and Euler Polynomials . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 19.1 Bernoulli Numbers and Bernoulli Polynomials .. . . . . . . . . . . . . . . . . . . . 19.1.1 Equations.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 19.1.2 Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
225 226 226 227
Contents
xvii
19.2 Euler Numbers and Euler Polynomials.. . . . . . . . .. . . . . . . . . . . . . . . . . . . . 19.2.1 Equations.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 19.2.2 Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
229 229 230 232
20 Riemann Zeta Function .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 20.1 Equations and Evaluation .. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 20.1.1 Equations.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 20.1.2 Evaluation .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
233 234 234 235 236
21 Piecewise Interpolation Polynomials . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 21.1 Interpolation Polynomials . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 21.1.1 Lagrange Interpolation Polynomials .. .. . . . . . . . . . . . . . . . . . . . 21.1.2 Hermite Interpolation Polynomials . . . .. . . . . . . . . . . . . . . . . . . . 21.1.3 Extended Hermite Interpolation Polynomials .. . . . . . . . . . . . 21.2 Computational Aspects . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 21.3 The Finite Element Method .. . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 21.3.1 Example: The Hydrogen Atom . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
237 238 238 239 242 243 243 246 250
22 Wigner- and Clebsch-Gordan Coefficients . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.1 Fundamental Equations and Computation . . . . . .. . . . . . . . . . . . . . . . . . . . 22.1.1 Basic Aspects . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.1.2 Clebsch-Gordan Coefficients and Wigner 3j-Symbols . . . 22.1.3 Wigner 6j-Symbols . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.1.4 Wigner 9j-Symbols . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.2 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.2.1 Clebsch-Gordan Coefficients and Wigner 3j-symbols .. . . 22.2.2 Wigner 6j-Symbols . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 22.2.3 Wigner 9j-Symbols . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
251 251 251 253 254 255 255 255 256 257 258
23 Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 23.1 Separability in Three Dimensions . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 23.2 Programs and Computational Aspects . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 23.2.1 The SPECFUNPHYS Class CoordTrafo .. . . . . . . . . . . . . . . . . . . 23.2.2 Ellipsoidal Coordinates and Cone Coordinates . . . . . . . . . . . 23.2.3 Hyperspherical Coordinates .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . References .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .
259 260 268 268 272 273 275
Index . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 277
Gamma Functions, Beta Functions, and Related
Abstract
Topics of this chapter are gamma functions, beta functions, and related functions in the complex domain. The evaluations are based on various numerical techniques in dependence of the function argument. Related functions are the Pochhammer symbol, the psi or digamma function, the incomplete gamma function and its first and second derivative, the inverse incomplete gamma function, and the incomplete beta function. In addition some examples are discussed. Corresponding programming code can be downloaded.
This chapter focuses on gamma functions and beta functions and related functions, such as their derivatives and incomplete gamma respectively incomplete beta functions. Γ - and β-functions are related to many special functions, integrals and series expansions of differential equations and quite frequently used for evaluation. We will start with a short overview of relevant MATLAB- and toolbox functions.
1.1
Function Overview
Gamma function and related • gamma MATLAB-function returns the gamma function restricted to real arguments.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_1
1
1
2
1 Gamma Functions, Beta Functions, and Related
• gammaC SPECFUNPHYS-class returns the gamma function for real and complex arguments. • gammaln MATLAB-function returns the logarithm of the gamma function for positive real arguments. • gammalnC SPECFUNPHYS-class returns the logarithm of the gamma function for arbitrary complex arguments. Pochhammer Symbol pochC, pochlnC SPECFUNPHYS-class, returns the value of the Pochhammer Symbol, respectively, its logarithm for complex arguments. psi or digamma function is the logarithmic derivative of the gamma function. The MATLAB-function psi is restricted to positive real arguments, the SPECFUNPHYS-class psiC supports complex arguments. Incomplete gamma function • gammainc MATLAB-function returns the value of the incomplete gamma function for real values of the integral boundary and positive real numbers in the integrand. • incgammaC SPECFUNPHYS-class returns the value of the incomplete gamma function for complex arguments. • diincgammaC returns the first two derivatives of the incomplete gamma function supporting complex arguments. • invincgammaC computes the inverse incomplete gamma function in the complex domain. Beta function and related • beta MATLAB-function returns the beta function restricted to positive real arguments • betaC SPECFUNPHYS-class returns the beta function for real and complex arguments • betaln MATLAB-function returns the logarithm of the beta function for positive real arguments. • betalnC SPECFUNPHYS-class returns the logarithm of the beta function for arbitrary complex arguments. Incomplete Beta function The MATLAB-function betainc returns the incomplete beta function. The limit of the integral is restricted to the interval [0, 1] and the integral values to positive real numbers. The SPECFUNPHYS-class incbetaC works for arbitrary complex arguments.
1.2 Gamma Function
3
1.2
Gamma Function
1.2.1
Fundamental Equations
The gamma function Γ is a generalization of the factorial function. The following equations can be found in [1] and [3]. For positive integers n Γ (n) = (n − 1)! , and n!! =
1
2 2 n Γ ( 12 n + 1) 1 1 π − 2 2 2 (n+1) Γ ( 12 n + 1)
: :
(1.1a)
n even . n odd
The gamma function can be defined by ∞ Γ (z) = zz−1 exp(−t)dt , and
(1.1b)
(1.2)
0
holds the recurrence relation Γ (z + 1) = z Γ (z) .
(1.3)
Euler’s reflection formula Γ (1 − z)Γ (z) =
π sin(πz)
z∈ / Z.
(1.4)
Plays an important rôle for evaluating Γ (z). Figure 1.1 shows the absolute value of the gamma function in the complex plane. Under complex conjugation the gamma function becomes Γ (¯z) = Γ (z)
and
ln(Γ (¯z)) = ln(Γ (z)).
(1.5)
For z = −n, n ∈ N Γ (z) has a simple pole, Fig. 1.1, with residuum Res(Γ, −n) =
−n n!
.
Some special values are Γ (ix) =
π x sinh(πx)
with x real,
(1.6a)
1 1 Γ ( ) = π 2 , and 2
(1.6b)
|Γ (x + iy)| ≤ |Γ (x)|.
(1.6c)
4
1 Gamma Functions, Beta Functions, and Related | (z)|
35 30 25 20 15 10 5 5i 4 2
0i
0 -2
imag
-4 -5 i
-6
real
Fig. 1.1 Absolute value of Γ (z) in the complex plane. At negative integer values Γ (z) becomes infinite
Γ (z) can become very large for large z. Therefore, to avoid overflow the computation will be based on the logarithm of the gamma function.
1.2.2
Computation of the Gamma Function
The computation of the gamma function is based on a Lanczos series: Γ (z + 1) = (z + γ + 0.5)z+0.5 exp[−(z + γ + 0.5)] √ c1 c2 cn × 2π c0 + + ··· . z+1 z+2 z+n
(1.7)
A general discussion can be found in [5]. This series converges for (z) ≥ 0. To compute Γ (z) in the left half complex plane Euler’s reflection formula, Eq. (1.4), is used and to avoid overflows the logarithm ln(Γ (z)) is computed. For the evaluation, the user can either choose the coefficients derived from Godfrey [2], γ = 607 128 and c = [0.99999999999999709182; 57.156235665862923517; -59.597960355475491248; 14.136097974741747174; -0.49191381609762019978; .33994649984811888699e-4; .46523628927048575665e-4; -.98374475304879564677e-4;
1.2 Gamma Function
5
.15808870322491248884e-3; -.21026444172410488319e-3; .21743961811521264320e-3; -.16431810653676389022e-3; .84418223983852743293e-4; -.26190838401581408670e-4; .36899182659531622704e-5];
or the coefficients published in [4], γ = 5 and c = [1.000000000190015 76.18009172947146 -86.50532032941677 24.01409824083091 -1.231739572450155 0.1208650973866179e-02 -0.5395239384953d-05];
The computation based on the second series is less accurate than the computation based on the first one and serves mainly for testing.
1.2.3
The Class gammalnC and gammaC
The MATLAB-function y = gammaln(a) returns the logarithm of the gamma function. The input “a” must be non-negative and real. The SPECFUNPHYS-class [obj, erg] = gammalnC(a,coe) computes the logarithm of the gamma function for arbitrary complex arrays “a”, where the optional input “coe” is “default” or “PG” for Lanczos-coefficients based on the work of Paul Godfrey [2], “NR” for the Lanczos-coefficients as published in the Numerical Recipes [4], and “ML” if the MATLAB-function gammaln should be used. The return value “obj” is an object of the class gammalnC with the properties “value” for the values of gammalnC, “info” for information about the used method, and “ina” with the input “a”. The second value “erg” are the Γ -values as doubles. The class gammalnC supports the methods abs for computing the absolute value, angle to compute the phase angle in radians, conj for complex conjugation, and imag for computing the imaginary part and real for the real part of the gammalnC object. All methods have two inputs. The first one is the class object and the second argument (optional) determines whether the method should be applied on the property “value” (default) or on the input variable “ina”. The SPECFUNPHYS-class [obj,res] = gammaC(a,coe) returns the gamma function evaluated at the (complex) elements of “a”. gammaC calls the class gammalnC and the result is derived with the MATLAB exp-function. “coe” has exactly the same possible values as gammalnC and gammaC comes with the same methods as gammalnC. Example
The following example visualizes the Γ -function.
6
1 Gamma Functions, Beta Functions, and Related function gammavisu % gamma function visualized % due to inf at negative integer maximum % function values restricted to 35 x = [-6.2:0.1000:5.25];%+0.05; y = -5:0.1:5; [X,Y] = meshgrid(x,y); Z = X+i*Y; yp = gammaC(Z); Zp = abs(yp);
% % % % % %
complex plane Gamma-function ’PG’ method is used abs-method alternative abs(yp,’value’) or yp.abs(’value’)
Zp(Zp>35)=35; surf(X,Y,Zp),axis tight, shg fh = gcf; fh.Position = [60 80 961 594]; ah = gca; ytl=ah.YTickLabel; for k=1:length(ytl) ytlk = [ytlk,’ i’]; end ah.YTickLabel = ytl; xlabel(’real’),ylabel(’imag’) title(’|\Gamma(z)|’)
1.3
The Pochhammer Symbol
Pochhammer’s symbol [1, 3] is given by (z)w =
Γ (z + w) . Γ (z)
(1.8)
For “w” positive integer this is equal to z · (z + 1) · (z + 2) · · · (z + w). The class [obj,erg] = pochlnC(z,w) returns the logarithm of the Pochhammer symbol calling the class gammalnC and using the computation based on the Γ Lanczos-coefficients as derived by Godfrey [2]. The two inputs “z,w” are complex arrays either of the same size or one must be a scalar. The object “obj” has the properties “value” (function value), “inz” (first input), and “inw” (second input). The second output “erg” is the function values in doubles. The class pochlnC supports the methods abs for computing the absolute value, angle to compute the phase angle in radians, conj for complex conjugation, and imag for returning the imaginary part and real for returning the real part of the gammalnC object. All methods have two inputs. The first one is the object and the second one (optional) on which class property the method should be applied on,
1.4 The psi Function
7
with the value “value” (default) for the Pochhammer result, or “inz” for the first input, or “inw” for the second input. The class [obj,erg] = pochC(z,w) returns the Pochhammer value by calling the class pochlnC and using the MATLAB exp-function. Arguments and methods are equivalent to the description above for pochlnC. Example x = [-6.2:0.1000:5.25]; y = -5:0.1:5; [X,Y] = meshgrid(x,y); Z = X+i*Y; w = 2*rand; objp = pochC(Z,w); Zp = abs(objp,’value’); Zp(Zp>35)=35; surf(X,Y,Zp)
1.4
% complex plane
% % % %
Pochhammer value abs-method alternative objp.abs(’value’) limit peaks
The psi Function
The psi or digamma function is the logarithmic derivative of the gamma function. ψ(z) =
d(lnΓ (z)) 1 dΓ (z) = . dz Γ (z) dz
(1.9)
The psi function holds the following recurrence equation: 1 ψ(z + 1) = ψ(z) + , z
(1.10)
ψ(1 − z) = ψ(z) + π cot(πz).
(1.11)
and reflection formula
The MATLAB-function psi is restricted to positive real arguments and the SPECFUNPHYS-class psiC works also for complex arguments. obj=psiC(z) is computed from the logarithmic derivative of the Γ Lanczos series, Eq. (1.7), with the coefficients from [2]. For the left complex half plane Euler’s reflection formula, Eq. (1.4), is used. The input “z” is an arbitrary complex array and “obj” an object of the class psiC with the properties “value” (ψ-value) and “inz” (input variable). Like gammalnC psiC supports the methods abs for computing the absolute value, angle to compute the phase angle in radians, conj for complex conjugation, and imag for computing the imaginary part and real for the real part of the psiC object. All methods have two inputs. The first one is the object and the
8
1 Gamma Functions, Beta Functions, and Related
optional second one if the method should be applied on the property “value” or the input value z “inz”. The default is “value”. Example r =0.6; theta = linspace(0,2*pi,200); z = r*exp(i*theta); obj = psiC(z);
% z coordinates
% psi-function % method angle: % phase angle % method abs: radius
phi = obj.angle(’value’); rho = obj.abs(’value’); polarplot(phi,rh)
The toolbox comes in addition with example psivisu.
1.5
The Incomplete Gamma Functions
1.5.1
Fundamental Equations
There are two incomplete gamma functions which differ in the selected integration tail. z exp(−t)t a−1 dt, and (1.12) γ (z, a) =
0 ∞
Γ (z, a) =
exp(−t)t a−1 dt.
(1.13)
z
Their sum is given by the Gamma function Γ (a) = γ (x, a) + Γ (x, a),
(1.14)
thus it is sufficient to compute one type of the incomplete gamma functions. The normalized functions are P (z, a) =
γ (z, a) Γ (a)
and Q(z, a) =
Γ (z, a) Γ (a)
with
P (z, a) +Q(z, a) = 1.
(1.15a) (1.15b)
γ (z, a) has simple poles at a equal to negative integers or zero. The incomplete gamma functions hold the recurrence formula γ (z, a + 1) = aγ (z, a) − za exp(−z)
and
(1.16)
1.5 The Incomplete Gamma Functions
9
Γ (z, a + 1) = aΓ (z, a) + za exp(−z).
(1.17)
The derivatives are given by d d γ (z, a) = − Γ (z, a) = za−1 exp(−z), and dz dz
(1.18a)
d2 1−a d y(z, a) with y = γ (z, a) or y = Γ (z, a). y(z, a) = − 1 + z dz dz2 (1.18b) The incomplete gamma function is related to the confluent hypergeometric function 1 F1 (a; b; z), Eq. (6.5), via γ (z, a) = a −1 za exp(−z) 1 F1 (1, 1 + a, z) γ (z, a) = a
−1 a
z
and
1 F1 (a, 1 + a, −z).
(1.19) (1.20)
These equations will be useful for computing the incomplete gamma function by a series expansion.
1.5.2
Computational Aspects
The series expansion of Eq. (6.5) converges for all allowed values, but in some cases very slow. Therefore the computation will make use of the series expansion Eqs. (1.19) and (1.20), on a continued fraction ansatz, and on the recurrence formula. From Eq. (6.5) we get 1 F1 (1; 1 + a; z)
=1+
1 1 1 z+ z2 + z3 + · · · 1+a (1 + a)(2 + a) (1 + a)(2 + a)(3 + a) (1.21)
which will diverge for a negative integers. The single terms of the sum can be efficiently computed by t0 = 1 , tn =
1 tn−1 n+a
n = 1, 2, 3, · · · .
(1.22)
10
1 Gamma Functions, Beta Functions, and Related
Similar for 1 F1 (a; 1 + a; z)
=1+ +
a(a + 1) a z+ z2 (1 + a) · 1 (1 + a)(2 + a) · 1 · 2
a(a + 1)(a + 2) z3 + · · · (1 + a)(2 + a)(3 + a) · 1 · 2 · 3
(1.23)
which will diverge as well for a negative integers. The single terms of the sum can be computed via t0 = 1 , tn =
a+n−1 tn−1 (n + a) · n
n = 1, 2, 3, · · · .
(1.24)
Thus together with Eqs. (1.19) and (1.20) we can approximately calculate the value of the incomplete gamma function. To avoid a loss of significance the single terms of the sum are split in their real and imaginary part and each of them in its positive and negative part. Each of these positive subparts will be sorted in ascending order and the negative ones in descending order and summed individually before put together. The upper summation limit depends on |z| to avoid overflow. For (a) large it turns out that the series expansions above converge slowly. In this case an approximation by continued fraction [1] 6.5.31 is more favorable:
1 1−a 1 2−a 2 γ (z, a) = Γ (a) − exp(−z)z ··· . z+ 1+ z+ 1+ z+
a
(1.25)
1 cf (z,a)
Therefore we have to compute cf (z, a) = z +
1−a 1+
1
.
(1.26)
2−a z+ 2 1+ z+ 3−a 1+···
In the final computation convergence is no longer tested. Because the computation for the series expansion is very quick, the number of terms in the sum is by default very high, in most cases unnecessarily high; similar for the continued fraction. Tests on convergence were performed in developing the toolbox functionalities. Even if the recurrence equations (1.16) are analytic equations, they are numerically of limited stability. For a = 1 the incomplete gamma function equals to γ (1, z) = 1 − exp(z).
(1.27)
1.5 The Incomplete Gamma Functions
11
This equation will be used for computing the a = 1 results, and serves as a starting value for the recurrence equation (1.16). The computation based on this equation will be limited for a positive integer and 1 < a ≤ 7.
1.5.3
Related Programs
Incomplete Gamma Functions MATLAB comes with the functions gammainc for the incomplete gamma function and gammaincinv for the inverse incomplete gamma function. Note, gammainc returns the normalized functions, Eq. (1.15a), and is restricted to positive real values for “a” and real values for “z”. The SPECFUNPHYS-class incgammaC computes the (non-normalized) incomplete gamma function, Eqs. (1.12), and (1.13), therefore differs by the scaling factor Γ (a), but is not restricted to real values. The SPECFUNPHYS-class [obj, erg] = incgammaC(z,a,lu,nm,method) computes the incomplete gamma function in the complex plane. (z,a) are the same variables as in Eq. (1.12), they must be the same size or either scalar. All other variables are optional. “lu” specifies the integral tail and has the values “lower” (default) or “upper”. “nm” is the upper bound of summations for series based computations. The default value depends on |z| to avoid overflow with a maximum number of 500. The default depth is 10 for the continued fraction (10th-approximant). “method” can have the values “m1” for computations based on Eq. (1.19), “m2” for Eq. (1.20), and “m3” for continued fraction based computations. The method is selected in dependence of the values of a, z and z/a. For a = 1 Eq. (1.27) will be used and for a positive integer and a ≤ 7 the evaluation will be based on the recurrence equation (1.16). The object “obj” comes with the properties value (function value), info (information about computational method used and upper or lower tail), ina (numerical input a), and inz (numerical input z), and “erg” is the computational value in doubles. incgammaC supports the following methods: “abs” for for computing the absolute value, “real” for the real and “imag” for the imaginary value, “angle” for the phase angle in radians, and “conj” for the complex conjugate value. Each of the methods can be applied either on the values (value, default) or on the input variables z (inz) or a (ina), e.g., >> obj=incgammaC(randn*exp(i*randn), rand); >> abs_a=obj.abs(’ina’); % or >> abs_a=abs(obj,’ina’);
The second argument (here “ina”) of the methods is optional. Derivatives of the Incomplete Gamma Functions The 1st and 2nd derivatives of the incomplete gamma function are given by Eqs. (1.18a) and (1.18b). The corresponding class is diincgammaC with integral-
12
1 Gamma Functions, Beta Functions, and Related
arguments “z,a” and the optional 3rd argument “lu” with values ’‘lower”, or “upper” (“l”,“u”,“lo”,“up”) in dependence of the integral tail. The class properties are res for the first derivative of the incomplete gamma function, resd2 for the second derivative, info is the information about the integral tail, and ina, inz the integral input values “a, z”. diincgammaC supports the same methods as incgammaC and in addition its own surf-method. The syntax is [h1, h2, h3] = surf(obj,ax,was,loga,dd), with “obj” the class object. All other input variables are optional. “ax” allows either the input variable ‘z’ (default) or ‘a’ to be selected as the plot axis; “was” what shall be plotted, the real or absolute etc. function value, with values ‘real’, ‘imag’, ‘abs’ or ‘all’; “loga” with value “log” if the absolute function value shall be plotted in a logarithmic scale, and “dd” with value ‘dd’ if the second derivative shall be plotted (default 1st derivative). “hx” are the figure handle objects. The Inverse of the Incomplete Gamma Functions The computation of the inverse of the incomplete gamma functions is based on a Newton-Raphson method. Numerical tests with refining complex grids to obtain an optimized starting value failed. Therefore the starting value for the Newton-Raphson algorithm is a complex normally distributed random value. The advantage is that the computation becomes very quick. The disadvantage is that in rare cases no result is found. In many cases this was based on a vanishing or on an extremely large first derivative. Repeating the computation or slightly changing the γ -value could lead to a result. The Newton-Raphson computation stops either after 100 iterations or after convergence is reached. Be zNR the computed Newton-Raphson value. From this value we compute γ (zNR , a). If the relative difference of both the real and the imaginary part of γ (zNR , a) to the original gamma-value is less than 10−7 from the original γ -value, the result is accepted, otherwise it is rejected. In case no converged result was found, the Newton-Raphson algorithm will be repeated (maximum: 50times). γ (z, a) is a many-valued function of z. The Newton-Raphson computation stops if one solution is found. To obtain several solutions the computation must be repeated several times. The function [z,info,protocol] = invincgammaC(a,ergt,tail,zstart) computes the inverse incomplete gamma function. “a” is the integrand value, “ergt” the value of the incomplete gamma function. The optional input value “tail” determines the integral tail; ∞ “u” for the upper tail z · · · all other character values for the lower tail (default). “zstart” (optional) determines the start value in case the computation should not start randomly. If no result is found, the computations will continue with random values. The output-value “z” is the integrand value, “info” a cell variable with some information about the accuracy of the computation, and “protocol” a table with the values of each Newton-Raphson iteration step.
1.6 Applications: Examples
1.6
13
Applications: Examples
The Γ - and incomplete gamma functions serve quite frequently as normalization or scaling factors. Due to their relation to different integrals they are also useful for computing integrals. For example, Γ (z) holds the following relation:
∞
Γ ( α+1 2 ) . (α+1)/2 2β
x α exp(−βx 2 )dx =
0
(1.28)
The exponential integrals can be easily calculated with the help of the incomplete gamma function Γ (a, x).
∞
En (x) = 1
exp(−x t) tn
x > 0 n ∈ N,
En (x) = x n−1 Γ (x, 1 − n),
(1.29a) (1.29b)
thus E0 (x) =
exp(−x) 1 and En (0) = x n−1
n > 1.
(1.29c)
As examples we will have a closer look on the Böhmer integrals.
1.6.1
Examples
The Böhmer Integrals The Böhmer or generalized sin and cos Integrals are given by
∞
si(z, a) =
(1.30)
t a−1 cos(t)dt
(a) < 1
(1.31)
t a−1 sin(t)dt
(a) > −1
(1.32)
t a−1 cos(t)dt
(a) > 0,
(1.33)
z z
Si(z, a) =
(a) < 1
∞
ci(z, a) =
t a−1 sin(t)dt
z
0 z
Ci(z, a) = 0
and hold the following relations:
1 ci(z, a) ± i si(z, a) = exp ± iπa Γ (∓i z, a) 2
(1.34)
14
1 Gamma Functions, Beta Functions, and Related
1 Ci(z, a) ± i Si(z, a) = exp ± iπa γ (∓i z, a). 2
(1.35)
From Eq. (1.35) we obtain easily
1 1 Ci(z, a) = exp iπa γ (−i z, a) + exp − iπa γ (i z, a) /2 and 2 2 (1.36)
1 1 Si(z, a) = exp iπa γ (−i z, a) − exp − iπa γ (i z, a) /2. (1.37) 2 2 The MATLAB-function q = integral(fun,xmin,xmax) (for details see the MATLAB-documentation) allows directly to integrate Eqs. (1.32), and (1.33), with “fun” the function handle representing the integrand and “xmin, xmax” the integral limits. integral is based on an adaptive quadrature. %% Example: Computing the Boehmer integrals % via incomplete gamma function a0 = exp(i*rand) % a0 = 0.6861 + 0.7275i z = exp(i*rand) % z = 0.6171 + 0.7869i %% For sufficiently large a --> no problem format long a = 2*a0; % direct integration Cih = @(t) t.^(a-1) .* cos(t); Ci = integral(Cih,0,z) % 0.153560594714140 + 0.036271725299627i % Sih = @(t) t.^(a-1) .* sin(t); Si = integral(Sih,0,z) % 0.006099267216393 + 0.100534030211523i % incomplete gamma function [objp,ergp] = incgammaC(i*z,a); [objm,ergm] = incgammaC(-i*z,a); Cig = (exp(-1/2*pi*a*i).*ergp + exp(1/2*pi*a*i).*ergm)/2 % 0.153560588891605 + 0.036271722524393i Sig = (exp(1/2*pi*a*i).*ergm exp(-1/2*pi*a*i).*ergp)/(2*i) % 0.006099267002845 + 0.100534030518022i
The results based on the MATLAB-function integral and the results computed with the incomplete gamma function are in very good agreement. %% If a is too small --> insufficient accuracy a= a0/10 % Cih = @(t) t.^(a-1) .* cos(t); Ci = integral(Cih,0,z) %Warning: Reached the limit on the maximum number of
1.7 The Beta Function
15
% intervals in use. % Approximate bound on error is 9.0e-02. The integral % may not exist, % or it may be difficult to approximate numerically % to the requested accuracy. % % Ci = 7.197972035744612 - 6.956739662340192i % Sih = @(t) t.^(a-1) .* sin(t); Si = integral(Sih,0,z) % 0.590239179687008 + 0.664022327453170i % [objp,ergp] = incgammaC(i*z,a); [objm,ergm] = incgammaC(-i*z,a); Cig = (exp(-1/2*pi*a*i).*ergp + exp(1/2*pi*a*i).*ergm)/2 % 6.885162924201410 - 6.622074106422456i Sig = (exp(1/2*pi*a*i).*ergm exp(-1/2*pi*a*i).*ergp)/(2*i) % 0.590239111019731 + 0.664022265510878i
In this case the function integral did no longer sufficiently converge for the generalized cos-integral. Thus in some situations it might be easier to compute integrals via incomplete gamma functions than by direct integration. In addition the relation with incomplete gamma function allows a generalization of integral functions.
1.7
The Beta Function
1.7.1
Basics
The beta function is closely related to the gamma function. Its integral representation is given by the Euler integral of 1st kind:
1
B(z, w) =
t z−1 (1 − t)w−1 dt
with (z) > 0, (w) > 0 .
(1.38)
0
The beta function is symmetric B(z, w) = B(z, w)
(1.39)
and holds B(z, w) =
Γ (z)Γ (w) . Γ (z + w)
(1.40)
16
1 Gamma Functions, Beta Functions, and Related
The binomial coefficient nk can be computed with the MATLAB-function nchoosek and generalized via
1 n n! = . = k!(n − k)! (n + 1)B(k + 1, n − k + 1) k
(1.41)
The computation of the SPECFUNPHYS beta function is based on the logarithm of Eq. (1.40).
1.7.2
The Class betalnC and betaC
The SPECFUNPHYS-class [obj, erg] = betalnC(z,w) returns the logarithm of the beta function for arbitrary complex arrays “z,w”. betalnC calls gammalnC, and the computation is based on the Lanczos-coefficients of Paul Godfrey [2]. The return value “obj” is an object of the class betalnC with the properties “value” for the values of betalnC, “inz” and “inw” for the input of the first, respectively, second argument “z,w”. The second output variable “erg” are the Beta-values as doubles. The class betalnC supports the methods abs for computing the absolute value, angle to compute the phase angle in radians, conj for complex conjugation, and imag for computing the imaginary part and real for the real part of the betalnC object. All methods have two inputs. The first one is the object and the optional second one if the method should be applied of the property “value” or one of the input values “inz”, “inw”. The default is “value”. The SPECFUNPHYS-class [obj,res] = betaC(z,w) returns the beta function at the elements of “z, w”. betaC calls the class betalnC and the result is derived with the MATLAB exp-function. All arguments have exactly the same possible values as betalnC and betaC comes with the same methods as betalnC.
1.8
The Incomplete Beta Function
1.8.1
Fundamental Equations
The incomplete Beta function [1] is defined by
x
Bx (a, b) =
t a−1 (1 − t)b−1 dt.
(1.42)
0
Please note that the MATLAB-function betainc is based on Ix (a, b) = Bx (a, b)/B(a, b),
(1.43)
1.8 The Incomplete Beta Function
17
and limited to positive real values for “a, b” and 0 < x ≤ 1. The incomplete Beta function is related to the hypergeometric function 2 F1 [3] via Bz (a, b) = =
za 2 F1 (a, 1 − b; a + 1; z) a
and
(1.44a)
za (1 − z)b 2 F1 (a + b, 1; a + 1; z). a
(1.44b)
The computation will be based on these relations to the hypergeometric function and its transformation properties (8.3).
1.8.2
Computational Aspects
The computation of the incomplete Beta function is based on a series expansion of the hypergeometric function, see Chap. 8. Because this expansion only converges for |z| < 1 argument transformations are necessary to cover the complete complex space. The hypergeometric function is defined as ˜ c; ˜ b; ˜ z) = 2 F1 (a,
∞ ˜ n zn (a) ˜ n (b) n=0
=
∞
(c) ˜n
n!
|z| < 1
tn zn
(1.45)
(1.46)
n=0
with (· · · )n the Pochhammer symbol, Eq. (1.8). tn can be iteratively computed (a˜ + n)(b˜ + n) tn . (c˜ + n)(n + 1)
(1.47)
a˜ = a, b˜ = 1 − b, and c˜ = a + 1,
(1.48)
t0 = 1, tn+1 = Case 1 Due to Eq. (1.44a) we set
and thus we get from Eq. (1.47) t0 = 1, tn+1 =
(a + n)(1 − b + n) tn . (a + 1 + n)(n + 1)
(1.49)
Therefore the series expansion becomes finite and hence exact for 1 − b = −n ⇒ b = n + 1, and if b > −a infinite for a = −n − 1 with n positive integer and z arbitrary. The computation of Bz (a, b) converges only within the unit circle |z| < 1 for arbitrary a, b.
18
1 Gamma Functions, Beta Functions, and Related
Case 2 Due to Eq. (1.44b) we set a˜ = a + b , b˜ = 1 , and c˜ = a + 1,
(1.50)
and thus we get from Eq. (1.47) t0 = 1, tn+1 =
a+b+n tn . a+1+n
(1.51)
Similar to case 1, the series expansion becomes finite and hence exact for a + b = −n, with n positive integer, and for a = −n − 1 singular. Again, for arbitrary a, b the computation of Bz (a, b) converges only within the unit circle |z| < 1. Case 3 This case is based on the following transformation formula: −a˜ ˜ ˜ c; F ( a, ˜ b; c; ˜ z) = (1 − z) F ˜ c˜ − b; ˜ 2 1 2 1 a,
z z−1
(1.52)
and Eq. (1.44a) a˜ = a , b˜ = 1 − b , and c˜ = a + 1,
(1.53)
hence −a ˜ F ( a, ˜ b; c; ˜ z) = (1 − z) F 2 1 a, a + b; a + 1; 2 1
z , z−1
(1.54)
and thus we get from Eq. (1.47) t0 = 1 , tn+1 =
(a + n)(a + b + n) tn . (a + 1 + n)(n + 1)
(1.55)
This series becomes finite and hence exact for a + b = −n and diverges for a = z −n − 1. Case 3 and 4 are more favorable than case 1 or 2 for |z| > z−1 < 1. Case 4 Similar to case 3 we are using the transformation formula −b˜ ˜ ˜ c˜ − a; ˜ b; c; ˜ z) = (1 − z) 2 F1 b, ˜ c; ˜ 2 F1 (a,
z z−1
(1.56)
and Eq. (1.44b) b˜ = 1 − b , c˜ − a˜ = 1 , and c˜ = a + 1,
(1.57)
1.8 The Incomplete Beta Function
19
hence b−1 ˜ ˜ b; c; ˜ z) = (1 − z) 2 F1 1 − b, 1; a + 1; 2 F1 (a,
z , z−1
(1.58)
and thus we get from Eq. (1.47) t0 = 1 , tn+1 =
1−b+n tn . a+1+n
(1.59)
This series becomes finite and hence exact for b = n + 1 and infinite for a = −(n + 1). Case 5 With the following transformation the series will converge within the unit circle with center at 1. ˜ c; ˜ b; ˜ z) 2 F1 (a, =
˜ Γ (c)Γ ˜ (c˜ − a˜ − b) ˜ a˜ + b˜ − c˜ + 1; 1 − z) F (a, ˜ b; ˜ 2 1 Γ (c˜ − a)Γ ˜ (c˜ − b) ˜
˜ a− ˜ b + (1 − z)c−
Γ (c)Γ ˜ (a˜ + b˜ − c) ˜ ˜ c˜ − a˜ − b˜ + 1; 1 − z). ˜ c˜ − b; 2 F1 (c˜ − a, ˜ Γ (a)Γ ˜ (b) (1.60)
With, Eq. (1.44a), a˜ = a , b˜ = 1 − b , and c˜ = a + 1, Equation (1.60) simplifies to ˜ c; ˜ b; ˜ z) 2 F1 (a,
=
Γ (a + 1)Γ (b) 2 F1 (a, 1 − b; 1 − b; 1 − z) Γ (1)Γ (a + b) a + (1 − z)b 2 F1 (1, a + b; b + 1; 1 − z). −b
(1.61)
and hence for the first summand becomes = 1, tn+1 =
(2)
= 1, tn+1
t0
(1)
a + n (1) t , and the 2nd one n+1 n a + b + n (2) t . = b+1+n n
(1)
t0
(2)
Equation (1.61) diverge for a negative integer.
(1.62) (1.63)
20
1 Gamma Functions, Beta Functions, and Related
Case 6 This last transformation can be used to compute Bz (a, b) outside the unit circle ˜ c; ˜ b; ˜ z) 2 F1 (a,
=
Γ (c)Γ ˜ (b˜ − a) ˜ ˜ 1 ˜ a˜ + 1 − c; ˜ a˜ + 1 − b; (−1)a˜ (z)−a˜ 2 F1 a, ˜ (c˜ − a) z Γ (bΓ ˜
(1.64)
˜ Γ (c)Γ ˜ (a˜ − b) 1 ˜ ˜ ˜ b˜ + 1 − c; (−1)b (z)−b 2 F1 b, + ˜ b˜ + 1 − a; ˜ . ˜ z Γ (aΓ ˜ (c˜ − b) Due to Eq. (1.44a) we set a˜ = a, b˜ = 1 − b, and c˜ = a + 1,
(1.65)
and thus we get from Eq. (1.64) for the first summand the constant term (−1)a
Γ (a)Γ (1 − b − a) Γ (1 − b)
(1.66)
and from the second summand t0 = 1, tn+1 =
(1 − a − b + n)(1 − b + n) tn . (2 − a − b + n)(n + 1)
(1.67)
Due to the first summand we will get a singular result for a a negative integer and for a + b positive integers.
1.8.3
The Class incbetaC
MATLAB comes with the functions betainc for the incomplete Beta function. Note, betainc returns the Beta normalized functions, Eq. (1.43), and is restricted to positive real values for “a, b” and real values between 0 · · · 1 for “z”. The SPECFUNPHYS-class incbetaC computes the (non-normalized) incomplete Beta functions, therefore differs by the scaling factor Beta(a,b) from the MATLAB function, but is not restricted to real values. The SPECFUNPHYS-class [obj, erg] = incbetaC(z,a,b,nm) returns the incomplete Beta function in the complex plane. (z,a,b) are the same variables as in Eq. (1.44a), they could be either of the same size or scalar. “nm” is optional and the upper bound of summations of series expansion, with default value 1000. The object “obj” of the class comes with the properties value (computational result), info (information about computational method), ina, inb (numerical input a, b), and inz (numerical input z), and “erg” is the computational value in doubles. incbetaC supports the following methods: “abs” for computing the absolute value, “real” for the real, and “imag” for the imaginary value, “angle” for the phase
References
21
angle in radians, and “conj” for the complex conjugate value. Each of the methods can be applied either on the function values (value, default) or on the input variables z (inz), a (ina), or b (inb). Example %% Data x = linspace(-5,5,50); % complex array [X,Y] = meshgrid(x,x); z = X+i*Y; a = 0.75 - i*0.25; % randn+i*randn; b = -0.5; % randn; obj = incbetaC(z,a,b); % incomplete Beta function %% Visualization figure,surf(X,Y,obj.abs) xlabel(’real(z)’),ylabel(’imag(z)’),zlabel(’abs’) shg figure,surf(X,Y,obj.real) xlabel(’real(z)’),ylabel(’imag(z)’),zlabel(’real’) shg figure,surf(X,Y,obj.imag) xlabel(’real(z)’),ylabel(’imag(z)’),zlabel(’imag’) shg
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover Pub., New York (1972) 2. Godfrey, P.: A note on the computation of the convergent Lanczos complex Gamma approximation (2015). http://my.fit.edu/~gabdo/gamma.txt 3. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt (1981) 4. Press, W.H., Flannery, B.P., Teukolsky, S.A., Vetterling, W.T.: Numerical Recipes in Fortran 77. Cambridge University Press, Cambridge (1986) 5. Pugh, G.R.: An Analysis of the Lanczos Gamma Approximation. Thesis, The University of British Columbia (2004)
2
Error Functions and Fresnel Integrals
Abstract
Topic of this chapter is the evaluation of the error function, the Fresnel functions, and some related functions, like the Dawson integral and the Voigt profile functions in the complex domain. The computation is based on the incomplete gamma function, and thus various numerical techniques are used in dependence of the function arguments. The corresponding programming code is freely available.
In this chapter, we will discuss the error functions, the Fresnel integrals, and some related functions. Applications occur in a variety of physical applications, e.g., in the solutions of diffusion problems, probability theory, the analysis of the diffraction of light, in quest of plasma dispersion, or in spectral line profiles. First, we start with a listed overview of relevant MATLAB and SPECFUNPHYS functions.
2.1
Function Overview
Error functions: • erf and erfc are MATLAB functions to compute the error function and complementary error function. Both are restricted to real values. • The SPECFUNPHYS class erfComp allows the computation of the error and complementary error function in the complex domain. • The inverse of the error functions is only unique in the real domain and can be computed with the MATLAB functions erfinv and erfcinv. Dawson integral: The SPECFUNPHYS class dawsonC returns the Dawson integral or function. © The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_2
23
24
2 Error Functions and Fresnel Integrals
Voigt profile: The SPECFUNPHYS class voigt computes the Voigt functions and the line broadening function. Fresnel integral: The SPECFUNPHYS class fresnel evaluates various Fresnel integral functions in the complex domain.
2.2
Error Functions
2.2.1
Fundamental Equations and Computation
The error function erf, Fig. 2.1, and complementary error function erfc [1, 3] equal 2 erf(z) = √ π 2 erfc(z) = √ π
z
exp(−t 2 )dt
(2.1a)
0 ∞
exp(−t 2 )dt .
(2.1b)
z
5
1800 1600
4
1400 1200
3
1000 800
3
600 400
1
200 0
0 -3
2
3
2
-2
-1 -1
0
1
real
-2 imag 2
3
-3
2 1 0 -3
1 0 -2
-1 -1
0
1
real
-2 imag 2
3
-3
Fig. 2.1 Absolute value of the error function erf(z) in the complex plane. Please note, for z = ±3i, the absolute value | erf(z)| is of the order 109 , which is hidden due to the finite plot resolution. On the right-hand side, the maximum plot value of | erf(z)| is restricted to 5 to uncover the structure of the lower values
2.2 Error Functions
25
With z ∈ C, both functions are defined in the complex domain and they are entire functions. These functions fulfill the following symmetry relations: erf(−z) = − erf(z) erfc(−z) = 2 − erfc(z) erf(¯z) = erf(z),
(2.2a) (2.2b) (2.2c)
and thus erf is an odd function. Special values are erf(0) = 0, erf(∞) = 1, erfc(0) = 1, and erfc(∞) = 0.
(2.3)
The derivatives of the error function hold 2 d n+1 erf(z) = (−1)n √ Hn (z) exp(−z2 ), n ∈ N, n+1 dz π
(2.4)
where Hn (z) are the Hermite polynomials. The error functions are related to the incomplete gamma functions [4], Chap. 1.5, via
1 1 2 ,z erf(z) = prefactor · √ γ (2.5a) 2 π
1 1 2 erfc(z) = prefactor · √ Γ ,z . (2.5b) 2 π These equations are in [4] without the prefactor and thus hold only if (z) > 0, which is obvious due to the symmetry relations. For example, erf is an odd function, whereas Eq. (2.5a) leads to an even function without prefactor. With ⎧ ⎪ −1 ⎪ ⎪ ⎪ ⎪ ⎨ +1 prefactor = −1 ⎪ ⎪ ⎪ +1 ⎪ ⎪ ⎩ 0
: : : : :
(z) < 0 (z) > 0 (z) = 0 ∧ (z) < 0 (z) = 0 ∧ (z) > 0 (z) = 0 ∧ (z) = 0,
(2.6)
Equations (2.5a) and (2.5b) hold in the entire complex domain. Hence, the computation is based on the incomplete gamma functions. (See Chap. 1.5 for details.)
26
2 Error Functions and Fresnel Integrals
2.2.2
erfComp and Applications
The Class erfComp MATLAB comes with the functions erf and erfc for the error and complementary error function. Both are restricted to real numbers. The SPECFUNPHYS class [obj, erg] = erfComp(z,lu,nm) evaluates the error function or complementary error function in the complex plane. “z” could be an arbitrary complex array. All other variables are optional. “lu” has the values of “erf” (default, error function) or “erfc” for computing the complementary error function. The computation is based on the corresponding incomplete gamma function. Thus, see Chap. 1.5 for details, “nm” (optional) is the upper bound of summations for series based computations. The default value depends on |z| to avoid overflow with a maximum number of 500. The default depth is 10 for the continued fraction (10th-approximant). The object “obj” comes with the properties, value (function value), info (information about computational method used and if the error or complementary error function was computed), and inz (numerical input z), and “erg” is the computational value in doubles. erfComp supports the following methods: “abs” for computing the absolute value, “real” for the real and “imag” for the imaginary value, “angle” for the phase angle in radians, and “conj” for the complex conjugate value. Each of the methods can be applied either on the results (value, default) or on the input variables z (inz). As an example, Fig. 2.1 was created by x = linspace(-3,3,50); % Input Data [X,Y] = meshgrid(x,x); Z = X+i*Y; obj = erfComp(Z); % error function % a = 20.5; e = 37.2; % azimuth and elevation: surf % Cz = obj.abs; % absolute value % figure % visualization subplot(1,2,1) surf(X,Y,Cz), view(a,e), xlabel(’real’), ylabel(’imag’) subplot(1,2,2) surf(X,Y,Cz,X.*Y),zlim([0,5]), view(a,e) xlabel(’real’), ylabel(’imag’)
2.2 Error Functions
27
Examples
Every measurement is uncertain to some degree. If there are no systematic errors, the distribution of measurements follows a normal distribution. The probability of an error of measurements is given by the Gaussian error integral 2
x 1 t Φ(x) = √ exp − dt (2.7) 2 2π −∞ or cumulative distribution function of a normal distribution. The relationship between this function and the error function is given by
z 1 1 + . Φ(z) = erf √ 2 2 2
(2.8)
An example for solving the heat equation with the error function can be found in the MATLAB documentation. As an additional example, consider the problem of diffusion in a semi-finite medium, x > 0, when the boundary is kept at a constant concentration C0 and the initial concentration is zero throughout the medium [2]. Therefore, we need a solution of ∂ 2C ∂C =D· ∂t ∂x 2
(2.9)
with the boundary condition C = C0 for x = 0, t > 0 and the initial condition C = 0 for x > 0, t = 0. The concentration is then given by C(x, t) = C0 erfc
x √ 2 Dt
.
(2.10)
The result is plotted in Fig. 2.2. Figure 2.2 was computed by x = linspace(0,1,50); % x ccordinate Dt = linspace(0,10,50); % D scaled time [X,DT] = meshgrid(x,Dt); Z = X./sqrt(DT); [obj, res] = erfComp(Z,’erfc’); % concentration res(1,:) = 0; % initial condition res(1,1) = 1; % boundary condition figure % visualization pcolor(X,DT,res), colorbar shading interp, xlabel(’x’), ylabel(’Dt’),shg
Dawson Integral The Dawson integral or function is given by F (z) = exp(−z2 ) 0
z
exp(t 2 )dt
(2.11)
28
2 Error Functions and Fresnel Integrals
Dt
10
1
9
0.9
8
0.8
7
0.7
6
0.6
5
0.5
4
0.4
3
0.3
2
0.2
1
0.1
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0
x
Fig. 2.2 Color coded concentration C/C0 for diffusion in a semi-finite medium. Horizontal, the space coordinate x, and vertical, the scaled time D · t
and is the solution of the differential equation dF (x) + 2x F (x) = 1 dx
(2.12)
with initial condition F (0) = 1. The Dawson integral is closely related to the error function √ i π F (z) = − exp(−z2 ) erf(iz), (2.13) 2 and its computation is based on this equation. The SPECFUNPHYS class [obj, erg] = dawsonC(z) computes the Dawson integral or function in the complex plane. “z” could be an arbitrary complex array. The computation is based on Eq. (2.13). The object “obj” comes with the properties, value (function value), info (information about computational method), and inz (numerical input z), and “erg” is the computational value in doubles. The class dawsonC supports the same methods as erfComp.
2.3
Voigt Profile
The Voigt profile is a spectral line profile resulting from the convolution of a Gaussian profile and a Lorentzian profile. The Gaussian profile is due to Doppler
2.3 Voigt Profile
29
broadening and the Lorentzian due to natural broadening. The Voigt functions are given by
1
U (x, t) = √ 4πt
−∞
1
∞
V (x, t) = √ 4πt
∞ −∞
2 exp − (x−y) 4t
dy 1 + y2 2 y exp − (x−y) 4t dy, x ∈ R, t > 0, 2 1+y
(2.14a)
(2.14b)
and the line broadening function [5] a H (a, u) = π
∞
exp(−t 2 ) dt, (u − t)2 + a 2
(2.14c)
√ ν − ν0 u = 2 ln2 . δνD
(2.14d)
−∞
with a=
√ ln2δνL , δνD
ν is the frequency, ν0 the central frequency of the Gaussian, δνD the full width half maximum (FWHM) due to the Doppler broadening, and δνL the FWHM of the Lorentzian. The Voigt functions are connected [4] as follows: U (x, t) + iV (x, t) =
π 1 − ix exp(z2 ) erfc(z), with z = √ . 4t 2 t
(2.15)
Some results are plotted in Fig. 2.3. The line broadening function is given by 1 H (a, u) = √ U a π
0.8
u 1 , . a 4a 2
(2.16)
0.4
0.6
0.3
V
U
0.4 0.2
0.2 0.1
0
5
x
10
15
0
0
5
x
10
15
Fig. 2.3 On the left-hand side, the Voigt function U (x, t), and on the right-hand side, V (x, t), with t equal to 0.1, 1, 2.5, 5, and 10 from top to bottom
30
2 Error Functions and Fresnel Integrals
The class [obj, ergU, ergV, ergH] = voigt(x,t) computes the Voigt functions and the line broadening function based on Eq. (2.15). The input variables “x, t” have to be on the same size or scalars with “x” real and “t” positive definite. The object “obj” has the properties “resU” (value of Voigt function U), “resV” (Voigt function V), “resH” (line broadening function), “info” (computational method), “inx” (numerical Input x), “int” (numerical Input t), “a” (H function argument), and “u” (H function argument). “ergU,” “ergV,” and “ergH” are the values of the corresponding functions in doubles. As an example, Fig. 2.3 was computed via %% tl=[0.1,1,2.5,5,10]; % Data x = linspace(0,15); x = x(:); ergUpl = []; ergVpl = []; for t=tl % computation [obj, ergU, ergV, ergH] = voigt(x,t); ergUpl = [ergUpl,ergU]; ergVpl = [ergVpl,ergV]; end %% Visualization subplot(1,2,1) plot(x,ergUpl) xlabel(’x’),ylabel(’U’) subplot(1,2,2) plot(x,ergVpl) xlabel(’x’),ylabel(’V’)
2.4
Fresnel Integrals
The Fresnel integrals are entire functions in the complex area and arise in the approximative description of the near-field Fresnel diffraction phenomena. The Fresnel integrals [1] are defined as
1 2 πit dt exp FF (z) = 2 z
z 1 2 C(z) = πt dt cos 2 0
z 1 2 S(z) = πt dt. sin 2 0
∞
(2.17a) (2.17b) (2.17c)
C(z) is called the Fresnel cosine integral function and S(z) the Fresnel sine integral function. In the literature, e.g., in [3], there are minor differences in the definition, which might necessitate to scale the functional argument and the integral value. The definition above follows [1]. The Fresnel integrals are closely related to the error
References
31 0.8 0.6 0.4 0.2
S(x)
Fig. 2.4 The cornu spiral is a parametric plot of the Fresnel integrals with axes (X, Y ) = (C(x), S(x)). The spiral converges to (±0.5, ±0.5) for x ⇒ ±∞
0 -0.2 -0.4 -0.6 -0.8 -0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
C(x)
function
1√ 1 C(z) ± iS(z) = (1 ± i) · erf π(1 ∓ i)z , 2 2
(2.18)
where either all upper or all lower signs are taken throughout. The exp-integral equals FF (z) =
1 (1 + i) − (C(z) + iS(z)) . 2
(2.19)
The SPECFUNPHYS class [obj, esin, ecos, eexp] = fresnel(z) computes the Fresnel integrals Ff , C, and S in the complex domain. “z” could be an arbitrary complex array. The computation is based on Eq. (2.18). The object “obj” comes with the properties “fsin” (value of the Fresnel sine function), “fcos” (value of the Fresnel cosine function), “fexp” (value of the Fresnel exp function), “infop” (computational method used for upper track), “infon” (computational method used for the lower track), and “inz” (the numerical input z). “esin, ecos, eexp” are the computational value in doubles of the Fresnel sine, cosine, and exp functions. The class fresnel supports the same methods as erfComp. As an example, we show in Fig. 2.4 the cornu spiral. The cornu spiral was computed via x = linspace(-4,4,500); [~, esin, ecos] = fresnel(x); plot(ecos,esin,’k’) % Cornu spiral xlabel(’C(x)’), ylabel(’S(x)’),shg
References 1. Abramowitz, M., and Stegun, I.A.: Handbook of Mathematical Functions. Dover Pub., New York (1972)
32
2 Error Functions and Fresnel Integrals
2. Crank, J.: The Mathematics of Diffusion. Clarendon Press, Oxford (1975) 3. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt (1981) 4. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders B.V. (eds.): NIST Digital Library of Mathematical Functions. http://dlmf. nist.gov, Rel. 1.0.17 (2017) 5. Thorne, A.P.: Spectrophysics. Chapman and Hall, London (1988)
Legendre Polynomials and Legendre Functions
Abstract
Legendre polynomials and, respectively, Legendre functions are one of the most important functions in physics. In this chapter, we will discuss and derive corresponding program codes supporting complex arguments and complex indices. The code is freely available. The functions covered are Legendre polynomials and Legendre functions of first and second kind, the evaluation of the nodes for the Legendre functions of first kind based on the corresponding Jacobi matrix, the Mehler or conical functions, the toroidal or ring functions, and others. An application is, e.g., the evaluation of spherical harmonics. In dependence of the function arguments and the function indices, the evaluation will be based either on recurrence relations or on hypergeometric functions.
Topic of this chapter are Legendre polynomials and Legendre functions and related functions in the real and complex domains. Legendre functions play an important role in many areas in physics, e.g., in electrodynamics in solving the Laplace equation in spherical coordinates, in quantum dynamics with respect to spherical harmonics, Legendre functions with complex degrees in scattering theory, and so forth. In the next chapter, we will list relevant functions, followed by chapters about Legendre polynomials and Legendre functions. In Chap. 4, we will discuss complex indices, the Mehler functions, and the toroidal functions.
3.1
Function Overview
Legendre polynomial: • The MATLAB function P = legendre(n,x) computes the associate Legendre functions of degree n and order m = 0 · · · n. © The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_3
33
3
34
3 Legendre Polynomials and Legendre Functions
• The SPECFUNPHYS class legendrepoly returns the polynomial coefficients of the Legendre polynomials based on Eq. (3.5) and comes with methods, e.g., to plot the polynomials and compute the corresponding values. • legendre2poly returns the polynomial coefficients of the Legendre functions Qn of second kind and has some additional methods for computing and visualizing Qn . • The SPECFUNPHYS class Pl0 allows to compute directly the values of the Legendre polynomial of degree n of first kind and second kind based on Eq. (3.5). • The SPECFUNPHYS function JacobiPl returns the nodes of the Legendre polynomials of first kind based on a Jacobi matrix ansatz. Associate Legendre function of integer indices: • The SPECFUNPHYS function JacobiPlm returns the nodes of the associate Legendre functions of first kind based on a Jacobi matrix ansatz. • The SPECFUNPHYS class legendrefun returns the polynomial structure of the associate Legendre function of first kind and allows via additional methods the computation of functions values and supports plotting. • The SPECFUNPHYS class Plm returns directly the values of the associate Legendre function. Spherical harmonics: The SPECFUNPHYS function Ylm = shfun(l,m,theta,phi) returns the values of the spherical harmonic Ylm (θ, φ), and plotsh(l,m,ax) creates a surface plot of Ylm . Functions with complex indices: • The SPECFUNPHYS class [obj, resa] = mehlerfun(tauin,muin,z,PorQ) returns the function values of the Mehler or conical function of first and second kind and supports additional methods like line and surface plots via the superclass PQnumu, see PQnumufun. • The SPECFUNPHYS class [obj, resa] = toroidalfun(tauin, muin,z,PorQ) allows the computation of the toroidal or ring function. Additional methods are supported via the superclass PQnumu, see PQnumufun. • Legendre functions of first and second kind with arbitrary complex indices and arguments can be computed with the SPECFUNPHYS class [obj, resa] = PQnumufun(nuin,muin,z,PorQ). PQnumufun supports the following additional methods (via superclass PQnumu): computing the absolute function value of an object (abs(obj)), the real part of the function value (real(obj)), the phase angle of the function value (angle(obj,dr)), answering the logical question isreal(obj), and isrealsingle(obj,tol) for taking care of the finite accuracy of the computation tolerance, and it supports line plots with the overloaded method plot and surface plots with the overloaded method surf.
3.2 Legendre Polynomials
35
• Oblate spheroidal functions can be computed via the function RTnm or with the method RTnm of PQnumufun.
3.2
Legendre Polynomials
In this section, we will discuss Legendre polynomials Pn and, respectively, Legendre functions of integer degree and zero order, and order zero Legendre functions Qn of second kind. Qn are strictly spoken no polynomials. Some examples are plotted in Fig. 3.1. The Legendre differential equation is d d (1 − x 2 ) y + n(n + 1)y = 0 dx dx
with n ∈ N .
(3.1)
Its solution is single valued, finite, and continuous for −1 ≤ x ≤ +1. The general solution is given by y = a · Pn (x) + b · Qn (x), with Pn the Legendre polynomials. The Legendre polynomials are defined by Rodrigues’ formula Pn (x) =
1
n 1 dn 2 x − 1 , 2n n! dx n
(3.2)
0
2
polynomial
0.5
1
3
1
0
2
3
4 5
0 5 4
-1
-0.5
2
1
-1 -1
-2 -0.5
0
x
0.5
1
-1
0
-0.5
0
x
0.5
1
4
polynomial
Q0
P3
P2
2 P0
0 Q3 Q2
-2 -1
-0.5
0
0.5
x
1
1.5
2
Fig. 3.1 Legendre polynomials of first and second kinds. Left-hand side top: Legendre polynomials of first kind. Solid line: P0 and P3 , dashed line: P1 and P4 , and dotted line: P2 and P5 . Right-hand side top: Legendre polynomials of second kind. Solid line: Q0 and Q3 , dashed line: Q1 and Q4 , and dotted line: Q2 and Q5 . Bottom: Various Legendre polynomials of first (P) and second (Q) kinds from −1 ≤ x ≤ 2. All lines are labeled with the degree
36
3 Legendre Polynomials and Legendre Functions
where x could be real or complex. The Legendre polynomials can be derived from the generating function ∞
1 = Pn (x)hn , √ 2 1 − 2xh + h n=0
(3.3)
which comes historically from the expansion of the gravitational potential 1/r, with r the distance. The Legendre polynomials are orthogonal on the interval −1 ≤ x ≤ +1:
1 −1
Pm (x)Pn (x) =
2 δnm 2n + 1
(3.4)
and fulfill the following recurrence formula: (n + 1)Pn+1 (x) = (2n + 1)xPn (x) − nPn−1 (x) .
(3.5)
This equation, together with P0 (x) = 1 and P1 = x, allows to generate recursively the Legendre polynomial coefficients for up to n ≈ 25. The Class Legendrepoly The Legendre polynomial coefficients up to order n can be computed with [obj, P] = legendrepoly(n). “n” is the highest polynomial order, “obj” an object of the class legendrepoly, with the properties, “polycoef” a table of the polynomial coefficients, “polynorm” the corresponding vector of the norm, and “polyint” the normalization interval ([−1, +1]), and “info” here Legendre polynomial. “P” is an array of polynomial coefficients. The rows are the coefficients of the Legendre polynomial in descending powers of the polynomial. The SPECFUNPHYS class legendrepoly comes with the methods of the superclass polymeth, see also Chap. 15. Example >> format rat >> [obj, P] = legendrepoly(6) obj = legendrepoly with properties: polycoef: polynorm: polyint: info:
[7x7 table] [7x1 double] [-1 1] ’Legendre Polynomial’
P = 0 0 0
0 0 0
0 0 0
0 0 0
0 0 3/2
0 1 0
1 0 -1/2
3.2 Legendre Polynomials 0 0 0 231/16
37
0 0 5/2 0 35/8 0 63/8 0 -35/4 0 -315/16 0
0 -3/2 -15/4 0 0 15/8 105/16 0
0 3/8 0 -5/16
For example, the fifth row corresponds to the Legendre polynomial P4 (x) = 35 4 15 2 3 8 x − 4 x + 8 . “obj.polycoef” shows the same result as the table. The Methods The plot-method can be used via plot(obj,varargin). The first input is the class object. All other inputs are optional. The second input (integer vector) are the orders of the polynomials that shall be plotted. The maximum number is given by the class object. The default is to plot all corresponding polynomials of the class object. The third input gives the plot region. The default value is “obj.polyint.” The forth input is the axes handle object in which the result should be plotted. The default is to open a new figure environment. An example is Fig. 3.1. The deri-method Pder=deri(obj,n) returns the n-th derivative of the Legendre polynomials represented by “obj.” “Pder” is a table with the polynomial coefficients. The polyvalue-method [res, n] = polyvalue(obj,x,n) computes the values of the polynomials. “obj” is the class object, and all other inputs are optional. “x” is a vector, and polyval evaluates the polynomial at each element of “x.” The default values are 50 elements with interval limits given by obj.polyint. “n” is an integer value of the table rows which should be evaluated (default is all). For additional methods, see Chap. 15. Some Special Results The first Legendre polynomials are listed below: P0 (x) = 1
1 2 3x − 1 2 1 P4 (x) = 35x 4 − 30x 2 + 3 8 P2 (x) =
P1 (x) = x
1 3 5x − 3x 2 1 P5 (x) = 63x 5 − 70x 3 + 15x . 8 P3 (x) =
38
3 Legendre Polynomials and Legendre Functions
P2n are even and P2n+1 are odd polynomials. Some special results are P2n (0) =
(−1)n Γ (n + 1/2) √ πΓ (n + 1)
Pn (−1) = (−1)n P2n+1 (0) = 0 Pn (1) = 1 , and |Pn (x)| ≤ 1 for − 1 ≤ x ≤ 1 . Zero Order Legendre Functions of Second Kind As already mentioned, a general solution of the Legendre differential equation (3.1) is given by a linear combination of Legendre polynomials P and Legendre functions Q of second kind. The functions Qn are given by 1 1+x Pn (x) ln − Wn−1 (x) for − 1 ≤ x ≤ 1 2 1−x 1 z+1 − Wn−1 (z) , Qn (z) = Pn (z) ln 2 z−1
Qn (x) =
(3.6a) (3.6b)
with Wn−1 (x) =
n 1 k=1
k
Pk−1 (x)Pn−k (x) .
W is a solution of the differential equation [3], (1 − x 2 )
d 2 Wn−1 dWn−1 dPn (x) + (n + 1)nWn−1 − 2 =0. − 2x 2 dx dx dx
The first few functions are listed below: 1 1+x P0 (x) ln 2 1−x 1 1+x −1 Q1 (x) = P1 (x) ln 2 1−x Q0 (x) =
3 1 1+x P2 (x) ln − x 2 1−x 2 5 1 1+x 2 Q3 (x) = P3 (x) ln − x2 + . 2 1−x 2 3
Q2 (x) =
(3.6c)
3.2 Legendre Polynomials
39
x+1 These equations hold for −1 ≤ x ≤ 1, otherwise ln 1+x 1−x becomes ln x−1 . The functions Q hold the same recurrence relations as P , especially Eq. (3.5). Therefore, again the computation of the polynomial coefficients will be based on recurrence formula (3.5). Results are shown in Fig. 3.1.
The Class Legendre2poly The polynomial coefficients necessary to evaluate Eq. (3.6a) can be computed via [obj, Qln, Qpl] = legendre2poly(n). The class object comes with the properties “polycoefln” a table of the Legendre polynomial coefficients (Qln), “polycoefpl” the table of the polynomial coefficients (Qpl) for the additional Wpart, “polyint” a predefined interval [−1, +1], and “info” with the value of the “Legendre Function of Second Kind.” The class comes in addition with the method [res, n] = Qvalue(obj,x,n) to compute the functional value at points x. “obj” is the class object, and all other input variables are optional. “x” is an arbitrary vector, and default is x ∈ [−1, +1]. “n” is an integer vector at which Qn should be computed. The method plot(obj,n,x,ax) plots the corresponding functions. “obj” is the class object. All other input variables are optional. “n” is an integer vector at which Qn should be plotted; default is all. “x” the region about which the functions should be plotted with default −1 · · · + 1, and “ax” the axes handle which should be used for the plot. Example
The following example lists the code of plot, Fig. 3.1: % Visualization of Legendre Polynomials legendrepoly(5).plot % method of polymeth class ax1 = gca; subplot(2,2,1,ax1) hold on % generating the objects objQ=legendre2poly(5); objP=legendrepoly(5); % visualization ax2 = subplot(2,2,2); x = linspace(-1,1); n = 0:5; plot(objQ,n,x,ax2) % calling the plot-method hold on % ax3 = subplot(2,2,3:4) x = linspace(-1,2,200); n = [0,2,3]; plot(objP,n,x,ax3) % method of polymeth class hold on plot(objQ,n,x,ax3) % method of legendre2poly class ylim([-2,4])
40
3 Legendre Polynomials and Legendre Functions
Direct Computation For evaluating the Legendre polynomials, the methods polyvalue and, respectively, Qvalue are used. Both are based on the MATLAB function polyval. Arithmetic among numbers in floating point representation is not exact. (Only arithmetic in integer representation is exact.) Any arithmetic operation among floating numbers will cause a round-off error. The polynomial representation of Legendre polynomials uncovers best their structure. But firstly, to derive the Legendre polynomial and then to evaluate this Legendre polynomial at position x will be less accurate than the direct evaluation based on the recurrence relation (3.5). Figure 3.2 shows the relative deviation between the direct computation based on the recurrence relation (3.5) and the evaluation of the corresponding Legendre polynomial. The class Pl0 evaluates the polynomial values of the Legendre polynomial of first kind and second kind based on Eq. (3.5). Starting point of the computation are the values for l = 0 and l = 1. The syntax to compute the polynomial values is obj = Pl0(l,x,w), e.g., y = Pl0(23,randn(2,3),3).value. “l” is the degree of the Legendre polynomial, “x” an arbitrary complex array of type double at which the polynomials will be evaluated, and “w” (optional) if the Legendre polynomials of 1st kind (default, w = 1) will be computed or second kind (w = 2) or both (w = 3). y = Pl0(...).value returns a structure with fields “P00” to “Pl0” and/or “Q00” to “Ql0” containing the corresponding polynomial values with the same array structure as “x”; “obj” is the object of the class Pl0 with property “y.” An application example (partial wave expansion in Coulomb scattering) can be found in Sect. 7.3.1. Nodes of the Legendre Polynomials √ By orthonormalizing the Legendre polynomials, Eq. (3.4), Pl → (2l + 1)/2Pl = P˜l , we arrive at the recurrence relation
Fig. 3.2 Relative deviation Δrel between the computation based on the recurrence relation (3.5) and the evaluation of the corresponding Legendre polynomial for P25,28,31,34,37(x) and P40 (x) for −1 ≤ x ≤ 1
2l + 1 ˜ l Pl+1 + 2l + 3 2l + 1
2l + 1 ˜ Pl−1 , 2l − 1
(3.7)
100 40
10
-5
rel
l+1 x P˜l (x) = 2l + 1
37 34 31 28 25
10-10
10-15
10 -20 -1
-0.8
-0.6
-0.4
-0.2
0 x 0.2
0.4
0.6
0.8
1
3.3 Legendre Functions of Integer Type
41
from which we can derive directly the Jacobi matrix, see Chap. 15, √ 1/3 0 0 0 √ √ ⎜ 1/3 0 2 1/15 0 ⎜ √ √ JP = ⎜ 1/15 0 3 1/35 0 2 ⎝ .. .. .. .. . . . . ⎛
⎞ 0 ··· 0 ···⎟ ⎟ 0 ···⎟ ⎠ . . .. ..
(3.8)
to compute the zeros of the Legendre polynomial of first kind. The nodes of the Legendre polynomials are given by the eigenvalues of the corresponding Jacobi matrix. Computing the nodes via eigenvalues is significantly more accurate than computing the roots of the corresponding polynomials. The zeros “x0” of the Legendre polynomial are returned by the tiny program x0 = JacobiPl(l) with “l” the degree.
3.3
Legendre Functions of Integer Type
Associate Legendre functions of integer degree and integer order as well as spherical harmonics play an important role in many areas in physics. For example, solutions of the Laplace equation in spherical coordinates (23.5, 23.6b) can be written as < r, θ, φ|Ψ >=
∞ l
alm r l + blm r −(l+1) Ylm (θ, φ),
(3.9a)
l=0 m=−l
and in case of cylindrical symmetry, it simplifies to < r, θ |Ψ >=
∞
al r l + bl r −(l+1) Pl (cos θ ) ,
(3.9b)
l=0
with a and b complex constants. Legendre polynomials Pl have been discussed in the last chapter. The θ -part of the spherical harmonics is given by the associate Legendre functions. In the next two subsections, we will first discuss the associate Legendre functions and as an application the spherical harmonics and in the next section associate Legendre functions of first and second kinds with complex indices. The conventions used are • • • • •
x ∈ R, −1 ≤ x ≤ 1 cos(θ ) − π ≤ θ ≤ π z∈C indices n, l, m ∈ Z indices ν, μ ∈ C.
42
3 Legendre Polynomials and Legendre Functions
3.3.1
Fundamental Equations and Computation
The associate Legendre functions are the solutions of the Legendre equation ! μ2 d2 d (1 − z ) 2 − 2z + ν(ν + 1) − y(z) = 0, dz dz 1 − z2 2
(3.10)
where the indices “ν” and “μ” are referred to as the degree and order. For μ = 0 and ν = l integer, these functions are identical to the Legendre polynomials. For −1 ≤ x ≤ +1, and ν = l, μ = m integers with 0 ≤ |m| ≤ l, these functions are nonsingular and can be derived from the Legendre polynomials via Plm (x) = (−1)m (1 − x 2 )m/2
dm Pl (x) , and dx m
Plm (z) = (z2 − 1)m/2
dm Pl (z) . dzm
(3.11a)
(3.11b)
Identical equations hold for the Legendre functions Qm l of second kind (P ↔ Q). μ Qν will be discussed in the next chapter. The following relations between positive and negative orders are computationally useful: Pl−m (x) = (−1)m
(l − m)! m Γ (ν − m + 1) m P (x) , Pν−m (x) = (−1)m P (x) (l + m)! l Γ (ν + m + 1) ν
Γ (ν − μ + 1) 2 −μ μ μ Pν (z) = P (z) − exp(−iμπ) sin(μπ)Qν (z) Γ (ν + μ + 1) ν π Γ (ν − μ + 1) 2 −μ μ μ cos(μπ)Pν (x) − sin(μπ)Qν (x) Pν (x) = Γ (ν + μ + 1) π μ
μ
P−ν−1 (z) = Pνμ (z), P−ν−1 (x) = Pνμ (x) Q−μ ν (z) = exp(−2μπi) m Q−m ν (x) = (−1)
Γ (ν − μ + 1) μ Q (z) Γ (ν + μ + 1) ν
Γ (ν − m + 1) m Q (x). Γ (ν + m + 1) ν
(3.12a) (3.12b) (3.12c) (3.12d) (3.12e) (3.12f)
3.3 Legendre Functions of Integer Type
43
For 0 ≤ m ≤ l, the associate Legendre functions satisfy the following orthogonality condition:
+1 −1
Pkm (x) Plm (x)dx =
2(l + m)! δk,l , (2l + 1)(l − m)!
(3.13)
−1 Nlm
which allows, similar to Eq. (3.7), to define normalized Legendre functions Plm (x) → Nlm Plm (x) and to compute the corresponding zeros. The nodes of the associate Legendre function Plm (x) are evaluated with the function Nu = JacobiPlm(l,m). The computation is based on the eigenvalues of the corresponding Jacobi matrix, Eq. (15.6). For m = 0, the associate Legendre function carries an additional factor (1 − x 2)m/2 , and thus the zeros at position x = (−1, +1) are added. The first few associate Legendre functions are P00 (x) = 1 1 P1−1 (x) = − P11 (x) , 2 P2−2 (x) =
P10 (x) = x ,
(3.14) " P11 (x) = − 1 − x 2
(3.15)
1 2 P (x) , 24 2
1 1 P2−1 (x) = − P21 , P20 (x) = (3x 2 − 1) 6 2 " (3.16) P21 (x) = −3x 1 − x 2 , P22 (x) = 3(1 − x 2 ).
The associate Legendre functions Plm (x) can be built by a prefactor (−1)m (1 − x 2 )m/2 multiplied with a polynomial. These polynomials will be uncovered by the class legendrefun, [obj, P] = legendrefun(l,m). The input parameters “l,m” are the degree and order of the associate Legendre function Plm . The class object “obj” comes with the properties, “polycoef,” a table of the polynomial coefficients for all allowed degrees l l
(3.18a)
and Pmm (x) = (−1)m (2m − 1)!!(1 − x 2 )(m/2) , m (x) = x(2m + 1)Pmm (x) , Pm+1
Pmm (z) = (2m − 1)!!(z2 − 1)(m/2) , (3.18b)
m Pm+1 (z) = z(2m + 1)Pmm (z).
(3.18c)
The class Plm serves for the direct computation of values of the associate Legendre function. obj = Plm(l,m,x) returns the class object “obj” with the property “values” with all function values of P ˜m (x) for |m| ≤ l˜ ≤ l, the property “x” at l which the associate Legendre functions were evaluated and “lm” with the list of corresponding (lm)-pairs. Example: >> x = [0, 0.25, 0.5, 0.75, 1.0 0,-0.25,-0.5,-0.75,-1.0]; >> res = Plm(4,2,x).value res = struct with fields:
3.3 Legendre Functions of Integer Type
45
P42: [2x5 double] P32: [2x5 double] P22: [2x5 double] >> res.P42 ans = -7.5000 -7.5000
-3.9551 -3.9551
4.2188 4.2188
9.6387 9.6387
0 0
>> res.P32 ans = 0 0
3.5156 -3.5156
5.6250 -5.6250
4.9219 -4.9219
0 0
3.3.2
Application: Spherical Harmonics
The spherical harmonics of degree l and order m # Ylm (θ, φ)
= (−1)
m
(2l + 1)(l − m)! m Pl (cos θ ) exp(imφ) 4π(l + m)!
(3.19)
are the solution of the Laplace–Beltrami operator (23.6b) in spherical coordinates (23.5). The spherical harmonics are normalized
Ylm (θ, φ)Ylm (θ, φ)dΩ = δl,l δm,m
(3.20)
with dΩ = sin θ dθ dφ and hold Yl−m (θ, φ) = (−1)m Ylm (θ, φ)∗ ,
(3.21)
with ∗ the complex conjugate. Due to Eq. (3.19), their computation is straightforward. The function Ylm = shfun(l,m, theta,phi) returns the values of a spherical harmonic Ylm (θ, φ) by calling the class Plm. The input parameters “l,m” are integers, and the angles “theta” and “phi” are vectors. The output “Ylm” is a two dimensional array with φ fixed for each row and, respectively, θ in each column. The function [Ylm, Xout, Yout, Zout] = plotsh(l,m,ax) plots the absolute value of spherical harmonics in a spherical representation, see Fig. 3.3. The computation is based on the class legendrefun. “l,m” are the degree and order and scalar integers. The axes object “ax” (optional) specifies the axes for plotting. All output values are optional and complex (“Ylm”) or real 2D arrays. For example, >> surf(abs(Ylm).*X,abs(Ylm).*Y,abs(Ylm).*Z) would create a figure similar to Fig. 3.3.
46
3 Legendre Polynomials and Legendre Functions
Fig. 3.3 Absolute value of the spherical harmonic Y31 in a polar representation. The distance to the coordinate origin is proportional to |Ylm |
3.4
Associate Legendre Functions with Complex Indices
In this chapter, we will discuss the associate Legendre functions of first and second kinds with complex indices. We will start with some fundamental equations necessary for its computation. As first step, we will introduce computational techniques for evaluating the conical or Mehler functions, followed by a discussion of the toroidal or ring functions before we turn to arbitrary Legendre functions.
3.4.1
Fundamental Equations
The computations will be based on various series expansions via hypergeometric functions, on recurrence relations, and directly solving corresponding differential equations. Thus, we will start with the representation of the associate Legendre functions in terms of hypergeometric series. It is common convention for associate Legendre functions in [1] and in many other publications to set (z2 − 1)α := (z + 1)α (z − 1)α
(3.22a)
and not explicitly to distinguish between
z+1 z−1
μ/2
→
1+x 1−x
μ/2 with − 1 ≤ x ≤ +1 .
(3.22b)
I will nevertheless mainly avoid this convention for clarification. The associate Legendre function is related to the hypergeometric function Pνμ (z) =
1 Γ (1 − μ)
z+1 z−1
μ/2
1−z F −ν, ν + 1; 1 − μ; , (3.23a) 2 1 2
with |1 − z| < 2 and
1 + x μ/2 1−x 1 μ , (3.23b) −ν, ν + 1; 1 − μ; (x) = F Pν 2 1 Γ (1 − μ) 1 − x 2
3.4 Associate Legendre Functions with Complex Indices
47
for |x| < 1. Based on the transformation formulas (8.3), the following equations can be derived to go, e.g., beyond the restriction for z above. Pνμ (z)
1 1 + x μ/2 1 + z −μ z + 1 μ/2 = resp. z→x Γ (1 − μ) 2 z−1 1−x
1 − z 1−z < 1. (3.23c) × 2 F1 1 − μ + ν, −μ − ν; 1 − μ; , 2 2
For certain values of ν and μ, this series could become finite, e.g., for μ half-integer in case of conical functions. Pνμ (z)
z + 1 μ/2 Γ (−μ) 1+z = 2 F1 −ν, ν + 1; 1 + μ; z−1 Γ (1 − μ + ν)Γ (−μ − ν) 2
$ 1 + z −μ 1+z Γ (μ) + 2 F1 1 − μ + ν, −μ − ν; 1 − μ; 2 Γ (1 + ν)Γ (−ν) 2 |1 + z| < 2 ,
resp.
1+x 1−x
μ/2 z→x;
(3.23d)
note that this series will diverge if μ becomes a positive or negative integer. Pνμ (z) =
2−ν−1 Γ (− 12 − ν)z−ν+μ−1 √ (z − 1)μ/2 (z + 1)μ/2 π Γ (−ν − μ)
ν −μ 3 −2 1+ν −μ ,1 + ;ν + ;z × 2 F1 2 2 2 2ν Γ ( 12 + ν)zν+μ √ (z − 1)μ/2 (z + 1)μ/2 π Γ (1 + ν − μ)
−ν − μ 1 − ν − μ 1 −2 , ; − ν; z × 2 F1 , |z| > 1 2 2 2 +
(3.23e)
√ Γ (ν + μ + 1) −ν−μ−1 z π (z − 1)μ/2 (z + 1)μ/2 Γ (ν + 32 )
3 −2 ν +μ 1+ν+μ , ;ν + ;z , |z| > 1 (3.24a) × 2 F1 1 + 2 2 2
−ν−1 Qμ ν (z) = exp(iμπ)2
48
3 Legendre Polynomials and Legendre Functions
Qμ ν (z)
Γ (1 + ν + μ)Γ (−μ) z − 1 μ/2 1 = exp(iμπ) 2 Γ (1 + ν − μ) z+1
1−z × 2 F1 −ν, 1 + ν; 1 + μ; 2
$ 1−z z + 1 μ/2 + Γ (μ) , 2 F1 −ν, 1 + ν; 1 − μ; z−1 2
|1 − z| < 2, (3.24b)
resp.
1−x 1+x
μ/2 and
1+x 1−x
μ/2 z → x;
note that this series will diverge for μ integer, which will be covered by the following equation: Qμ ν (z)
√ = exp(iμπ)2μ π (z − 1)−μ/2 (z + 1)−μ/2
Γ ( 1+ν+μ ) 1 2 × exp ±i π(μ − ν − 1) 2 2Γ (1 + ν−μ 2 )
−ν − μ 1 + ν − μ 1 2 , ; ;z × 2 F1 2 2 2 1 zΓ (1 + ν+μ ) exp ±i π(μ − ν) 2 2 + (3.24c) 1+ν−μ Γ( 2 )
! ν−μ 3 2 1−ν −μ ,1 + ; ;z with + for (z) > 0 and × 2 F1 2 2 2 − for (z) < 0
for |z| < 1 and for −1 ≤ x ≤ +1 by √ Qμ ν (x) = −
π sin
1 2 (ν
+ μ)π Γ ( ν+μ+1 ) 2
21−μ Γ ( ν−μ 2 + 1)
ν+μ+1 μ−ν 1 2 , ; ;x × 2 F1 2 2 2
(1 − x 2 )μ/2
3.4 Associate Legendre Functions with Complex Indices
√ cos + 2μ π × 2 F1
1 2 (ν
+ μ)π Γ ( ν+μ 2 + 1) Γ ( ν−μ+1 ) 2
49
x (1 − x 2 )μ/2
(3.24d)
μ−ν +1 3 2 ν+μ + 1, ; ;x . 2 2 2
If μ is not an integer, the Legendre functions of first and second kind are related via μ Eq. (3.12b). Therefore, in case the hypergeometric series expansion of Qν should μ μ −μ not converge, Qν will be calculated from the pair (Pν , Pν ). Either μ is an integer or this pair is not converged, and the corresponding differential equation of the hypergeometric function will be directly solved. Hypergeometric Series: Programming Hints The hypergeometric series is given by 2 F1 (a, b; c; z)
= 1z0 + +
a · b 1 a · b · (a + 1) · (b + 1) 2 z + z c·1 c · 1 · (c + 1) · 2
a · b · (a + 1) · (b + 1) · (a + 2) · (b + 2) 3 z + · · · . (3.25) c · 1 · (c + 1) · 2 · (c + 2) · 3
With 2 F1 (a, b; c; z)
= ta(0)z0 + ta(0) · ta(1)z1 + ta(0) · ta(1) · ta(2)z2 (3.26) +ta(0) · ta(1) · ta(2) · ta(3)z3 + · · · ,
we get ta(0) = 1, ta(1) =
a·b (a + n − 1) · (b + n − 1) , · · · , ta(n) = ,··· . c·1 (c + n − 1) · n
We can easily translate this into a MATLAB program: z = z(:);
% z have to be % a column vector zprod = repmat(z,1,nm-1); % nm maximum % of the series zprod = cumprod(zprod,2); % z^n zprod = [ones(length(z),1),zprod]; % corresponding array z^0 ... z^n ... n = 1:nm-1; % elements of the summands: ta(n) = (a+n-1)*(b+n-1)/((c+n-1)*n); ta = [1,ta];
% ta(0), ...
50
3 Legendre Polynomials and Legendre Functions ya = cumprod(ta);
% single summands without z^n
te = ya.*zprod;
% complete series % check convergency % not for computation
tres = cumsum(te,2);
The cumulative sum will give us some information about convergency. Simply summing up the complete series will shrink the accuracy due to mutual cancellations. Therefore, we split the total array te for each individual zvalue into its real and imaginary subparts. Each of these subparts is divided into its positive and negative values. The positive part will be sorted in ascending order and the negative part in descending order before summing up, e.g., rtz1 = real(te); % Real and imaginary part itz1 = imag(te); for k = 1:length(z) % Split for single z-values rtz1s = rtz1(k,:); itz1s = itz1(k,:); rtz1p = sum(sort(rtz1s(rtz1s>0))); % Positive part rtz1m = sum(sort(rtz1s(rtz1s0))); % Positive part itz1m = sum(sort(itz1s(itz1s 0, and ω2 = −ω1 −ω3 , and the lattice parameter τ = ωω31 with nome q = exp(iπτ ), see Eq. (9.2). The Weierstraß elliptic function is defined as ℘ (z) =
1 + z2
(m,n)=(0,0)
1 1 − , (z − mω1 − nω3 )2 (mω1 + nω3 )2
(12.1)
and thus by construction, this function is double periodic with fundamental periods equal 2ω1 , 2ω3 , and an even function ℘ (−z) = ℘ (z). The Weierstraß ζ function is defined as dζ(z) = −℘ (z), dz
(12.2a)
and therefore ζ (z) =
1 + z
1
(m,n)=(0,0)
z − mω1 − nω3 )
+
1 z + . mω1 + nω3 (mω1 + nω3 )2 (12.2b)
The Weierstraß ζ function is an odd function ζ(−z) = −ζ(z) and quasiperiodic ζ (z + 2ωi ) = ζ (z) + 2ηi with ηi = ζ(ωi ). Finally, the Weierstraß σ function is defined as 1 dσ (z) = ζ(z), σ (z) dz
(12.3a)
or alternatively σ (z) =
. (m,n)=(0,0)
1−
z2 z z + . exp mω1 + nω3 ) mω1 + nω3 2(mω1 + nω3 )2 (12.3b)
The σ -function is a quasiperiodic odd function σ (−z) = −σ (z). The complex numbers 0, 2ω1 , 2ω2 , and 2ω3 define a parallelogram on the complex plane and the set of points 2mω1 + 2nω3 with (m, n) ∈ Z a lattice. The
12.2 Fundamental Equations and Computation
155
lattice invariants are given by
g2 = 60
(mω1 + nω3 )−4
and
(12.4a)
(m,n)=(0,0)
g3 = 140
(mω1 + nω3 )−6 .
(12.4b)
(m,n)=(0,0)
The lattice roots (e1 , e2 , e3 ) are the solution of the cubic equation 4z3 − g2 z − g3 = 0,
(12.4c)
respectively, the half-periods values ω1 , ω2 , and ω3 e1 = ℘ (ω1 ),
e2 = ℘ (ω2 ),
e3 = ℘ (ω3 ),
(12.4d)
and thus, the corresponding discriminant Δ is Δ = g23 − 27g32 .
(12.4e)
The Weierstraß ℘ function is the general solution of the differential equation
dy dz
= 4y 3 − g2 y − g3 .
(12.4f)
Substituting the half-periods values into this differential equation yields 4ei3 −g2 ei − g3 = 0, thus the same equation as (12.4c). The elliptic modular function λ is given by λ(τ ) =
ϑ 4 (0, q) e3 − e2 , = 24 e1 − e2 ϑ3 (0, q)
(12.5a)
and Klein’s complete invariant J (τ ) is J (τ ) = 12
3 3 g2
Δ
=
8 3 ϑ2 (0, q) + ϑ38 (0, q) + ϑ48 (0, q) d 54( dz ϑ1 (0, q))8
.
(12.5b)
The following equations build the computational basis: e1 =
π2 4 4 ϑ (0, q) + 2ϑ (0, q) , 2 4 12ω12
(12.6a)
e2 =
π2 4 ϑ2 (0, q) − ϑ44 (0, q) , 2 12ω1
(12.6b)
156
12 Weierstraß Functions
e3 = −
π2 4 4 2ϑ (0, q) + ϑ (0, q) . 2 4 12ω12 z˜ =
With ℘ (z) − e1 = ℘ (z) − e2 = ℘ (z) − e3 =
(12.6c)
πz , 2ω1
πϑ3 (0, q)ϑ4 (0, q)ϑ2 (˜z, q) 2ω1 ϑ1 (˜z, q) πϑ2 (0, q)ϑ4 (0, q)ϑ3 (˜z, q) 2ω1 ϑ1 (˜z, q) πϑ2 (0, q)ϑ3 (0, q)ϑ4 (˜z, q) 2ω1 ϑ1 (˜z, q)
(12.6d)
2 ,
(12.6e)
,
(12.6f)
.
(12.6g)
2
2
To evaluate the ζ (z) and σ (z) functions, we need, in addition, Jacobi’s identity d ϑ1 (0, q) = ϑ2 (0, q) ϑ3 (0, q) ϑ4 (0, q) , and dz ηj = −ωj ej + 2RG(0, ej − ek , ej − el ),
(12.6h) (12.6i)
with (j, k, l) cyclic permutations. The Weierstraß function ℘ (z) could be evaluated via Eqs. (12.6a) and (12.6e); σ (z) is given by σ (z) = 2ω1 exp
η1 z2 2ω1
ϑ1 (˜z, q) d π dz ϑ1 (0, q)
,
(12.7)
and ζ (z) within the half-period parallelogram is given by ζ (z) = −z℘ (z) + 2RG(℘ (z) − e1 , ℘ (z) − e2 , ℘ (z) − e3 )
(12.8a)
and in general by ζ(z) =
π d η1 log ϑ(˜z, τ ). z+ ω1 2ω1 dz
(12.8b)
We will use the first equation only if (τ ) < 0.02 and z sufficiently small. The logarithmic derivative could be evaluated by ∞
q 2n d sin(2nz). log ϑ(z, τ ) = cot(z) + 4 dz 1 − q 2n n=1
(12.8c)
12.3 The Class ellipWeier
157
In case, the Weierstraß functions ℘ (z) and ζ(z) should not converge due to a high z-value, this z-value will be mapped on the fundamental period parallelogram and the result of the ζ function evaluated based on its quasiperiodicity.
12.3
The Class ellipWeier
The class classWeier serves for the evaluation of the Weierstraß elliptic functions and some lattice related functions. The syntax is obj = ellipWeier(wweier, omega1, omega3, z). The input variable “wweier” supports the values: • “wp”—Weierstraß ℘ (z)-function obj = ellipWeier(’wp’, omega1, omega3, z); • “zeta”—Weierstraß ζ(z)-function obj = ellipWeier(’zeta’, omega1, omega3, z); • “sigma”—Weierstraß σ (z)-function obj = ellipWeier(’sigma’, omega1, omega3, z); • “e1,” “e2,” “e3,” and “eall” for the computation of the zeros of the Weierstraß cubic normal ei , e.g., obj = ellipWeier(’e1’, omega1, omega3); • “eta1,” “eta2,” “eta3,” and “etaall,” the quasiperiodic contribution ηi to the ζ (z)-function, e.g., obj=ellipWeier(’etaall’,omega1,omega3) to compute all three values; • “g23” to compute the lattice invariants g2 and g3 and “disc” for the discriminant Δ, and g2 and g3; • “lambda” for the elliptic modular function λ(τ ), obj=ellipWeier(’lambda’, omega1, omega3) or obj=ellipWeier(’lambda’,1,tau); • “klein” to evaluate Klein’s complete invariant J (τ ), e.g., obj = ellipWeier(’klein’, 1, tau); and • the auxiliary function ℘ (z) − ei via “wpe1,” “wpe2,” “wpe3,” and “wpeall.” The inputs “omega1” and “omega3” are the half-period lattice generator, with (ω3/ω1) > 0. Some functions depend only on τ = ω3 ω1 , and thus one could also use obj = ellipWeier(wweier, 1, tau) instead of obj = ellipWeier(wweier, omega1, omega3). The last input variable z is the complex function variable. All variables have to be scalars. The output is the object “obj” with property “value” for the evaluation result. This could be a single number or a vector. “z” is the input at which the function will be evaluated. In case of ℘ (z) and ζ(z), “z” will have two components if the evaluation was based on the periodic, respectively, and quasiperiodic properties of these functions. “para” is the used parameter for evaluation, thus in dependence of the functions, ω1 and ω3 and/or τ . Finally, “info” carries some general information about the function in quest.
158
12 Weierstraß Functions
Examples
(a) As a first example, we compute Klein’s invariant J (τ ). tau = pi + i; obj = ellipWeier(’klein’, 1, tau, 0.5 + i*0.75) obj = ellipWeier with properties: value: 0.747655947903644 - 0.031588735985876i z: NaN para: 3.141592653589793 + 1.000000000000000i info: 2x1 cell obj.info ans = 2x1 cell array ’Klein’s complete invariant J(tau)’ ’parameter tau’
As an alternative, we could have used any ω1 and ω3 with the ratio τ =
ω3 ω1
omega1 = rand omega1 = 0.814723686393179 omega3 = tau*omega1; obj = ellipWeier(’klein’,omega1,omega3,0.5 + i*0.75) obj = ellipWeier with properties: value: 0.747655947903644 - 0.031588735985876i z: NaN para: 3.141592653589793 + 1.000000000000000i info: 2x1 cell >> obj.info ans = 2x1 cell array ’Klein’s complete invariant J(tau)’ ’parameter tau’
(b) Figure 12.1 was plotted with the following function ( visuweier.m): % as an example we visualize some results for a % lemniscatic lattice g2 = 0.8; % lattice invariant omega1 = gamma(0.25)^2 ./ (4*sqrt(pi)*g2^(1/4)); omega3 = i*omega1; xl = linspace(-2.5,2.5,30); % variable z [X, Y] = meshgrid(xl, xl); z = X + i*Y; for n = 1:numel(z) % p(z) function res(n)=ellipWeier(’wp’,omega1,omega3,z(n)).value; end res = reshape(res,size(z));
12.3 The Class ellipWeier
159 3
3
2
2
5 4 3 2 1 0
5 1
1
4 3
0
0
2 1
-1
-2 2
-1
1
0
real(z)
-2
2
-1 -2
imag(z)
2
-1
1 0
0
1
-1
-2
-3
-2
0 1
real(z)
-1 2
-2
imag(z)
-3
Fig. 12.1 Weierstraß elliptic function ℘ (z) on the left-hand side and σ (z) on the right-hand side for a lemniscatic lattice with ω1 = 1.960445 and ω3 = i · ω1 . The height is given by the absolute value, and the phase angle is color coded
surface(X,Y,abs(res),angle(res)) % visualization zlim([0, 5]) % figure for n = 1:numel(z) % sigma(z) function res(n)=ellipWeier(’sigma’,omega1,omega3,z(n)).value; end res = reshape(res,size(z)); % visualization surface(X,Y,abs(res),angle(res)) zlim([0,5]
(c) To check the accuracy, we could compute ei : e1 + e2 + e3 = 0. >> obj=ellipWeier(’eall’,omega1,omega3,0.5 + i*0.75); >> sum(obj.value) ans = 5.551115123125783e-17
The same hold for the function ηi : >> obj = ellipWeier(’etaall’, omega1, omega3); >> sum(obj.value) ans = 0.000000000000000e+00 - 8.881784197001252e-16i
The sum of the auxiliary functions ℘ (z) − ei should be equal to 3 · ℘ (z): >> z = 0.5 + 0.75*i >> objwp = ellipWeier(’wp’, omega1, omega3, z); >> res = ellipWeier(’wpeall’, omega1, omega3, z).value; >> 3*objwp.value - sum(res) ans = 2.220446049250313e-15 + 5.440092820663267e-15i
160
12 Weierstraß Functions
Reference 1. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders, B.V. (eds.): NIST Digital Library of Mathematical Functions (2017). http://dlmf.nist.gov, Rel. 1.0.17
Parabolic Cylinder Functions
13
Abstract
Topic of this chapter are the four parabolic cylinder functions. The evaluation of these functions is based on the confluent hypergeometric function. The parameters and function arguments could be complex, except for the parabolic cylinder function W (a, x) by definition. The corresponding code is ready for download.
Topic of this chapter are the parabolic cylinder functions. The parabolic cylinder coordinates and the corresponding Laplace–Beltrami operator can be found under Eqs. (23.22). If we seek a solution of the Helmholtz equation in parabolic cylinder coordinates (Δη,ζ,z + k 2 )φ(η, ζ, z) = 0 in the form φ1 (η)φ2 (ζ )φ3 (z), we obtain the following equations:
d2 2 − λη + μ φ1 (η) = = 0, dη2 2
d 2 − λζ − μ φ2 (ζ ) = = 0, dζ 2 2
d 2 + k + λ φ3 (z) = = 0, dz2
(13.1) (13.2) (13.3)
where λ and μ are constants. Thus, the results are given by the parabolic cylinder functions.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_13
161
162
13.1
13 Parabolic Cylinder Functions
Equations and the Class paracylFun
Function Overview The SPECFUNPHYS class paracylFun allows the evaluation of the parabolic cylinder functions U (a, z), V (a, z), Da (z), and W (a, z). Equations The following equations are based on [1, 2]. The parabolic cylinder functions U (a, z) and V (a, z) are solutions of the differential equation
d2 1 2 − z − a w = 0, dz2 4
(13.4a)
and Dν (z) = U (− 12 − ν, z) of
d2 1 1 2 + ν + − z w = 0, dz2 2 4
(13.4b)
and finally for x ∈ R, W (a, x) with differential equation
1 2 d2 + x − a w = 0. dx 2 4
(13.4c)
The evaluation of these functions are based on the confluent hypergeometric function, Sect. 6. With √ √ π π d U (a, 0) = 1 1 , , (13.5) U (a, 0) = 1 1 3 1 a+ a− dz 2 2 4 Γ ( 4 + 2 a) 2 2 4 Γ ( 14 + 12 a) 1
V (a, 0) =
1
π2 2 a+ 4
Γ ( 34 − 12 a)2 Γ ( 14 + 12 a)
1
,
3
π2 2 a+ 4 d V (a, 0) = , (13.6) 1 1 dz Γ ( 4 − 2 a)2 Γ ( 34 + 12 a)
and
1 1 1 1 2 1 f1 (a, z) = exp − z 1 F1 ( a + , ; z2 ) , 4 2 4 2 2
3 3 1 1 1 f2 (a, z) = z exp − z2 1 F1 ( a + , ; z2 ) , 4 2 4 2 2
(13.7) (13.8)
we obtain U (a, z) = U (a, 0)f1 (a, z) +
d U (a, 0)f2 (a, z) dz
and
(13.9)
13.1 Equations and the Class paracylFun
163
d V (a, 0)f2 (a, z). dz
(13.10)
d W (a, 0)w2 (a, x), dx
(13.11a)
V (a, z) = V (a, 0)f1 (a, z) + The function W (a, x) is given by W (a, x) = W (a, 0)w1 (a, x) + with
1 1 1 1 1 w1 (a, x) = exp − iz2 1 F1 ( − ia, ; ix 2 ) , 4 4 2 2 2
3 1 1 3 1 w2 (a, x) = x exp − iz2 1 F1 ( − ia, ; ix 2 ). 4 4 2 2 2
(13.11b) (13.11c)
SPECFUNPHYS Class paracylFun The syntax of the class paracylFun is [obj, result] = paracylFun (wpcf, a, z) with “wpcf” equal “U” for U (a, z), “V” for V (a, z), “D” for Da (z), and “W” for W (a, x), x ∈ R. “a” is the scalar parameter that could be complex (real for “W”), and “z” could be an arbitrary complex (real for “W”) array. Output are the object “obj” with properties “value” for the function values, “z” for the input at which the function will be evaluated, the function parameter “a,” and “info” with some general information and hints about the evaluation of the corresponding confluent hypergeometric functions. The second output is “result” with the function results. Example >> >> >> >> >> >> >> >> >>
a = 1.5; % function parameter x = linspace(-3.6,5,30); y = linspace(-5, 5, 40); [X, Y] = meshgrid(x,y); z = X + i*Y; % function input res = paracylFun(’U’, a, z).value; % function value surf(X,Y,abs(res)) % visulization axis tight, zlim([0,50]) view(28.8,40.8), xlabel(’real’), ylabel(’imag’), shg
The result is shown in Fig. 13.1.
164
13 Parabolic Cylinder Functions
Fig. 13.1 Absolute value of the parabolic cylindrical function U (a, z), with a = 1.5 and z = x + iy, −3.6 < x < 5, and −5 < y < 5
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover, New York (1972) 2. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders, B.V. (eds.): NIST Digital Library of Mathematical Functions (2017). http://dlmf.nist.gov. Rel. 1.0.17
Mathieu Functions
14
Abstract
Topic of this chapter are the solutions of the (angular) Mathieu equation and the radial or modified Mathieu equation in the complex domain. The Mathieu differential equations are related to the Helmholtz equation in elliptic cylindrical coordinates. The periodic Mathieu functions of integer order and the Mathieu functions of non-integer (complex) order are discussed. The second solution of the corresponding differential equation is as well derived. Similar to the modified Mathieu differential equation, first and second solutions are discussed, and computational methods for evaluating all functions are presented. The corresponding code and, in addition, code for direct integration of the differential equations are available for download.
From the Helmholtz equation in elliptic cylindrical coordinates, Eq. (23.19), we get the (angular) Mathieu equation, see Fig. 14.2, with parameters (a,q),
d2 + a − 2 q cos(2z) y(z) = 0, dz2
(14.1)
and the radial or modified Mathieu equation, see Fig. 14.2,
d2 − a + 2 q cosh(2z) y(z) = 0. dz2
(14.2)
The Mathieu equation is an example of a Hill equation and was derived from Mathieu in the context of the free oscillations of an elliptic membrane. The Mathieu equation plays, e.g., an important role in applications involving elliptic geometries or in problems involving periodic motions. An example about dynamical trapping of ions in a Paul trap can be found in [4]. © The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_14
165
166
14 Mathieu Functions
In this chapter, we will mainly derive code for the evaluation of the even parity eigenfunctions cen (z, q), the odd parity eigenfunctions sen (z, q) and the corresponding eigenvalues, the functions f en (z, q) and gen (z, q), the non-integer functions ceν (z, q), seν (z, q), and meν (z, q), and the solution of the modified Mathieu functions Ceν (z, q), Seν (z, q), F eν (z, q), and Geν (z, q). Most equations used can be found in [3] and [1].
14.1
Function Overview
The SPECFUNPHYS class mathieuFun supports the following functions: • the computation of the eigenvalues and eigenvectors of Eq. (14.1), an (even parity) and bn (odd parity), • the corresponding functions cen (z, q), sen (z, q), and men (z, q), n integer, • the second solutions f en (z, q) and gen (z, q) of the corresponding period functions and the related scaling factors Cn (q) and Sn (q), • the non-integer eigenfunctions ceν (z, q), seν (z, q), and meν (z, q), and • the even and odd parity functions wI (z; a, q) and wI I (z; a, q) via direct integration. • Supported eigensolutions of Eq. (14.2) are the integer functions Cen (z, q), Sen (z, q), and Men (z, q), • the second solutions F en (z, q) and Gen (z, q), • the non-integer solutions Ceν (z, q), Seν (z, q), and Meν (z, q), and • WI (z; a, q) and WI I (z; a, q). The SPECFUNPHYS functions eiga and eigb allow the computation of the eigenvalues an and bn and the corresponding eigenvectors. The SPECFUNPHYS functions [z,y]=mathieudeq(a, q, w0, zspan) and [z,y]=modmathieudeq(a, q, w0, zspan) support the direct evaluation of the differential equations with initial condition w0.
14.2
Fundamental Equations and Computation
We will start with the solutions of Eq. (14.1) before we turn to the modified Mathieu equation, Eq. (14.2).
14.2.1 Mathieu Differential Equation As Eq. (14.1) is a differential equation of the second order, the most general solution is y(z) = Ay1 (z) + By2 (z) with arbitrary complex constants A and B. Due to
14.2 Fundamental Equations and Computation
167
Floquet’s theorem, it is always possible to choose y1 in the form y1 (z) = exp(i ν(a,q) z) p(z)
(14.3)
with p(z) π-periodic and ν a constant depending on a and q. If ν is a real number, y1 (z) is bounded, otherwise unbounded. If ν is a rational number, y1 (z) will be periodic and for integer values π or 2π periodic and, respectively, π periodic or π antiperiod, in all other real cases non-periodic. In addition, if ν is an integer, a second solution exists of the form y2 (z) = c z y1 (z) + f (z),
(14.4)
with f (z) the same periodicity properties as y1 and c a constant [2]. Periodic Mathieu Eigenfunctions of Integer Order The periodic integer eigenfunctions of the Mathieu differential equation and its corresponding eigenvalues are listed in Table 14.1, see also Fig. 14.1. The corresponding Fourier series converges in the z-plane and reads ce2n (z, q) =
∞
A(2n) 2r (q) cos(2 r z)
(14.5)
r=0
ce2n+1 (z, q) =
∞
(2n+1)
A2r
(q) cos((2 r + 1) z)
(14.6)
r=0
se2n+1 (z, q) =
∞
(2n+1) B2r+1 (q) sin((2 r + 1) z)
(14.7)
r=0
se2n+2 (z, q) =
∞
(2n+2)
B2r+2 (q) sin((2 r + 2) z),
(14.8)
r=0
Table 14.1 Periodic integer eigenfunction of the Mathieu equation (14.1); antiperiodic π means f (z + π) = − f (z); n = 0, 1, 2, . . . Eigenvalues a2n a2n+1 b2n+2 b2n+1
Eigenfunction ce2n (z, q) ce2n+1 (z, q) se2n+2 (z, q) se2n+1 (z, q)
Periodicity Period π Antiperiod π Period π Antiperiod π
Parity Even Even Odd Odd
q=0 √ ce0 (z, 0) = 1/ 2 cen (z, 0) = cos(n z) sen (z, 0) = sin(nz)
168
14 Mathieu Functions
with n ∈ N. The recurrence formulae for the q-dependent coefficients A and B are (2n)
(2n)
a A0 − q A2 = 0 (a − 4) A(2n) − q A(2n) + 2A(2n) =0 2 4 0 (2n) (2n) (2n) (a − 4r 2 )A2r − q A2r+2 + A2r−2 = 0,
(a − 1 − q) A(2n+1) − q A(2n+1) =0 1 3 (2n+1) (2n+1) (2n+1) a − (2r + 1)2 A2r+1 − q A2r+3 + A2r−1 = 0,
a − (2r + 1)2
(a − 1 + q) B1(2n+1) − q B3(2n+1) = 0 (2n+1) (2n+1) (2n+1) B2r+1 − q B2r+3 + B2r−1 = 0, (2n+2)
(2n+2)
(a − 4) B2 − q B4 =0 (2n+2) (2n+2) (2n+2) (a − 4r 2 ) B2r = 0. − q B2r+2 + B2r−2
(14.9a) (14.9b) (14.9c) (14.10a) (14.10b) (14.11a) (14.11b) (14.12a) (14.12b)
Due to the normalization of the Mathieu solutions
2π
y 2 dx = π,
(14.13)
0
we get the following normalization conditions: 2 2A(2n) 0 (q) +
∞
2 A(2n) 2r (q) = 1,
(14.14a)
r=1 ∞
(2n+1)
A2r+1 (q)2 = 1, and
(14.14b)
r=0 ∞ r=0
(2n+1) B2r+1 (q)2 = 1,
∞
(2n+2) B2r+2 (q)2 = 1.
(14.15)
r=0
Thus, we get sparse tridiagonal matrices with eigenvalues a and b and corresponding √ = 12 (2)A˜ (2n) eigenvectors A and B. By setting A(2n) 0 0 , we reduce the computation
14.2 Fundamental Equations and Computation
169
of the eigenvalues for all four cases on symmetric tridiagonal matrices. For cen (z, q): ⎛
0 ⎜ √2q ⎜ ⎜ ⎜ 0 ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ ⎜ ⎝ ⎛
√
1+q ⎜ q ⎜ ⎜ ⎜ 0 ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ ⎜ ⎝
2q 4 q .. . .. .
q 9 q .. . .. .
0 0 q 0 16 q .. . . . . .. .. . .
0 0 q 0 25 q .. . . . . .. .. . .
⎛ (2n) ⎞ (2n) ⎞ A˜ 0 A˜ 0 ⎜ A(2n) ⎟ ⎜ A(2n) ⎟ ⎜ 2 ⎟ ⎜ 2 ⎟ ⎜ (2n) ⎟ ⎜ (2n) ⎟ ⎜ A4 ⎟ ⎜ A4 ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ ⎜ . ⎟ ⎟ ⎜ . ⎟ = a2k ⎜ .. ⎟ , ⎜ ⎜ ⎟ ⎟ ⎜ .. ⎟ ⎜ .. ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ (2n) ⎟ ⎜ (2n) ⎟ ⎜A ⎜A ⎟ ⎟ ⎝ 2r ⎠ ⎝ 2r ⎠ .. .. . .
⎞⎛
··· ··· ···
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎟ q (2r)2 q ⎟ ⎠ .. . q
(14.16a)
⎞⎛
··· ··· ···
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎟ q (2r − 1)2 ) q ⎟ ⎠ .. . q
⎛ (2n+1) ⎞ (2n+1) ⎞ A1 A1 ⎜ A(2n+1) ⎟ ⎜ A(2n+1) ⎟ ⎜ 3 ⎜ 3 ⎟ ⎟ ⎜ (2n+1) ⎟ ⎜ (2n+1) ⎟ ⎜ A5 ⎜ A5 ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ , . . ⎜ ⎟ = a2k+1 ⎜ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ . . ⎜ (2n+1) ⎟ ⎜ (2n+1) ⎟ ⎜A ⎜A ⎟ ⎟ ⎝ 2r+1 ⎠ ⎝ 2r+1 ⎠ .. .. . . (14.16b)
and for sen (z, q): ⎛
4 ⎜q ⎜ ⎜ ⎜0 ⎜. ⎜. ⎜. ⎜. ⎜. ⎜. ⎜ ⎜ ⎝
q 0 0 16 q 0 q 36 q .. .. . . . . . .. .. .. . . .
··· ··· ···
⎞⎛
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎟ 2 q (2r) q ⎟ ⎠ .. . q
⎛ (2n+2) ⎞ ⎞ B2(2n+2) B2 ⎜ B (2n+2) ⎟ ⎜ B (2n+2) ⎟ ⎜ 4 ⎜ 4 ⎟ ⎟ ⎜ (2n+2) ⎟ ⎜ (2n+2) ⎟ ⎜ B6 ⎜ B6 ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎟ = b2k ⎜ ⎟ , . . ⎜ ⎜ ⎟ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ . . ⎜ (2n+2) ⎜ (2n+2) ⎟ ⎟ ⎜B ⎜B ⎟ ⎟ ⎝ 2r ⎝ 2r ⎠ ⎠ .. .. . .
(14.17a)
170
14 Mathieu Functions
and ⎛
1−q ⎜ q ⎜ ⎜ ⎜ 0 ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ . ⎜ ⎜ ⎝
q 9 q .. . .. .
0 0 q 0 25 q .. . . . . .. .. . .
··· ··· ···
⎞⎛
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎟ 2 q (2r − 1) ) q ⎟ ⎠ .. . q
⎛ (2n+11) ⎞ (2n+1) ⎞ B1 B1 ⎜ B (2n+1) ⎟ ⎜ B (2n+1) ⎟ ⎜ 3 ⎜ ⎟ ⎟ ⎜ (2n+1) ⎟ ⎜ 3(2n+1) ⎟ ⎜ B5 ⎜ B5 ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎟ = b2k+1 ⎜ ⎟ , . . ⎜ ⎜ ⎟ ⎟ .. .. ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ . . ⎜ (2n+1) ⎜ (2n+1) ⎟ ⎟ ⎜B ⎜B ⎟ ⎟ ⎝ 2r+1 ⎠ ⎝ 2r+1 ⎠ .. .. . . (14.17b)
where the eigenvalues ak start with k = 0 and bk with k = 1, Fig. 14.1. Therefore, with the M ATLAB function eigs, we can quickly and easily compute the eigensolutions and, from the Taylor expansions, the corresponding Mathieu function. Basic Solutions The functions wI and wI I are the even (I) and odd (II) parity solutions of the Mathieu equation (14.1). The initial conditions are wI (z; a, q) = 1,
and
wI I (z; a, q) = 0,
and
d wI (z; a, q) = 0 and dz d wI I (z; a, q) = 1. dz
(14.18) (14.19)
For a equal to an eigenvalue ak , we get wI (z; ak , q) · cek (0, q) = cek (z, q),
(14.20)
and if a equals an eigenvalue bl wI I (z; bl , q) ·
d sel (0, q) = sel (z, q). dz
(14.21)
The evaluation of wI and wI I is based on a direct integration of the differential equation with the MATLAB function ode113. Second Solutions As already mentioned, see Eq. (14.4), a second linear independent solution exists, referred as f en (z, q) for the functions cen (z, q) and gen (z, q) for the functions
14.2 Fundamental Equations and Computation
171
sen (z, q) [2, 3]. Thus, f en (z, q) = Cn (q) (z cen (z, q) + fn (z, q)), and
(14.22)
gen (z, q) = Sn (q) (z sen (z, q) + gn (z, q)).
(14.23)
Hence, for n ∈ N, f2n (z, q) is π-periodic and f2n+1 (z, q) is π-antiperiodic, both with parity odd, and g2n+1 (z, q) is π-antiperiodic and g2n+2 (z, q) is π-periodic, both g’s with parity even. The factors Cn (q) and Sn (q) are normalized such that
2π
(Cn (q))2
2π
(fn (z, q))2 dz = (Sn (q))2
0
(gn (z, q))2 dz = π .
(14.24)
0
For the computation of f en (z, q)andgen (z, q), we integrate the differential equation (14.1) directly using the MATLAB-function ode113. For f en (z, q), we start with the initial values (0, 1), which results in f˜en (z, q) = c · f en (z, q), with c an unknown constant. Because fn (π, q) = 0, we could compute an intermediate constant via c˜f˜en (π, q) = π · cen (π, q). This allows us to compute f˜n (z, q) = c˜f˜en (z, q) − z · cen (z, q), and due to Eq. (14.24), 2π ˜ Cn (q)2 = |π/ 0 (f˜n (z, q)2 | and thus the scaling c = Cn (q) · c. For gen (z, q), we start by integrating Eq. (14.1) with the initial value (1, 0), which gives ge ˜ n (z, q) ∝ gen (z, q). To compute the scaling factor c, we have to evaluate the functions at two points (r, r + π), with r a random number between ]0, 0.5], because gen (0, q) = 0. As gn (r, q) = (−1)n gn (r + π, q), we can compute (similar to f en ) the proportional constant c˜ and, with the normalization condition (14.24), the scaling factor between gen and ge ˜ n. Mathieu Functions of Non-integer Order For non-integer ν, the series expansion of the Mathieu functions reads meν (z, q) =
∞
(ν)
(14.25a)
(ν)
(14.25b)
(ν)
(14.25c)
c2r (q) exp[i(ν + 2 r) z]
r=−∞
ceν (z, q) =
∞
c2r (q) cos[(ν + 2 r) z]
r=−∞
seν (z, q) =
∞
c2r+1 (q) sin[(ν + 2 r) z],
r=−∞
and the coefficients satisfy (ν) (ν) (ν) q c2r+2 − a − (ν + 2r)2 q c2r + q c2r−2 = 0,
(14.25d)
172
14 Mathieu Functions
with the normalization condition ∞ 2 (ν) c2r (q) = 1.
(14.25e)
r=−∞
The corresponding eigenvalues and eigenvectors can be derived from the (infinite) sparse tridiagonal matrix equation ⎛
..
. ⎜ ⎜ q (−2n + ν)2 ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ 0 ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝
⎞ ⎟ ⎟ ⎟ ⎟ ⎟ . ⎟ ⎟ 2 ⎟ 0 q (−2 + ν) q ⎟ ⎟ 0 q ν2 q 0 ⎟ 2 0 q (2 + ν) q 0⎟ ⎟ ⎟ .. ⎟ . ⎟ ⎟ q (2n + ν)2 q ⎟ ⎠ .. .
q ..
⎛ ⎞ ⎞ .. .. . . ⎜ ⎟ ⎟ ⎜ ⎜ (ν) ⎟ ⎜ (ν) ⎟ ⎜ c−2n ⎟ ⎜ c−2n ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ c(ν) ⎟ ⎜ c(ν) ⎟ ⎜ −2 ⎟ ⎜ −2 ⎟ ⎜ (ν) ⎟ = a ⎜ (ν) ⎟ , ⎜ c0 ⎟ ⎜ c0 ⎟ ⎜ (ν) ⎟ ⎜ (ν) ⎟ ⎜c ⎟ ⎜c ⎟ ⎜ 2 ⎟ ⎜ 2 ⎟ ⎜ . ⎟ ⎜ . ⎟ ⎜ .. ⎟ ⎜ .. ⎟ ⎜ ⎟ ⎟ ⎜ ⎜ (ν) ⎟ ⎜ (ν) ⎟ ⎜ c2n ⎟ ⎜ c2n ⎟ ⎝ ⎠ ⎠ ⎝ .. .. . . ⎛
(14.26) with a as eigenvalue. Obviously the result for ν and the result for ν + k, with k integer, are identical. To compute the eigenvalues and Eigenvectors, the MATLAB function eigs is used, and the corresponding Mathieu functions are evaluated from the Taylor expansions (14.25). Note: For ν ≥ 0, ν = n integer, the function me is given by men (z, q) =
√ 2cen (z, q)
√ and me−n (z, q) = − 2 i sen (z, q).
(14.27)
14.2.2 Modified Mathieu Differential Equation By substituting the independent variable z → i z, we can map the Mathieu equation (14.1) onto the modified Mathieu equation (14.2). Therefore, the solutions (Ceν , Seν , Meν , F en , Gen ) of the modified Mathieu differential equation are related to the Mathieu functions by Ceν (z, q) = ceν (i z, q), ν = −1, −2, · · ·
(14.28a)
Seν (z, q) = −i seν (i z, q), ν = 0, −1, −2, · · ·
(14.28b)
Meν (z, q) = meν (−i z, q)
(14.28c)
14.2 Fundamental Equations and Computation
173
F en (z, q) = −i f en (i z, q) n ∈ N
(14.28d)
∗
Gen (z, q) = gen (i z, q) n ∈ N .
(14.28e)
Hence, we can use directly the eigenvalues and scaling factors obtained for the solutions of the Mathieu equation (14.1). The Taylor series expansion will be mapped on a series expansion with hyperbolic functions, e.g., gen , and Eq. (14.5) becomes Ce2n (z, q) =
∞
(2n)
A2r (q) cosh(2 r z)
(14.29)
r=0
and similar for the other functions cosh(2r + 1)z, sinh(2r + 1)z, and sinh(2r + 2)z instead of the cos- and sin-functions. Due to the behavior of the hyperbolic functions for large arguments, these series will no longer converge, and thus we evaluate the modified Mathieu functions Ceν , Seν , F en , and Gen by direct evaluation of the differential equation (14.2) with the MATLAB function ode113, and Me via √ 2 Cen (z, q), with n ∈ N, √ Me−n (z, q) = − 2 i Sen (z, q), with n ∈ N∗ , Men (z, q) =
Meν (z, q) = Ceν (z, q) + i Seν (z, q),
with n ∈ / Z.
(14.30a) (14.30b) (14.30c)
Basic Solutions Similar to the functions wI and wI I , WI and WI I are the even (I) and odd (II) parity solutions of the modified Mathieu equation (14.2). The initial conditions are WI (z; a, q) = 1,
and
WI I (z; a, q) = 0,
and
d WI (z; a, q) = 0 and dz d WI I (z; a, q) = 1. dz
(14.31) (14.32)
For a equal to an eigenvalue ak , we get WI (z; ak , q) · Cek (0, q) = Cek (z, q),
(14.33)
and if a equals an eigenvalue bl WI I (z; bl , q) ·
d Sel (0, q) = Sel (z, q). dz
(14.34)
The evaluation of WI and WI I is based on a direct integration of the differential equation with the MATLAB function ode113.
174
14.3
14 Mathieu Functions
Programs
14.3.1 The SPECFUNPHYS Class Mathieufun The syntax of the class mathieuFun is obj = mathieuFun(wmathieu, n, q, z) and, respectively, obj = mathieuFun(wmathieu, n, q, z, name, value) or obj = mathieuFun(wmathieu, a, q, name, value), where the input argument “wmathieu” with values “ce,” “se,” “me,” “Cehyp,” “Sehyp,” “Mehyp,” “fe,” “ge,” “Fehyp,” “Gehyp,” “w1,” “w2,” “W1hyp,” “W2hyp,” “eiga,” and “eigb” specifies which Mathieu functionality should be evaluated. For example, “ce” stands for cen (z, q), “Cehyp” for Cen (z, q), and so on. In dependence of the function in quest, “n” could be either an integer or an arbitrary scalar value and “q” a complex scalar. “z” is a row vector, tested for real values. The name–value pairs are “eigen” with value 0 (no eigenvalue as output), 1 (output eigenvalues), or 2 (output eigenvalues and eigenvectors); “scale” with the same values as “eigen” and a similar meaning (see below); “zend” with zend for Mathieu functions where the evaluation is based on the direct integration of the differential equation. If zend is a scalar, the differential system will be integrated from 0 to zend. If zend has more than one element, zend = [z1 , z2 , · · · , zn ], then the solver returns the solution at the points [0, z1 , z2 , · · · , zn ]. The values have to be real and monotonically increasing. For Mathieu functions with n = ν, the corresponding matrix runs from −nmax to +nmax (default 75); the name–value pair “nmax” together with a real positive integer value allows to modify this value. The output argument is the object with properties “value” (function values), “z” (input at which the functions will be evaluated), “eigen” (eigenvalues and eigenvectors or parameter a), “q” (differential equation parameter q), “n” (number or maximum number of the eigenvalue), “scale” (scaling factor C or S for of the second solution and additional scaling c), and “info” (general information including hints with respect to the evaluation). Functions cen/ν (z, q), sen/ν (z, q), Cen/ν (z, q), Sen/ν (z, q), men/ν (z, q), and Men/ν (z, q) “n” could be either a positive integer or an arbitrary scalar value unequal −1, −2, · · · . For even/odd integer values “n,” all function values related to even/odd integer values lower than or equal to “n” will be computed. For the modified Mathieu functions, their first derivative is also evaluated. The following name–value pairs are supported: “eigen” and for n = ν “nmax.” For men/ν (z, q), Men/ν (z, q), “n” could be a positive or negative integer. Example: obj = mathieuFun(’ce’, 5, 1.25, z, ’eigen’,2); >> obj obj = mathieuFun with properties: value: [3x250 double] z: [1x250 double] eigen: {[3x3 double] [101x3 double]}
14.3 Programs q: n: scale: info:
175 1.2500 [1 3 5] [] {’Mathieu eigenfunction ce(z,q); antiperiod pi and even parity’
Because n = 5, ce1 (z, q), ce3 (z, q), and ce5 (z, q) will be evaluated. The first row of “obj.value” are the function values of ce1 (z, q), the second ce3 (z, q), and so on. objCe = mathieuFun(’Cehyp’, 5, 1.25, z, ’eigen’,2); >> objCe objCe = mathieuFun with properties: value: [6x100 double] z: [100x1 double] eigen: {[3x3 double] [101x3 double]} q: 1.2500 n: [1 3 5] scale: [] info: {’modified Mathieu eigenfunction Ce(z,q) and dCe(z,q); evaluation based on solving differential equation’}
The evaluation of the modified Mathieu function is based on a direct integration of the differential equation (14.2). Therefore, the function values and its first derivative are computed. Here, the first row in “objCe.value” are the function values of Ce1 (z, q), the second row are the function values of Ce3 (z, q), and so on, and the d fourth row are the function values of the first derivative dz Ce1 (z, q), followed by d d dz Ce3 (z, q) and dz Ce5 (z, q). “objCe.eigen” is a cell variable. The first cell element are the eigenvalues in a diagonal matrix, and the second one are the eigenvectors. Functions f en (z, q), gen (z, q) F en (z, q), and Gen (z, q) The syntax is, e.g., obj=mathieuFun(’fe’, n, q, ‘zend’, 2*pi). The evaluation of these functions and their first derivative is based on integrating the corresponding differential equation. For the Mathieu functions f e and ge, the default integration interval runs from 0 to 2π and for the modified Mathieu functions F e and Ge from 0 to 1. For the input argument “n,” only positive integers are allowed. The following name–value pairs are supported: “eigen” and “scale.” For the name-value pair (’scale’, 1) the scaling factor Cn (q) or Sn (q) will be uncovered in the object property “scale”, and for the pair (‘scale’, 2), the scaling c is also uncovered as second vector component. Example: >> objfe = mathieuFun(’fe’, 5, 1.25, ’scale’, 2); >> objfe objfe = mathieuFun with properties: value: [377x2 double] z: [377x1 double] eigen: [] q: 1.2500
176
14 Mathieu Functions n: 5 scale: [4.1253e-06 4.8621] info: {2x1 cell}
>> objfe.info 2x1 cell array {’fn and dfn, computation based on’} {’wII, negative parity’ }
The first column in objfe.value are the function values, and the second column are the values of the first derivative. “obj.scale” has two values. The first one is Sn (q) and the second one the scaling factor c, which is for f en equal to objfe.value(1,2). Functions wI (z, q), wI I (z, q), WI (z, q), and WI I (z, q) The syntax is, e.g., obj = mathieuFun(’W2hyp’, a, q, ‘zend’, 2) for the modified basis solution WI I (z, q). Here, “a” could be an arbitrary value. In case “a” is an eigenvalue, the function value will be proportional to the corresponding (modified) Mathieu function. Example: Computation of an integer periodic Mathieu function and its derivative, see Eq. (14.20): >> n = 3; % 3rd eigenvalue >> q = 1.75; % parameter of the differential equation % computing the corresponding eigenvalue and scaling % factor ce_n(0, q) >> obj = mathieuFun(’ce’, n, q, 0, ’eigen’, 1); % computing the non-scaled function value and its % 1st derivative >> objdce=mathieuFun(’w1’, obj.eigen(2), q, ’zend’,pi); >> cedce=objdce.value * obj.value(1,2);%scaling result >> plot(objdce.z,cedce), grid on, shg % visualization
The functions sen are negative parity functions. Thus, we need as scaling factor the first derivative for z = 0 or the function value at a position z = 0. >> >> % >> >> >> >>
>> >> % >> >> %
n = 3; % 3rd eigenvalue q = 1.75; % parameter differential equation for the first derivative we need the eigenvector obj = mathieuFun(’se’, n, q, 0, ’eigen’, 2); eigenvector = obj.eigen{2}(:,2); rsum = 0:length(eigenvector)-1; % see Fourier if mod(n,2) == 0 % expansion of se_n rs = 2*rsum+2; else rs = 2*rsum+1; end rs = rs(:); % need column dse0 = sum(rs.*eigenvector) % first derivative evaluation wII dse_n(0,q) objdse=mathieuFun(’w2’,obj.eigen{1}(4),q,’zend’,pi); sedse = objdse.value * dse0; % function se_n and its 1st derivative
14.3 Programs >> % >> >>
177
plot(objdse.z, sedse), grid on , shg% visualization if you want to test the result: obj = mathieuFun(’se’, n, q, objdse.z, ’eigen’, 2); hold on, plot(obj.z, obj.value(2,:),’--’), shg
Eigensolution “eiga” and “eigb” The syntax is, e.g., obj = mathieuFun(’eiga’, n, q). All even or odd eigenvalues and eigenvectors up to n will be computed. “n” has to be a positive integer. “eiga” stands for the positive parity solutions and “eigb” for the negative parity solutions.
14.3.2 Additional SPECFUNPHYS Functions Evaluation of Eigenvalues and Eigenvectors The eigenvalues of the integer periodic Mathieu functions can be computed either with the class mathieuFun or with the SPECFUNPHYS functions eiga and eigb. The evaluation is based on the MATLAB function eigs. The functions eiga and eigb allow in addition to evaluate all eigenvalues of definite parity. The syntax for both is equal, and thus as an example, the syntax for eiga is shown. The syntax is [a, v] = eiga(n, q) or a= eiga(n, q, ’all’). The input argument “n” is the maximum number of the eigenvalue. In the first case, all even or odd eigenvalues and eigenvectors up to n will be computed and with the qualifier “all” all eigenvalues from 0 to n. Example: Fig. 14.1 was plotted with the following code (eigenvaluevisu.m): q = q = a = for
linspace(0,10); % q-parameter of the differential q(:); % equation []; % array for eigenvalues a_n k = 1:length(q) ak = eiga(4,q(k),’all’); a = [a,ak];
end %% b = []; % array for eigenvalues b_n for k = 1:length(q) bk = eigb(4,q(k),’all’); b = [b,bk]; %#ok end %% figure, hold on % visualization plot(q,a) plot(q,b), shg legend(’a(0)’, ’a(1)’, ’a(2)’, ’a(3)’, ’a(4)’, ... ’b(1)’, ’b(2)’, ’b(3)’, ’b(4)’), shg
178
14 Mathieu Functions 25
20
15
10
5
a(0) a(1) a(2) a(3) a(4) b(1) b(2) b(3) b(4)
0
-5
-10
-15 0
2
4
6
8
10
q
Fig. 14.1 Eigenvalues a and b evaluated with programs eiga.m and eigb.m. Horizontal, the differential equation parameter 0 ≤ q ≤ 10. The eigenvalues fulfill for q ≥ 0 a0 < b1 < a1 < b2 < a2 < b3 < a4 < b4 . . .
Integration of the Differential Equation The functions mathieudeq and modmathieudeq integrate directly the Mathieu equation (14.1) and, respectively, the modified Mathieu equation (14.2). The computation is based on the MATLAB function ode113. The syntax of both functions is identical. The syntax is, e.g., [z,y] = mathieudeq(a, q, z0, zspan) with “a, q” the differential equation parameters, “z0” the initial condition, and “zspan” the integration interval with default value [0, π] for mathieudeq and [0, 1] for modmathieudeq. An example of the Mathieu function and the modified Mathieu function is plotted in Fig. 14.2. Example: Fig. 14.2 was plotted with the following code (deqsolvisu.m): q = 2.5 + i; % differential equation parameter n = 5; [a, v] = eiga(n, q); % eigenvalue for q a = a(5); % solving deq mathieu: [z,y] = mathieudeq(a, q, [1,0], [0, pi]); % deq modified mathieu [zmod,ymod] = modmathieudeq(a, q, [1,0], [0, 2]); figure % visualization Mathieu function yyaxis left xlabel(’z’), ylabel(’real’) plot(z,real(y)), shg yyaxis right
References
179 1800
150 4
0.2
3
0
-0.1
-1
-0.2
-2 -3
-0.3
-4
-0.4
imag
0
1
1400
0
100
1200
-2 -4 0
real
2
real
1600
2
0.1
1000 0.5
1 z
1.5
2
800 600
50
400 200 0
0 0
0.5
1
1.5 z
2
2.5
3
imag
4
0
0.5
1 z
1.5
2
Fig. 14.2 On the left-hand side, the solution of the Mathieu equation (14.1) for eigenvalue a5 and q = 2.5 + i; horizontal, 0 ≤ z ≤ π. The left y-axis are the real part of the corresponding Mathieu function (solid line) and its first derivative (dashed line), the right y-axis are the imaginary part of the Mathieu function (dotted line) and the imaginary part of the first derivative (dash–dot line). On the right-hand side, the solution of the modified Mathieu equation (14.2) for 0 ≤ z ≤ 2. The left y-axis is the absolute value of the corresponding modified Mathieu function (solid line) and the right the absolute value of the first derivative (dashed line). The small figure inside uncovers the phase angle, again solid for the function, and dashed for its first derivative
ylabel(’imag’) plot(z,imag(y)), shg axis tight, shg figure % visualization modified Mathieu function yyaxis left plot(zmod,abs(ymod(:,1))), shg yyaxis right plot(zmod,abs(ymod(:,2))), shg axes(’Position’,[0.2, 0.55 0.4 0.3]) %inner figure plot(zmod,angle(ymod)), shg
References 1. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt A. M. (1981) 2. McLachlan, N.W.: Theory and Applications of Mathieu Functions. Oxford University Press, London (1947) 3. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders, B.V. (eds.): NIST Digital Library of Mathematical Functions (2017). http://dlmf.nist.gov. Rel. 1.0.17 4. Schleich, W.P.: Quantum Optics in Phase Space. Wiley, Berlin (2001)
Orthogonal Polynomials: General Aspects
15
Abstract
Topics of this chapter are fundamental aspects of orthogonal polynomials. Orthogonal polynomials play a prominent role for many applications in physics. In this chapter we discuss in detail Jacobi polynomials and Gegenbauer polynomials in the complex domain and generalizations for non-integer degrees. The evaluation is either based on recurrence equations or on the hypergeometric function. The computation of the polynomial roots is based on the eigenvalues of the corresponding Jacobi matrix. For all evaluations m-codes are available for download. With respect to computational aspects a superclass is derived with various methods from creating plots up to integrating weighted scalar products of orthogonal polynomials. Due to the huge number of orthogonal polynomials an additional class serving as container for arbitrary orthogonal polynomials is derived. As an application Zernike polynomials are presented. The corresponding programming codes are available for download.
Topics of this chapter are some general aspects of orthogonal polynomials. Orthogonal polynomials have many important applications in physics. Therefore some orthogonal polynomials, e.g., Hermite polynomials, Laguerre polynomials, Legendre polynomials or Chebyshev polynomials, will be discussed in separate chapters. Orthogonal polynomials treated in this chapter are the Jacobi polynomials and the Gegenbauer or ultraspherical polynomials, and as an example Zernike polynomials.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_15
181
182
15.1
15 Orthogonal Polynomials: General Aspects
Function Overview
polymeth The SPECFUNPHYS superclass polymeth comes with some methods common for several orthogonal polynomials. The class orthpoly creates from an arbitrary orthogonal polynomial an object, e.g., to use the methods of polymeth. Jacobi polynomial The SPECFUNPHYS class jacobipoly computes the polynomial coefficients of Jacobi polynomials and the class jacobix evaluates directly without detours about polynomial coefficients the polynomial values. The SPECFUNPHYS function jacobizero computes the zeros of a Jacobi polynomial. Gegenbauer polynomial The SPECFUNPHYS class gegenbauerpoly computes the polynomial coefficients of the Gegenbauer or ultraspherical polynomials. The class gegenbauerx directly evaluates the polynomial values. The SPECFUNPHYS function gegenbauerzero computes the roots of the Gegenbauer polynomial.
15.2
General Definitions
Orthogonal polynomials are playing a crucial rôle in physics under analytical and computational aspects, with many applications, e.g., in quantum- and electrodynamics. The polynomial structure uncovers rather analytical aspects,1 but are not sufficiently computational robust for higher orders. Therefore we will compute both, the polynomial structure and directly the polynomial values. Orthogonal polynomials can be produced by starting with 1, x, x 2 , · · · and employing the Gram–Schmidt orthogonalization process. However, although this is quite general, we took a more elegant approach that simultaneously uncovers aspects of interest to physicists. The following definitions, lemmas, and theorems can be found in [1, 4], applications with respect to quantum dynamics, e.g., in [3]. Also the following discussion is restricted to real variables the polynomials can be continued into the complex domain. In this section we will denote by [a, b] an interval of the real axis, by w(x) a weight function for [a, b], and by φi (x) an orthogonal polynomial of degree i. A function w(x) is called a weight function for [a, b] if and only if w(x) ≥ 0 on [a, b]
b
and
x n w(x)dx = μn
a
exists and remains finite for each n = 0, 1, 2, . . . and μ0 > 0 . The numbers μn defined above are called moments of w(x). The polynomials {φi (x), i =
1 To
uncover the polynomial structure in the corresponding arrays use the MATLAB format rat via >> format rat.
15.2 General Definitions
183
0, 1, 2 · · · n} of degree i are the orthonormal polynomials associated with the weight function w(x) and the interval [a, b] if and only if
b
φi (x)φj (x)w(x)dx = δij
i, j = 0, 1, 2, · · ·
.
(15.1)
a
The inner or scalar product between two function f, g on the interval [a, b] is defined by
b
f, g =
f (x)g(x)w(x)dx
.
(15.2)
a
Because φn (x) is a polynomial of degree n, φn has n roots ({x | φ(x) = 0}), which are real, distinct, and elements of the interval [a,b]. Any polynomial f (x) of degree n can be written as a linear combination {φi (x), i = 0 · · · n}, f (x) =
n
with
ai φi (x)
ai = φi |f i = 0 · · · n .
i=0
By writing the orthogonal polynomial in the following form: φn (x) =
n
ki x i , kn > 0
(15.3)
i=0
a three-term recurrence relation can be derived: xφn−1 (x) =
kn−1 kn−2 φn (x) + φn−2 (x) + βn−1 φn−1 (x) . kn kn−1
(15.4)
This recurrence relation leads to a remarkable proof of the reality of the nodes of the orthonormal sequence {φn (x)}. Let us rewrite (15.4) by the following matrix equation: ⎛ ⎜ ⎜ ⎜ x⎜ ⎜ ⎝
φ0 (x) φ1 (x) φ2 (x) .. . φN−1 (x)
⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠
⎛
k0 k1
0 0 ⎜ k0 β k1 0 ⎜ k1 1 k2 ⎜ 0 kk12 β2 kk23 =⎜ ⎜ ⎜ .. .. .. .. ⎝. . . . 0 0 0 0 β0
⎞⎛ ⎞ ··· 0 φ0 (x) ⎟⎜ ··· 0 ⎟ ⎜ φ1 (x) ⎟ ⎟ ⎟⎜ ⎟ ⎜ φ2 (x) ⎟ ··· 0 ⎟ ⎟⎜ ⎟ .. ⎟⎝ .. ⎠ ⎠ . . φN−1 (x) · · · βN−1
184
15 Orthogonal Polynomials: General Aspects
⎛ ⎜ ⎜ ⎜ +⎜ ⎜ ⎜ ⎝
⎞
0 0 0 .. . kN−1 kN φN (x)
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠
(15.5)
Now suppose we chose x as a node of φN , φN (xi ) = 0, we arrive at the matrix equation: xi φ(xi ) = J φ(xi ),
(15.6)
and hence the eigenvalues of the symmetric tridiagonal matrix J are the zeros of φN (x). J is called the Jacobi Matrix of the orthonormal polynomial. Since J is a symmetric matrix, all eigenvalues and thus all roots of the corresponding orthogonal polynomial are real and can be efficiently computed by solving the eigenvalue problem of tridiagonal matrix. From the matrix equation above we can also derive the Christoffel–Darboux relation N−1 i=0
φi (x)φi (y) =
kN−1 φN−1 (y)φN (x) − φN−1 (x)φN (y) . kN x−y
(15.7)
For completeness we will also mention the Rodrigues formula φn (x) =
1 dn {w(x)s(x)n } w(x) dx n
(15.8)
with s(x) a polynomial in x independent of n. The Rodrigues formula allows to derive directly a sequence of orthogonal polynomials via n-times derivation. It is also possible to generate all orthogonal polynomials of a certain kind from a single two-variable function by repeated differentiation, the generating function of the orthogonal polynomial. Assume that a function g(t, x) fulfills g(t, x) =
∞
an t n φn (x),
(15.9)
n=0
then the orthogonal polynomial φj (x) is (up to normalization) given by φj (x) ∝
dj g(t, x)|t =0. dt j
(15.10)
15.3 The Classes orthpoly and polymeth
185
One application of orthogonal polynomials occurs in quest of numerical integration techniques. Let f (x) be a polynomial of degree ≤ 2n − 1. Then the formula
b
f (x)w(x)dx =
a
n
wi f (xi ),
(15.11)
i=1
with weights wi , and xi the zeros of the orthogonal polynomial φn (x), is called Gauss quadrature.
15.3
The Classes orthpoly and polymeth
15.3.1 The Class orthpoly polymeth comes with several methods available for objects of its subclasses. Subclasses of polymeth with respect to Legendre, Gegenbauer, Jacobi, Hermite, Laguerre, and Chebyshev polynomials will be derived. But there are numerous other orthogonal polynomials of interest, e.g., Zernike polynomials for microscopy application. The class orthpoly allows to create an object from an arbitrary orthogonal polynomial, such that the methods of the class polymeth are supported. The syntax is obj = orthpoly(pc,pn,pint,d) with “pc” either an object of the class orthpoly or the polynomial coefficient as numerical matrix, “pn” the polynomial normalization factor to map an orthogonal polynomial onto an orthonormal one, the integration interval “pint”, and “d” some general information. This input information is then directly mapped to the object properties “polycoef” (pc), “polynorm” (pn), “polyint” (pint), and “info” (d). The output variable “obj” is the class object. Example: Zernike Polynomials The following equations can be found in [5]. There are even and odd Zernike polynomials, defined as Znm (ρ, φ) = Rnm (ρ) cos(mφ) Zn−m (ρ, φ) = Rnm (ρ) sin(mφ)
(even) and
(15.12a)
(odd),
(15.12b)
with n ≥ m, φ the azimuthal angle, ρ the scaled radial distance with 0 ≤ ρ ≤ 1, and the orthogonal polynomials n−m
Rnm (ρ)
=
2
k=0
(−1)k
Γ (n − k + 1) n+m ρ n−2k . Γ (k + 1)Γ 2 − k + 1 Γ n−m − k + 1 2 (15.12c)
186
15 Orthogonal Polynomials: General Aspects
√ The polynomial normalization factor is 2n + 2. The radial polynomials can be evaluated with the SPECFUNPHYS program zernike with syntax [Z, pn, pint, info] = zernike(m, nmax). The input variable “m” is an integer as defined above and “nmax” the maximum n-value under consideration. The output variable “Z” is the radial Zernike polynomial, “pn” the normalization factor, “pint” the integration interval for normalization, and “info” some general information. The following example shows how to generate an object of the superclass polymeth and below how to use the methods of polymeth. m=1; nmax = 7; % input variables for function zernike [Z,pn,pint,info] = zernike(m, nmax); % polynom obj = orthpoly(pc,pn,pint,info);
15.3.2 The Class polymeth polymeth comes with the following methods available for orthogonal polynomial objects: Method plot with syntax plot(obj, n, x, ha). “obj” is the object, all other inputs are optional. “n” (n ≥ 0) is an integer vector whose elements determine the order of the polynomials to be plotted. The default is that all polynomials are plotted. “x” is the region or the polynomial arguments at which the polynomial shall be plotted. For example, for x = [x1, x2] polynomial will be evaluated at 100 evenly spaced points between x1 and x2; in case “wint” has n components the polynomials will be computed at these n values. The default is the property “polyint”. The last input variable “ah” is an axes handle object that will be used for plotting. Method deri with syntax Pder = deri(obj, n) computes the n-th derivative of the orthogonal polynomials. Method polyvalue with syntax [res, n] = polyvalue(obj,x,n). “x” and “n” are optional inputs. “x” is the position at which the polynomials shall be evaluated with the same rules as for method plot. “n” is an integer vector larger than or equal to 1 of the polynomial rows (obj.polycoef) which shall be evaluated. Method opolyprod for computing the product of orthogonal polynomials with syntax [Cprod, prodtab, info] = opolyprod(obj1, ...). For ... = opolyprod(obj) all possible polynomial products will be computed. Additional arguments could be a 2nd object, which must be the second input or name–value pairs. ... = opolyprod(obj1, obj2) all possible combination between object “obj1” and “obj2” will be computed. In case there is no second object as input, “obj2” will be equal to “obj1”. opolyprod(_, ’n1’, [0,1,4]) all possible combinations of the polynomials 0, 1, 4 of obj1 with “obj2” will be computed. opolyprod(_, ’n2’, [0,1,4]) the same but vice versa. The outputs are “Cprod”, the product polynomials, “prodtab” the
15.3 The Classes orthpoly and polymeth
187
polynomials of ob1 and obj2 which are used to build the products and “info” with some general information. Example: obj1 = gegenbauerpoly(pi, 3); % Object 1 and obj2 = jacobipoly(0.75, 1.25, 3); % object 2: Product [Cprod, prodtab, info] = opolyprod(obj1, obj2, ’n1’,... [1,3], ’n2’, 3); >> Cprod Cprod = 2x7 table x6 x5 x4 ... x0 ______ _______ _______ ... _______ Pi1_3 Pi3_3
0 624.38
0 -117.07
43.982 -441.39
... ...
0 0
>> prodtab prodtab = 1 3 3 3
Method opolyint for integrating the polynomials with syntax[Cpint, prodtab, Cpintvalue, info,Cprod] = opolyint(obj, ...), where “obj” is an object of one of the subclasses of polymeth. with ... opolyint(obj) all product combinations of the orthogonal polynomials of the object “obj” will be integrated about the interval given by the property polyint. The following name–value pairs are supported: “’n1”’ together with an integer vector and “’n2’ together with an integer vector. Both are optional with the same meaning as for the method opolyprod. With p1 and p2 two polynomials of the object “obj”, the dn syntax for computing p1 (x)| dx n p2 (x) is ... = opolyint(_,’xd’,n) or “xderivative” instead of “xd”. The syntax for computing p1 (x)|x n p2 (x) is ... = opolyint(_,’xp’,n) or “xpower” instead of “xp”. “n” has to be a positive integer. The integration interval is by default the property “polyint”. In case the interb val shall be changed to a · · · the syntax is ... = opolyint(_,’defint’, [a,b]). For integration with a weight function w(x) the syntax is ... = opolyint(_,’wf’,hwf), with “hwf” the function handle of the weight function. Example % obj1 object of the Gegenbauer polynomial, see above whf = @(x)exp(-x.^2); % weight function [Cpint, prodtab, Cpintvalue, info,Cprod] = ... opolyint(obj1, ’n1’,3,’n2’,3,’wf’,whf); >> Cpintvalue Cpintvalue = table IntVal ______ Pi3_3
387.53
188
15 Orthogonal Polynomials: General Aspects
>> info info = 4x1 cell array {’Gegenbauer Polynomial’ } {’lambda = 3.1416’ } {’Integration with weight function’} {’Integration interval: -1 1’ }
The output variables are: “Cpint” the indefinite Integral of the polynomial product, if it exists. “prodtab” a table of the polynomial orders of the product polynomials, “Cpintvalue” the definite integral values, “info” some general information, and “Cprod” the table of the product of the polynomials before integration. This value could be useful in case of a weight function, because then “Cpint” will be empty. The following example (zernikevisu.m) uncovers the interplay between orthpoly and the methods of polymeth. The result is plotted in Fig. 15.1. phi = linspace(-pi,pi,50); % coordinates for plotting rho = linspace(0,1,50); [Rho, Phi] = meshgrid(rho,phi); x = Rho.*cos(Phi); y = Rho.*sin(Phi); % nf = 0; figure for m = 1:2:5 nf = nf+1; [Z,pn,pint,info] = zernike(m, 5); % Zernike coeff. % orthpoly method polyvalue res=orthpoly(Z,pn,pint,info).polyvalue(rho,6); Rm5 = repmat(res,length(rho),1); Zm5 = Rm5.*cos(m.*Phi); subplot(1,3,nf) surface(x,y,Zm5), shg shading interp end
1
1
1
0.5
0.5
0.5
0
0
0
-0.5
-0.5
-0.5
-1
-1 -1
-0.5
0
0.5
1
-1 -1
-0.5
0
0.5
1
-1
-0.5
0
0.5
1
Fig. 15.1 Zernike polynomials Znm (ρ, φ) color coded. From left to right the azimuthal degree m = 1, 3, 5 and the radial degree n = 5
15.4 Gegenbauer Polynomials
15.4
189
Gegenbauer Polynomials
The Gegenbauer or ultraspherical polynomial Cnλ (x) characterizes the momentum wave function of the Coulomb system in a similar way as the Laguerre polynomials in the coordinate representation. Both are connected with each other by Fourier transformation. The generating function of the Gegenbauer polynomial is (1 − 2ax + a 2 )−λ =
∞
Cnλ (x)a n
(15.13)
.
n=0
Hence for λ = 1/2 the Gegenbauer polynomials equal the Legendre polynomials, see Eq. (3.3), and thus the Cnλ s are generalizations of the Legendre polynomials. The recurrence formula for fixed index λ is λ λ (n + 2)Cn+2 (x) = 2(λ + n + 1)xCn+1 (x) − (2λ + n)Cnλ (x)
,
(15.14)
with C0λ (x) = 1
and C1λ = 2λx
(15.15)
,
and the derivative holds d λ λ+1 C (x) = 2λCn−1 dx n
(15.16)
.
The orthogonality relation is given by
+1 −1
1
λ Cnλ (x)Cm (x)(1 − x 2 )λ− 2 dx = 21−2λ π
Γ (n + 2λ) δnm n!(λ + n)Γ (λ)2
(15.17)
and its Rodrigues equation by Cnλ (x) = (−2)n
1 1 Γ (λ + n)Γ (2λ + n) dn (1 − x 2 ) 2 −λ n (1 − x 2 )n+λ− 2 , n!Γ (λ)Γ (2(λ + n)) dx
(15.18)
and the Cnλ (x) are solutions of the following differential equation:
n(2λ + n) d2 (2λ + 1)x d − + X(x) = 0 dx 2 x 2 − 1 dx x−1
.
(15.19)
190
15 Orthogonal Polynomials: General Aspects
15.4.1 The SPECFUNPHYS Class gegenbauerpoly and gegenbauerx The Class Gegenbauerpoly The syntax of the class gegenbauerpoly is [obj, C] = gegenbauerpoly(lambda, n), with “lambda” an arbitrary complex number (strictly speaking Gegenbauer polynomials are only defined for λ > −0.5) and the polynomial degree “n” a positive integer. The output variables are the object “obj” with properties “polycoef” (table of the polynomial coefficients), “polynorm” (the normalization vector), “polyint” (normalization interval with default [−1, +1]), “info” (some information). The optional output “C” is an array with the polynomial coefficients. Example: >> lambda = 0.7; n = 5; >> [obj, C] = gegenbauerpoly(lambda, n); >> obj obj = gegenbauerpoly with properties: polycoef: [6x6 table] polynorm: [0.5231 0.6889 0.7925 0.8715 0.9365 0.9924] polyint: [-1 1] info: {2x1 cell}
The Class Gegenbauerx The class gegenbauerx serves for the direct computation of the polynomial values. The computation is either based on the recurrence equation (15.14) or its relation to the Gauss hypergeometric function Cnλ (z) =
(2λ)n 1 1−z ). 2 F1 (−n, 2λ + n; λ + ; Γ (n + 1 2 2
(15.20)
The syntax is [obj, Cn] = gegenbauerx(lambda, n, x, wcom), with “lambda” - the Gegenbauer parameter - a scalar floating value and the polynomial degree “n” an integer value for evaluation with the recurrence equation or an arbitrary floating number in case of its relation with the hypergeometric function. “wcom” selects the evaluation method. For wcom = ’2F1’ or “n” noninteger the evaluation will be based on Eq. (15.20), otherwise on the recurrence equation (15.14). If the evaluation is based on the recurrence formula, all polynomials of degree equal to or smaller than “n” are computed. The output variables are the object “obj” and an array with the polynomial values “Cn”. The object “obj” comes with the properties “value” (the polynomial value), “z” (the position at which the function was evaluated), “degree” (the input variable n), “lambda” (the Gegenbauer polynomial parameter), and “info” (with some general information). As an example we discuss the wave function of Hydrogen like atoms in the momentum representation.
15.4 Gegenbauer Polynomials
191
1.5
P( )
1
0.5
0
-0.5
0
1
2
3
4
5
6
7
1 2 ζl Fig. 15.2 Momentum representation of the hydrogen radial part n(n−l−1)! C l+1 (n+l)! (ζ 2 +1)l+2 n−l−1 2 ζ −1 for l = 2 and n = 3 solid line, n = 4 dashed line, n = 5 dotted line, and n = 6 dash–dot ζ 2 +1 line
Example
The wave function of Hydrogen like atoms in the momentum representation [2] is given by
1 (2l + 1)(l − m)! 2 m φnlm (p, θ, φ) = Pl (cos θ ) exp(imφ) 4π(l + m)! 2
1
π22l+4l! n(n − l − 1)! 2 ζl ζ −1 l+1 · C 3 (n + l)! (ζ 2 + 1)l+2 n−l−1 ζ 2 + 1 (γ h) 2
(15.21)
with ζ =
2π p γh
and γ =
Z ; nao
and a0 the Bohr radius and Z the charge. Figure 15.2 shows the result of the non-scaled radial part in momentum representation (hydrogenmom.m): l = 2; % angular momentum lambda = l + 1; nmax = 3; x = linspace(0,7.5); %(x = zeta) xg = (x.^2 - 1)./(x.^2 + 1); xv = x.^l./((x.^2 + 1).^(l+2)); obj = gegenbauerx(lambda, nmax, xg); %% n = obj.degree+l+1; % principal quantum numbers ns = sqrt(n.*gamma(n-l)./gamma(n+l+1));
192
15 Orthogonal Polynomials: General Aspects
%% xg = repmat(xg,size(obj.value,1),1); ns = repmat(ns,1,size(obj.value,2)); prad = xg.*ns.*obj.value; % radial value in % momentum presentation plot(x,prad)
The class gegenbauerx house in addition a plot-method with syntax obj = plot(obj, nl) and “obj” an object of the class gegenbauerx, “nl” an optional integer vector of the polynomial degrees which should be plotted. Default is to plot all Gegenbauer polynomials in quest. Example: obj = gegenbauerx(lambda, n, x).plot([1,3]), thus C1λ (x) and C3λ (x) will be plotted. The SPECFUNPHYS Function Gegenbauerzero The evaluation of the polynomial roots is based on the computation of the eigenvalues of the corresponding Jacobi matrix (15.6) with the MATLAB function eig. The syntax of the SPECFUNPHYS function gegenbauerzero is gbz = gegenbauerzero(lambda, n), with the input variables “lambda” (Gegenbauer parameter), a scalar floating value, and “n” (polynomial degree), a positive integer value and the output variable “gbz”, the position of the polynomial roots. An alternative would be the MATLAB function roots in combination with gegenbauerpoly. For large polynomial degrees, the evaluation via gegenbauerzero shows significantly better results than the evaluation via roots. Example: n = 30; lambda = 4; % Gegenbauer parameter gbz = gegenbauerzero(lambda, n); % roots obj = gegenbauerx(lambda, n, gbz); % polynomial value % at roots and residuum sum(abs(obj.value(end,:)))/length(obj.value(end,:)) ans = 1.33917e-09
For the evaluation via roots this value would be 0.005 and for n = 10 the residuum value would be about 4.5 · 10−12.
15.5
Jacobi Polynomials
The Jacobi polynomials are orthogonal on the interval [−1, 1] with respect to the weight function (1 − x)α (1 + x)β . They follow the three-term recurrence relation (α,β)
2(n + 1)(n + α + β + 1)(2n + α + β)Pn+1 (x) =
(15.22a)
(2n + α + β + 1)[(2n + α + β)(2n + α + β + 2)x + α 2 − β 2 ]Pn(α,β) (x)
15.5 Jacobi Polynomials
193 (α,β)
−2(n + α)(n + β)(2n + α + β + 2)Pn−1 (x) (α,β)
(α,β)
with P−1 (x) = 0, P0
(α,β)
(x) = 1 , and P1
,
1 (x) = [α − β + (α + β + 2)x]; 2 (15.22b)
and at least one of the parameters α, β has to be larger than −1 (strictly speaking α > −1 and β > −1). The generating function of the orthogonal Jacobi polynomial is ∞
Pn(α,β) (x)zn = 2α+β R −1 (1 − z + R)−α (1 + z + R)−β
n=0
with
R=
"
1 − 2xz + z2
(15.23)
|z| < 1 .
From this equation it is straightforward to compute the lowest two contributions to the recurrence relation above. The orthogonality relation is given by
1 1
=
(1 − x)α (1 + x)β Pm(α,β) (x)Pn(α,β) (x)dx
(15.24)
2α+β+1 Γ (n + α + 1)Γ (n + β + 1) δn,m . 2n + α + β + 1 Γ (n + α + β + 1)n!
The Jacobi polynomials are the only integral rational solution of the hypergeometric differential equation, and related to the hypergeometric function via Pn(α,β) (z) =
(α + 1)n 1 2 F1 (−n, 1+α+β +n; α+1; (1−z)), n! 2
z ∈ C.
(15.25)
Many orthogonal polynomials can be treated as a Jacobi polynomial with special index (α, β). One of the most important relations is Pn (x) = Pn(0,0) (x) Tn (x) =
Legendre polynomial ,
22n (n!)2 (−1/2,−1/2) Pn Chebyshev polynomial (2n)!
(15.26a) (15.26b)
and the Gegenbauer polynomial Cnν (x) =
Γ (n + 2ν)Γ (ν + 1/2) (ν−1/2,ν−1/2) Pn (x). Γ (2ν)Γ (n + ν + 1/2)
(15.26c)
194
15 Orthogonal Polynomials: General Aspects
Rodrigues’ equation for the Jacobi polynomial is Pn(α,β) (x) =
n % & (−1)n −α −β d (1 − x)α (1 + x)β (1 − x)n . (1 + x) (1 − x) n n 2 n! dx (15.27a)
The k-th derivative of the Jacobi Polynomial is given by d k (α,β) Γ (α + β + n + 1 + k (α+k,β+k) P Pn (x) = k (x) k dx 2 Γ (α + β + n + 1) n−k
(15.27b)
and the Jacobi Polynomial is a solution of the second order differential equation ! d2 d (1 − x) + n(n + α + β + 1) y(x) = 0. + [β − α − (α + β + 2)x] dx 2 dx (15.27c) 2
15.5.1 The SPECFUNPHYS Class Jacobipoly and Jacobix The SPECFUNPHYS Class Jacobipoly The SPECFUNPHYS class jacobipoly evaluates the polynomial coefficient of the orthogonal Jacobi polynomials based on the recurrence relation (15.22a) with syntax [obj, P] = jacobipoly(alpha, beta, n). The input variables “alpha”, “beta” are floating scalars with at least one unequal −1. “n” is a positive integer. The output variables are the object “obj” with properties “polycoef” (table of the polynomial coefficients), “polynorm” (the normalization vector), “polyint” (normalization interval with default [−1, +1]), “info” (some information). The optional output “p” is an array with the polynomial coefficients. Example: >> alpha = i; beta = pi; n = 7; >> [obj, P] = jacobipoly(alpha, beta, n); >> obj obj = jacobipoly with properties: polycoef: [8x8 table] polynorm: [1x8 double] polyint: [-1 1] info: {3x1 cell}
The SPECFUNPHYS Class Jacobix The class jacobix allows to compute the polynomial values directly, either based on the recurrence equation (15.22a) or on the Gauss hypergeometric function (15.25). The syntax is [obj, Pn] = jacobix(alpha, beta, n, x, wcom). “alpha, beta” are the Jacobi polynomial parameters with at least one value unequal −1 and n either a positive integer or an arbitrary floating number.
15.5 Jacobi Polynomials
195
In the last case the evaluation is based on the hypergeometric function. This is also the case if the optional input variable “wcom” has the value “2F1”. In case the evaluation is based on the recurrence formula all degrees up to the value of n will be computed. The input variable “x” could be an arbitrary complex array. The output variables are the object “obj” and an array with the polynomial values “Pn”. The object “obj” comes with the properties “value” (the polynomial value), “z” (the position at which the function was evaluated), “degree” (the input variable n), “alpha” and “beta” (the Jacobi polynomial parameters), and “info” (with some general information). The class jacobix comes in addition with a plot-method with syntax (equal the gegenbauerx plot-method) obj = plot(obj, nl), “obj” an object of the class and “nl” an optional integer vector of the polynomial degrees which should be plotted. As an application example of the class jacobix we evaluate the Wigner rotation function. Example
The Wigner rotation function can be computed via Jacobi polynomials l dm,m (β) =
(l + m)!(l − m)! (l + m )!(l − m )!
1 2
(cos β/2)m+m (sin β/2)m−m
(m−m ,m+m ) Pl−m (cos β).
(15.28)
The polynomial coefficients and degree are given by the angular momentum l m−m ,m+m l (cos β). and the magnetic quantum numbers m, m by dm,m (β) ↔ Pl−m Figure 15.3 shows an example for m = 2, m = 1, and l = 2 · · · 5, and was evaluated via (wigjacvisu.m):
0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -3
-2
-1
0
1
2
3
l Fig. 15.3 The Wigner rotation function dm,m (β) (β horizontal axis) for m = 2, m = 1, and l = 2 solid line, l = 3 dashed line, l = 4 dotted line, and l = 5 dash–dot line
196
15 Orthogonal Polynomials: General Aspects
n = 3;m=2;ms=1; % basic data, n = l - m alpha = m-ms; % ms == m’ beta = m+ms; theta = linspace(-pi,pi); % theta = angle beta jx = cos(theta); cx = cos(theta/2); sx = sin(theta/2); obj = jacobix(alpha,beta,n,jx);% jacobi polynomial % intermediate calculations l = obj.degree+m; vorf = sqrt(gamma(l+m+1).*gamma(l-m+1)./... (gamma(l+ms+1).*gamma(l-ms+1))); cxmms = cx.^(m+ms); sxmms = sx.^(m-ms); %% correct size for multiplication l = repmat(l,1,length(theta)); vorf = repmat(vorf,1,length(theta)); cxmms = repmat(cxmms,n+1,1); sxmms = repmat(sxmms,n+1,1); %% wigner rotation function djmms = vorf.*cxmms.*sxmms.*obj.value; plot(theta,djmms), shg % visualisation
The SPECFUNPHYS Function Jacobizero The evaluation of the polynomial roots is based on the computation of the eigenvalues of the corresponding Jacobi matrix (15.6) with the MATLAB function eig. The syntax of the SPECFUNPHYS function jacobizero is jaz = jacobizero(alpha, beta, n), with the input variables “alpha”, “beta” (Jacobi polynomial parameters) scalar floating numbers, and “n” (polynomial degree), a positive integer value and the output variable “jaz”, the position of the polynomial roots. An alternative could be again based on the MATLAB function roots in combination with jacobipoly. Example
(on the left-hand side the position of the zeros and right-hand side the corresponding function values): >>jaz=jacobizero(pi,1+i,7) >>obj=jacobix(pi,1+i,7,jaz); jaz = >> obj.value(end,:).’ -0.9207 + 0.0485i 1.0e-13 * -0.0536 - 0.0063i -0.7337 + 0.0769i -0.0299 - 0.0172i -0.4669 + 0.0880i 0.0177 - 0.0331i -0.1487 + 0.0834i 0.0059 - 0.0117i 0.7743 + 0.0216i 0.3504 + 0.1064i 0.1873 + 0.0671i 0.0167 + 0.0024i 0.5058 + 0.0446i -0.0591 - 0.0300i
References
197
References 1. Nikiforov, A.F., Suslov, S.K., Uvarov, V.B.: Classical Orthogonal Polynomials of a Discrete Variable. Springer, Berlin (1991) 2. Podolsky, B., Pauling, L.: The momentum distribution in hydrogen-like atoms. Phys. Rev. 34, 109 (1929) 3. Schweizer, W.: Numerical Quantum Dynamics. Kluwer Academic Publishers, Dordrecht (2001) 4. Szegö, G.: Orthogonal Polynomials. American Mathematical Society, Providence (1975) 5. Wikipedia: Zernike polynomials. (2019). https://en.wikipedia.org/wiki/Zernike_polynomials
Hermite Polynomials
16
Abstract
Topics of this chapter are Hermite polynomials in the complex domain and its generalization to non-integer, complex degrees. The evaluation is either based on recurrence relations or the confluent hypergeometric function. The quantum harmonic oscillator is a particular important quantum system. Therefore in addition code for evaluating the harmonic oscillator wave function is derived, applications like the anharmonic oscillator, Wigner functions in phase space, and coherent states are discussed. Hermite polynomials are orthogonal polynomials. Thus all methods related to orthogonal polynomials can be additionally applied. The corresponding MATLAB code for evaluating Hermite polynomials, respectively, functions, computing their nodes and for all applications mentioned above can be downloaded.
In Chap. 15, we started to discuss orthogonal polynomials. This chapter is intended to introduce Hermite polynomials and some applications. The harmonic oscillator is a particularly important quantum system and its wave function in coordinate or momentum representation can be evaluated with the help of Hermite polynomials. Thus, we discuss in addition the harmonic oscillator eigenfunctions related to Wigner functions, the anharmonic oscillator, and coherent states. I suppose there is no quantum dynamic textbook without discussing the harmonic oscillator.
16.1
Function Overview
Hermite polynomial The SPECFUNPHYS class hermitepoly supports the evaluation of the polynomial coefficients of Hermite polynomials. The SPECFUNPHYS class hermitex allows the computation of the corresponding © The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_16
199
200
16 Hermite Polynomials
polynomial values directly. The function hermitezero returns the roots of the Hermite polynomial based on the corresponding Jacobi matrix. Harmonic oscillator The SPECFUNPHYS class harmonoscwave returns the wave functions of the harmonic oscillator in coordinate representation. Applications As applications we discuss, e.g., the anharmonic oscillator, graphical user interface anha01.m with anha01.fig, oscperex.m, anharmosc.m, the animation of coherent states, cohstates.m, cohstates_animation.m, and the visualization of Wigner functions, wigner2.m.
16.2
Hermite Polynomials
The Hermite polynomial [2] holds the orthogonality relation
+∞ −∞
exp(−x 2)Hn (x)Hm (x) =
√ n π2 n!δnm ,
(16.1)
is, e.g., defined by its Rodrigues formula dn 2 , Hn (x) = (−1)n exp x 2 exp −x dx n
(16.2)
and the generating function reads ∞ Hn (x) n 2 exp 2tx − t = t n!
(16.3)
.
n=0
The following recurrence formula will be used to compute the polynomial coefficients and the polynomial values. Hn+1 (x) = 2xHn (x) − 2nHn−1 (x), with H0 (x) = 1 , H1 (x) = 2x
.
(16.4)
By normalizing the Hermite polynomial 1 H˜ n (x) = π −1/4 √ Hn (x) 2n n!
(16.5)
we obtain x H˜ n (x) =
1√ √ 1√ √ ˜ 2 n + 1H˜ n+1 + 2 nHn−1 (x) , 2 2
(16.6)
16.2 Hermite Polynomials
201
and hence the Jacobi matrix becomes ⎛ ⎞ √ 1 0 2 0 0 0 · · · 2 ⎜ 1 √2 0 1 √0 0 · · · ⎟ ⎜2 ⎟ ⎜ ⎟ 0 1 √0 12 6 √0 · · · ⎟ ⎜ ⎟ JH = ⎜ 1 ⎜ 0 0 2 6 √0 2 · · · ⎟ ⎜ ⎟ ⎜ 2 0 ···⎟ 0 0 0 ⎝ ⎠ .. .. .. .. .. . . . . . . . .
(16.7)
.
The zeros of the Hermite polynomial Hn (x) are given by eigenvalues of Eq. (16.7). The derivative of the Hermite polynomials holds d Hn (x) = 2nHn−1 (x) dx
(16.8)
which leads together with the above recurrence formula to Hn (x) = 2xHn (x) − Hn+1 (x)
(16.9a)
Hn (x) − 2xHn (x) + 2nHn (x) = 0.
(16.9b)
and
Thus the Hermite differential equation is given by y − 2xy + 2ny = 0.
(16.9c)
H2n (x) are even and H2n+1 (x) are odd polynomials in x. Therefore we obtain for the parity of the Hermite polynomial Hn (−x) = (−1)n Hn (x),
(16.10)
and they are connected with the confluent hypergeometric function 1 F1 by
1 2 (2n)! ; x −n, and F 1 1 n! 2
3 2 n (2n + 1)! H2n+1 (x) = (−1) 2 x 1 F1 −n, ; x . n! 2 H2n (x) = (−1)n
Because the Laguerre polynomial holds Lαn (x)
=
n+α n
1 F1 (−n, α
+ 1; x)
(16.11a) (16.11b)
202
16 Hermite Polynomials
we obtain the following connection between Laguerre and Hermite polynomials of definite parity: x2 1/2 H2n+1 (x) = (−1)n 22n+1 n! x Ln x 2 . −1/2
H2n (x) = (−1)n 22n n! Ln
(16.12a) (16.12b)
16.2.1 The SPECFUNPHYS Class hermitepoly The SPECFUNPHYS class hermitepoly returns the polynomial coefficients of the Hermite polynomials. The syntax is [obj, H] = hermitepoly(n, one) with “n” the degree of the Hermite polynomial, thus an integer scalar and “one” optional. For ... = hermitepoly(n) all polynomial coefficients of the Hermite polynomial of degree 0, 1, 2, · · · , n will be evaluated, and for ... = hermitepoly(n, 1) only the polynomial coefficients of the Hermite polynomial of degree n. The output variables are “obj”, the object of the class hermitepoly and the matrix of the polynomial coefficients “H”. The object “obj” comes with the properties “polycoef”, a table of the polynomial coefficients, “polynorm”, the normalization vector, “polyint”, the normalization interval (default [−∞, +∞]), and “info” with some information. As a subclass of polymeth hermitepoly comes with the same methods as polymeth.
16.2.2 Evaluating Hermite Polynomials The SPECFUNPHYS Class hermitex The SPECFUNPHYS class hermitex returns the polynomial values of the Hermite polynomials. The syntax is [obj, Hn] = hermitex(n, x, wcom). The input variable “n” should be an integer and x an arbitrary complex array. “wcom” is an optional input with default value “recurrence”. For ... = hermitex(n, x) all Hermite polynomials of degree n and lower will be evaluated at the positions “x”, based on the recurrence formula (16.4). For ... = hermitex(n, x, ’1F1’) or “n” no positive integer value, the computation will be based on Eq. (16.11) and only the Hermite polynomial of degree n will be computed. Please note, for n no positive integer Eq. (16.11) will be used despite possible other definitions in literature. The output arguments are the object “obj” and the matrix “Hn” of the polynomial values. For degree n the corresponding values are in row n + 1. (The degree starts with n = 0, but MATLAB indexing with 1.) For non-integer n the first row corresponds to H2n+1 and the second row to H2n . The object “obj” comes with the properties “value”, the polynomial values (obj.value is identical Hn), “z”, the position at which the function was evaluated, “degree”, a column vector of the polynomial degrees, and “info” with some information about the evaluation.
16.3 Oscillator Systems
203
The class hermitex house in addition a plot-method with syntax obj = plot(obj, nl) and “obj” an object of the class hermitex, “nl” an optional integer vector of the polynomial degrees which should be plotted. Default is to plot all polynomials in quest. Example: >> x = linspace(-3,3); obj = hermitex(3,x).plot; >> ylim([-50,50]), shg
The SPECFUNPHYS function hermitezero returns the roots of the Hermite polynomials. The syntax is hz = hermitezero(n) with “n” the degree of the Hermite polynomial and “hz” a column vector with the corresponding roots. Example: >> hz = hermitezero(5) hz = -2.0202 -0.9586 0.0000 0.9586 2.0202 >> [obj, Hn] = hermitex(5, hz); % TEST >> Hn Hn = 1.0000 1.0000 1.0000 1.0000 -4.0404 -1.9171 0.0000 1.9171 14.3246 1.6754 -2.0000 1.6754 -41.7150 4.4565 -0.0000 -4.4565 82.5964 -18.5964 12.0000 -18.5964 0 0.0000 0.0000 -0.0000
1.0000 4.0404 14.3246 41.7150 82.5964 0
The roots of the Hermite polynomials play an important role for estimating quantum wave functions via discrete variable computations, see [5, 6].
16.3
Oscillator Systems
The Hamiltonian of the harmonic oscillator is given by
1 d2 1 2 − + x − En ψn (x) = 0 2 dx 2 2
(16.13)
with eigenfunctions 2
x 1 exp − ψn (x) = x|n = √ Hn (x) 1/4 n 2 π 2 n!
,
(16.14)
and Hn (x) the Hermite polynomial of n-th order. As already mentioned above results obtained in the study of oscillator systems are applicable to numerous
204
16 Hermite Polynomials
cases in physics, e.g., vibration of the nuclei in diamagnetic molecules, torsional oscillations in molecules, motion of a muon inside a heavy nucleus, giant resonances in atomic nuclei, to name only a few. The SPECFUNPHYS Class harmonoscwave The SPECFUNPHYS class harmonoscwave returns the eigenfunction of the harmonic oscillator in coordinate representation. The syntax is [obj, wavefun] = harmonoscwave(n, x) with the input arguments “n”, the maximum quantum number of the harmonic oscillator for ´evaluation, thus a positive integer value and “x” the coordinate values at which the wave function shall be evaluated. The output arguments are “wavefun” and the object “obj” with properties “wave”, the values of the wave function at position “x”, “z”, the coordinate values at which the wave function was evaluated (obj.z = x), “degree”, a column vector of the corresponding oscillator quantum numbers, and “info” with some information about the evaluation. The following applications are examples for the various classes and functions mentioned above.
16.3.1 Applications Coherent States Coherent states [1] are minimal uncertainty states, which play an important role in quantum optics. With the ladder operators ⎛# ⎛# ⎞ ⎞ 2 2 1 1 1 1 mω mω ⎝ ⎝ aˆ = √ xˆ + i pˆ ⎠ and aˆ † = √ xˆ − i pˆ ⎠ 2 2m 2 2m h¯ ω h¯ ω (16.15) the Hamiltonian of the harmonic oscillator becomes in Fock space
1 † a ˆ + , (16.16) Hˆ = hω a ˆ ¯ 2 √ with eigenstates |n, Hˆ |n = h¯√ ω(n + 12 )|n, and aˆ † |n = n + 1|n + 1 (raising or creation operator) and a|n ˆ = n|n − 1 (lowering or annihilation operator). Coherent states |α are eigenstates of the annihilation operator aˆ a|α ˆ = α|α, and α ∈ C.
(16.17)
Please note that the ladder operators are non-Hermitian operators and thus the eigenvalue could be complex. In Fock space the coherent state is given by
∞ αn 1 √ |n, |α = exp − |α|2 2 n! n=0
(16.18)
16.3 Oscillator Systems
205
and thus its coordinate representation
∞ αn 1 √ x|n, x|α = exp − |α|2 2 n!
(16.19)
n=0
with x|n = ψn (x) the harmonic oscillator eigenstate. The SPECFUNPHYS function cohstates returns the expansion coefficients of Eq. (16.18), the coherent state in coordinate representation Eq. (16.19) and visualizes the absolute value. The syntax is [cohs, cohsx] = cohstates(alpha, nmax, x) with the input argument “alpha” (coherent states eigenvalue), “nmax” (number of oscillator eigenstates, optional default 100), and “x” √ (optional, coordinate interval). The maximum x0 of α|α is given by x0 = 2|α| cos( (α)) and therefore the default values for “x” are x0 − 5 · · · x0 + 5. In the Schrödinger picture it is straightforward to show that with α(t) = exp(iωt)α(0) → a|α(t) ˆ = α(t)|α(t)
(16.20)
the coherent states are oscillating similar to the corresponding classical system. The SPECFUNPHYS function cohstates_animation(alpha) (h¯ ω = 1) uncovers this similarity. The coordinate resolution becomes insufficient for large absolute values of α > 2π. The program is also of interest from a MATLAB programming point of view, therefore I discuss a few aspects of this program: function cohstates_animation(alpha) % animation of coherent states % alpha coherent state value % example alpha = 1.05 + i*0.75 % cohstates_animation(alpha) nmax = 100; % # of oscillator eigenstates nf = 1:nmax; t = linspace(0,2*pi,100); % time at = alpha*exp(i*t); % time dependence x0 = sqrt(2)*abs(alpha).*cos(angle(alpha)); xl = 5 + abs(imag(alpha)); % coordinate resolution: x = linspace(-xl-abs(x0),xl+abs(x0),500); obj = harmonoscwave(nmax,x); % harmonic osc. states z = 0*x; % -> will be needed for visualisation ng = [1,nf]; k = 0; % counter for frames figure, shg al = at(1); % first frame to create surface object alp = al*ones(size(nf)); alp = [1,alp]; cohs = alp./sqrt(ng); cohs = cumprod(cohs); cohs = exp(-1/2*abs(alpha).^2).*cohs; % coh. s. % Fock representation
206
16 Hermite Polynomials
cohsx = cohs*obj.wave; % coh. s. coordinate repres. y = abs(cohsx); % absolute value for visualisation c = angle(cohsx); % value for color coding the phase surface([x;x],[y;y],[z;z],[c;c],’facecolor’,’none’,... ’edgecolor’,’flat’,’linewidth’,5), colorbar caxis([-pi,pi]);%surface object - color range for phase xlim([x(1),x(end)]) colormap jet gsurf=get(gca,’Children’); % handle surface object k = k+1; F(k) = getframe; % 1st frame for animation for al = at(2:end) % frames for movie alp = al*ones(size(nf)); alp = [1,alp]; cohs = alp./sqrt(ng); cohs = cumprod(cohs); cohs = exp(-1/2*abs(alpha).^2).*cohs; cohsx = cohs*obj.wave; y = abs(cohsx); % update absolute value and c = angle(cohsx); % color for phase gsurf.YData = [y;y]; % update of y-value gsurf.CData = [c;c]; % update of color coding k = k+1; F(k) = getframe; end movie(F,3) % see MATLAB documentation for details
The visualization is based on the MATLAB function surface([x;x],[y;y], [z;z],[c;c],...). Because we have a line object we create matrices by [x;x],... necessary for surface objects. The color coded phase is created via [c;c] and the update in each time step via gsurf.YData = [y;y]; gsurf.CData = [c;c]; with gsurf the corresponding object handle. The Wigner Function in Phase Space In classical dynamics there is no uncertainty principle and thus it is possible to know the position and the momentum of a particle at the same time to an (theoretically) arbitrary precision. This would not be possible in quantum dynamics. Therefore, there exists no phase space representation in quantum dynamics of canonically conjugate variables. Nevertheless, the Wigner function is constructed to come close to this picture. The density operator of a pure state is ρˆ = |ψψ| and in coordinate representation x|ρ| ˆ x ˜ = ψ(x)† · ψ(x, ˜
(16.21)
16.3 Oscillator Systems
207
ˆ = T r[ρˆ A], ˆ and can be used to compute the expectation value of an operator A with T r the trace. We now define the Wigner function as [3, 6] W (q, p) =
1 π h¯
dyq − y|ρ|q ˆ + y exp(2ipy/h¯ ) ,
(16.22a)
dyψ(x + y)ψ † (x − y) exp(2ipy/h¯ ).
(16.22b)
and thus equivalently W (q, p) =
1 π h¯
Integrating the Wigner function in Mock phase space over the momenta results in the probability of presence in coordinate space, and vice versa, integrating over the coordinate space will lead to the probability of presence in momentum space: W (q, p)dp = W (q, p)dq =
|q|ψ|2 |p|ψ|2 .
(16.23)
Additional properties of the Wigner function in phase space can be found in [3] and many text books about quantum optics. The SPECFUNPHYS function wigner2(n) allows to visualize the harmonic oscillator Wigner function, with “n” the harmonic oscillator quantum number. For n > 10 the resolution of the visualization will be insufficient. An example is shown in Fig. 16.1. Programming hints: The resolution of the figure is 401 × 401, thus the harmonic oscillator eigenfunction has to be evaluated at more than 160, 000 points with many repetitions. For large arrays MATLAB comes with the function arrayfun. But due to the many repetitions it is more efficient to use the MATLAB function unique. In addition, because we need only one single harmonic oscillator eigenstate Fig. 16.1 Harmonic oscillator Wigner function for quantum number n = 6. Superimposed is the corresponding classical trajectory in phase space
4
4 3
3 2
2 1
1
0
0
-1
-1
p
-2 -2
-3 -3
-4
q
208
16 Hermite Polynomials
with a small quantum number, it is more efficient to work with the polynomial representation: ... % computation only with unique values [XpYu, iXpYa, iXpYc] = unique(XpY); [XmYu, iXmYa, iXmYc] = unique(XmY); % because the degree should be small and we need only % one single eigenstate we will use hermitepoly [obj, Hpoly] = hermitepoly(n, 1); % HXpY = polyval(Hpoly,XpYu); HXmY = polyval(Hpoly,XmYu); ...
The Anharmonic Oscillator A weak additional potential V (x) to the harmonic oscillator Hˆ0 naturally raises the question: What would be the effect on the harmonic oscillator eigensolution? To approximately study this Hamiltonian system Hˆ = Hˆ0 + V (x)
(16.24)
we compute the potential matrix Vm,n = m|V |n, with |n a harmonic oscillator eigenstate. By interpreting V as matrix function x → V (x) the first step is to evaluate m|x|n, e.g., with the SPECFUNPHYS function [x,E0]=xoscmatrix(ndim) which lives in the private directory.1 “ndim” is the dimension of the matrix, thus a positive integer number equal to or greater than 1. The output arguments are the x-matrix “x” and the diagonal matrix “E0” with the harmonic oscillator eigenvalues. The MATLAB function Vnm = funm(x,V) evaluates the function “V” at the square matrix “x”. Thus, the approximate eigensolutions of Hˆ are given by computing the eigensolutions of the matrix E0 + Vnm with the MATLAB function eig or eigs. As an example we study Hˆ = Hˆ0 + 14 sin(π x), via the SPECFUNPHYS function [En, vn, wellfunah] = oscperex(ndim, nmax), with “ndim” the matrix dimension, “nmax” the number of eigenfunctions for visualization. The output arguments are the eigenvalues “En”, the eigenvectors “vn”, and nmax wave functions in coordinate representation “wellfunah”. Please note, this example is using the MATLAB function eig because the Hamiltonian matrix is no longer sparse; but this does not mean that all computed eigensolutions makes sense. function [En, Vn, wellfunah] = oscperex(ndim, nmax) % ndim = 100: Matrix dimension % nmax number of eigenvectors for visualisation % nmax = 5 1 Functions
folder.
in private directories are only available to functions or scripts that reside in the parent
16.3 Oscillator Systems
209
[xm, E0] = xoscmatrix(ndim);% ... sinx = funm(pi*xm, @sin); % Hm = E0 + sinx/4; % [V, D] = eig(Hm); % En2 = diag(D); [En, enind] = sort(En2); % Vn = V(:,enind); obj = harmonoscwave(ndim-1);% x = obj.z; wavefun = obj.wave; wavefun = wavefun.’; Vvisu = V(:,1:nmax); wellfunah = wavefun*Vvisu; % ...
x-matrix:xm matrix operation matrix for eigensolution eigensolution - unsorted eigensolution - sorted harm. osc. wave functions
Matrixmultiplikation
2nd Example: The Hamiltonian of the quartic anharmonic oscillator reads
3/2 C 1 h¯ h¯ (aˆ † + a) ˆ 3 + D 2 3 (aˆ † + a) ˆ 4 , Hˆ = h¯ ω (aˆ † aˆ + ) + 2 h¯ ω 2mω 4m ω 1 8
√
2κ
(16.25)
1 8λ
with 1/2κ and 1/2λ are the prefactors to x 3 , respectively, x 4 for h¯ = 1 = m. 1 1 Hˆ = Hˆ0 + κ x 3 + λ x 4 λ ≥ 0. 2 2
(16.26)
In first-order perturbation theory we get for the energy 1 3 En ≈ h¯ ω n + + λ(2n2 + 2n + 1) 2 8
,
(16.27)
and because of n|(aˆ † + a) ˆ 3 |n = 0 the energy does not undergo an alteration due to the cubic potential in first order. For even potentials V (x) = −V (x) eigenfunctions of even and odd parity do not mix and the computation can be optimized by projecting on the even, respectively, odd subspace. For vanishing fourth order term the potential curve will undergo a maximum so that the bound states die out at higher energy. Strictly speaking even the low lying states become quasi bound by coupling to the continuum via tunneling. By complex coordinate rotation [4, 6] one could take care of the 3rd order potential term. The SPECFUNPHYS function [E,V,testwav]=anharmosc(kappa,lambda,hmany,ndim,no,s) approximates the eigensolutions of the anharmonic oscillator by diagonalization with the MATLAB function eigs. “kappa” and “lambda” are the potential parameters, “hmany” are the number of requested eigensolutions, the matrix dimension (default 50) is given by the optional input argument “ndim”, if “no”
210
16 Hermite Polynomials
(optional, default “yes”) has the value “no” no wave function will be plotted, and “s” (optional) is the coordinate vector for visualizing the wave functions with default 2000 equidistant values between −5 · · · 5. The output arguments are “E” the energy eigenvalues, “V” the corresponding eigenvector and “testwave” the relative smallest contribution to each eigenvector. This should be a small number. A typical example is >> kappa = 0.2; lambda = 1; hmany = 5; ndim = 35; [E,V, tw] = anharmosc(kappa, lambda, hmany, ndim);
The graphical user interface >> anha01 uncovers the changes of the first two eigenfunctions in dependence of λ, κ and should be self-explanatory.
References 1. Cohen-Tannoudji, C., Diu, B., Laloe, F.: Quantum Mechanics. Hermann, Paris (1977) 2. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt A. M. (1981) 3. Hillery, M., O’Connell, R.F., Scully, M.O., Wigner, E.P.: Distribution functions in physics: fundamentals. Phys. Rep. 106, 121 (1984) 4. Ho, Y.K.: The method of complex coordinate rotation and its application to atomic collision processes. Phys. Rep. 99, 1 (1983) 5. Nikiforov, A.F., Suslov, S.K., Uvarov, V.B.: Classical Orthogonal Polynomials of a Discrete Variable. Springer, Berlin (1991) 6. Schweizer, W.: Numerical Quantum Dynamics. Kluwer Academic Publishers, Dordrecht (2001)
Laguerre Polynomials
17
Abstract
Topics of this chapter are the generalized or associated Laguerre polynomials in the complex domain and its generalization to non-integer degrees via confluent hyperspherical functions. Laguerre polynomials play an important role in quantum dynamics, e.g., in solving the radial Schrödinger equation for Coulomb potentials. Code for evaluating Laguerre polynomials, respectively, functions, the nodes of the polynomials, and the radial wave function can be downloaded. The Laguerre polynomials are orthogonal polynomials, thus additional methods are available.
Topics of this chapter are the generalized or associated Laguerre polynomials. Laguerre polynomials play an important role in quantum dynamics, e.g., in solving the radial Schrödinger equation for Coulomb potentials. In addition, Laguerre meshes, based on the roots of the generalized Laguerre polynomials, are used in approximation techniques. Function Overview The SPECFUNPHYS class laguerrepoly supports the evaluation of the polynomial coefficients and the SPECFUNPHYS class laguerrex returns the polynomial values directly. The SPECFUNPHYS function laguerrezero returns the roots of the corresponding Laguerre polynomial and Hrad allows to compute the radial wave function for Coulomb-like potentials.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_17
211
212
17 Laguerre Polynomials
17.1
Laguerre Polynomials
17.1.1 General Aspects Generalized Laguerre polynomials Lαn (x), n = 0, 1, · · · are polynomials of degree n in x. Its Rodrigues equation [1, 2] is given by Lαn (x) =
exp(x)x −n d n (exp(−x)x n+α ) n! dx n
(17.1)
.
Please note, there are different definitions and scaling factors in literature. Generalized Laguerre polynomials play an important rôle as part of the solution of the radial Schrödinger equation
l(l + 1) Z 1 d2 − E Rnl (r) = 0 + − − 2 dr 2 2r 2 r
(17.2)
,
with #
Rnl (r) =
2Z na0
3
(n − l − 1)! l 2Zr ρ exp(−ρ/2)L2l+1 , n−l−1 (ρ), with ρ = 2n (n + l)! na0 (17.3)
and a0 the Bohr radius, Z the atomic number, n the principal quantum number, and l the angular momentum. The orthogonality relation for the generalized Laguerre polynomials reads
∞ 0
exp(−x)x α Lαn (x)Lαn dx =
Γ (n + α + 1) δnn n!
(17.4)
.
The following recursion relation allows a numerically stable evaluation of the Laguerre polynomial for a given parameter α: Lαn+1 (x) =
1 (2n + α + 1 − x)Lαn (x) − (n + α)Lαn−1 (x) n+1
,
(17.5)
with Lα0 (x) = 1,
Lα1 (x) = 1 + α − x
.
(17.6)
As discussed for orthogonal polynomials in general, the equation above can be mapped on a recurrence formula for normalized generalized Laguerre polynomials to derive the corresponding Jacobi matrix. The roots of the generalized Laguerre polynomials are given by the eigenvalues of this matrix. The Jacobi matrix for the
17.1 Laguerre Polynomials
213
generalized Laguerre polynomial Lαn (x) becomes ⎛
√ 1+α − 1+α 0 0 0 √ √ ⎜− 1 + α 3 + α − 2(2 + α) 0 0 ⎜ √ √ ⎜ 0 − 2(2 + α) 5 + α − 3(3 + α) 0 ⎜ √ √ Lαn = ⎜ ⎜ 7 + α − 4(4 + α) 0 0 − 3(3 + α) ⎜ √ ⎜ 9+α 0 0 0 − 4(4 + α) ⎝ .. .. .. .. .. . . . . .
⎞ ··· ···⎟ ⎟ ⎟ ···⎟ ⎟ ···⎟. ⎟ ···⎟ ⎠ .. . (17.7)
The generating function of the generalized Laguerre polynomial is given by (1 − t)
−(1+α)
∞ Lαn (x) n xt = t exp − 1−t n!
(17.8)
n=0
and its derivative by d α L (x) = −Lα+1 n−1 (x) . dx n
(17.9)
The Laguerre polynomials are related to the confluent hyperbolic function via Lαn (z)
=
n+α n
1 F1 (−n, α
+ 1; z).
(17.10)
17.1.2 Related Programs The SPECFUNPHYS class laguerrepoly returns the polynomial coefficients of the generalized or associate Laguerre polynomials. The syntax is [obj, La] = laguerrepoly( alpha,n), with the input arguments “alpha” (arbitrary floating scalar), and the degree of the generalized Laguerre polynomial “n”, an integer scalar value. The output arguments are the object “obj” of the class and the matrix of the polynomial coefficients. The object “obj” comes with the properties “polycoef”, a table of the polynomial coefficients, “polynorm”, the normalization vector, “polyint”, the normalization interval (default [0, +∞]), and “info” with some information. As a subclass of polymeth laguerrepoly comes with the same methods as polymeth. The SPECFUNPHYS class laguerrex returns the polynomial values of corresponding generalized Laguerre polynomial. The syntax is [obj, Ln] = laguerrex(alpha, n, x, wcom) with the input arguments “alpha” and “n” (see above), and “x” (an arbitrary array) the position at which the polynomials will be evaluated. For ... = laguerrex(alpha, n, x) and “n” integer
214
17 Laguerre Polynomials
all polynomials with degree smaller or equal n will be evaluated. For n noninteger or ... = laguerrex(alpha, n, x, ‘1F1’) the evaluation will be based on the confluent hypergeometric function and only the polynomial with degree n will be evaluated. The output variables are the class object “obj” and the matrix of the polynomial values “Ln”. “obj” comes with the properties value, the polynomial values. For n positive integer and obj = laguerrex(alpha, n, x) obj.value is a matrix where each row belongs to a fixed degree running through all polynomial values. The first row corresponds to degree 0, and the last to n. In case the evaluation is based on the confluent hypergeometric function obj.value will have the same structure as the input “x”. The property “z” is the position at which the polynomial was evaluated, “degree” is the polynomial degree and “alpha” its parameter, “info” are some general information. The output argument “Ln” is identical to the property “value”. laguerrex comes in addition with the method “plot”, with syntax obj = plot(obj, nl) and “obj” an object of the class, “nl” an optional integer vector of the polynomial degrees which should be plotted. Default is to plot all polynomials in quest. Example: >> x = linspace(0,10); obj = laguerrex(1,3,x).plot; shg
The SPECFUNPHYS function laguerrezero with syntax lnaz = laguerrezero(alpha, n) returns the roots “lnaz” of the generalized Laguerre polynomial Lαn with the input arguments “alpha” and “n”; “n” has to be an integer scalar 0, 1, 2, · · · . The radial wave function Rn,l (r), Eq. (17.3), can be computed with the SPECFUNPHYS function Hrad: [Rnl, x, rho, n, l] = Hrad(n,l,rho, Z). “n” is the principal quantum number, thus an integer starting with 1, “l” the angular momentum, “rho” the radial coordinate scaled with the Bohr radius a0 and Z the atomic number (1 for the Hydrogen atom). “rho” and “Z” are optional with default values 0 · · · 7 and Z = 1. The output arguments are “Rnl” the values of the radial wave function, “n” and “l” the principal quantum number and angular momentum, “x”= 2Zrho n , and “rho” equals the input argument “rho”. (The normalized hydrogen wave function is written as ψnlm (r, ϑ, φ) = Rn,l (r)Ylm (ϑ, φ).)
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover, New York (1972) 2. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt A. M. (1981)
Chebyshev Polynomials
18
Abstract
The topics of this chapter are Chebyshev polynomials of 1st, 2nd, 3rd, and 4th kind. Arbitrarily shifted polynomials will be discussed as well as extensions into the complex domain. The polynomials can be generalized to functions with complex degree. The evaluation could be based on recurrence relations, on hypergeometric functions or on trigonometric series with generalizations to the complex domain via conformal mapping. Code for evaluating the Chebyshev polynomials, respectively, functions and their nodes can be downloaded. Additional methods of orthogonal polynomials are supported.
The topics of this chapter are Chebyshev polynomials, named after Pafnuty Chebyshev, a Russian nineteenth century mathematician. In literature there are alternative transliterations of his name used, e.g., Tschebyscheff or Tchebyshev. Chebyshev polynomials are orthogonal polynomials and play an important rôle, e.g., in polynomial interpolation and approximation theory, or in solving integral equations, filter techniques and constructing wavelets. Function Overview The SPECFUNPHYS class chebypoly returns the polynomial coefficients of the Chebyshev polynomials and shifted Chebyshev polynomials of 1st, 2nd, 3rd, and 4th kind. The SPECFUNPHYS class chebyx supports the computation of the Chebyshev polynomials, the shifted Chebyshev polynomials and arbitrarily shifted polynomials and functions of 1st, 2nd, 3rd, and 4th kind based on different methods. The Chebyshev polynomials can be extended to functions (non-integer degree) and the complex domain. The SPECFUNPHYS function chebyzero returns the nodes of the Chebyshev polynomials.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_18
215
216
18.1
18 Chebyshev Polynomials
Basic Properties and Formulae
The following equations can be found, e.g., in [1, 2].
18.1.1 Definition and Recurrence Formula The Chebyshev polynomial of first kind Tn (x) is a polynomial in x of degree n, defined by Tn (x) = cos(nϑ) , with x = cos(ϑ) and ϑ ∈ [π, 0].
(18.1a)
Similar the Chebyshev polynomial of second kind Un (x) is defined by Un (x) =
sin((n + 1)ϑ) , with x = cos(ϑ) and ϑ ∈ [π, 0], sin(ϑ)
(18.1b)
the Chebyshev polynomial of third kind Vn (x) is defined by Vn (x) =
cos((n + 12 )ϑ) cos( 12 ϑ)
, with x = cos(ϑ) and ϑ ∈ [π, 0],
(18.1c)
and finally the Chebyshev polynomial of fourth kind Wn (x) is defined via Wn (x) =
sin((n + 12 )ϑ) sin( 12 ϑ)
, with x = cos(ϑ) and ϑ ∈ [π, 0].
(18.1d)
Figure 18.1 shows as an example the Chebyshev polynomials up to degree 3. It is straightforward to derive from the trigonometric identities for multiply angels the recurrence equation Cn (x) = 2x Cn−1 (x) − Cn−2 (x) , n = 2, 3, · · · , and
(18.2a)
Cn are the Chebyshev polynomials of degree n, thus Cn (x) = Tn (x) or = Un (x) or = Vn (x) or = Wn (x), and the initial polynomial values are T0 (x) = 1 , T1 (x) = x ;
U0 (x) = 1 , U1 (x) = 2x
V0 (x) = 1 , V1 (x) = 2x − 1 ;
(18.2b)
W0 (x) = 1 , W1 (x) = 2x + 1. (18.2c)
18.1 Basic Properties and Formulae
217
Cebyshev Polynomial of 1st kind 1
4 T0 T1 T2 T3
0.5
Cebyshev Polynomial of 2nd kind U0 U1 U2 U3
2
0
0
-0.5
-2
-1
-4
-1 5
-0.5
0
0.5
1
Cebyshev Polynomial of 3rd kind
-1
8 6
0 4
0
0.5
1
W0 W1 W2 W3
2
V0 V1 V2 V3
-5
-0.5
Cebyshev Polynomial of 4th kind
0
-10
-2 -1
-0.5
0
0.5
1
-1
-0.5
0
0.5
1
Fig. 18.1 Visualization of the Chebyshev polynomials of degree 0 · · · 3. The plots were created via chebyx(n,x,’T’).plot, grid on, shg with n = 3 and −1 ≤ x ≤ 1
The Chebyshev polynomials are orthogonal
+1 −1
Cn (x)Cm (c)w(x) = δn,m Cn 2
(18.3a)
with respect to the following weight functions w(x) and norms Cn 2 : 1 π :n=0 and Tn 2 = for Tn (x) : w(x) = √ 2 π/2 :n>0 1−x " 1 for Un (x) : w(x) = 1 − x 2 and Un 2 = π 2 √ 1+x for Vn (x) : w(x) = √ and Vn 2 = π 1−x √ 1−x for Wn (x) : w(x) = √ and Wn 2 = π. 1+x
(18.3b) (18.3c) (18.3d) (18.3e)
218
18 Chebyshev Polynomials
18.1.2 The Shifted Chebyshev Polynomials For many applications the range [0, 1] is more convenient to use than [−1, 1]. Thus we map the independent variable x onto 2x −1 and label the Chebyshev polynomials by an additional star Cn∗ (x) = Cn (2x − 1), with
C ∈ {T , U, V , W }.
(18.4)
The recurrence relation becomes ∗ ∗ (x) − Cn−2 (x) , n = 2, 3, · · · , Cn∗ (x) = (4x − 2) Cn−1
(18.5a)
and the initial polynomial values are T0∗ (x) = 1 , T1∗ (x) = 2x − 1 ;
U0∗ (x) = 1 , U1∗ (x) = 4x − 2
V0∗ (x) = 1 , V1∗ (x) = 4x − 3 ;
W0∗ (x) = 1 , W1∗ (x) = 4x − 1. (18.5c)
(18.5b)
The shifted Chebyshev polynomials are orthogonal
+1 0
∗ Cn∗ (x)Cm (c)w(x) = δn,m Cn∗ 2
(18.6a)
with respect to the following weight functions w(x) and norms Cn∗ 2 : 1 for Tn∗ (x) : w(x) = √ x − x2 " for Un∗ (x) : w(x) = x − x 2 for Vn∗ (x) : w(x) = for
Wn∗ (x)
: w(x) =
and Tn∗ 2 =
π :n=0 π/2 : n > 0
(18.6b)
and Un∗ 2 =
1 π 8
(18.6c)
x 1−x
and Vn∗ 2 =
1 π 2
(18.6d)
1−x x
and Wn∗ 2 =
1 π. 2
(18.6e)
General Range More generally, Chebyshev polynomials as well as other orthogonal polynomials can be transformed to any given range [a, b] via s(x) =
2x − (a + b) , with x ∈ [a, b] and s ∈ [−1, 1], b−a
(18.7)
18.2 Computational Aspects and Programs
219
thus, e.g., Tn[a,b] (x) = Tn (s(x)).
(18.8)
18.1.3 Miscellaneous For completeness a few additional equations: The Rodrigues equation for the Chebyshev polynomials reads Tn (x) =
1 dn (−1)n 2n n! " 1 − x 2 n (1 − x 2 )n− 2 (2n)! dx
(18.9a)
1 1 dn (−1)n 2n (n + 1)! √ (1 − x 2 )n+ 2 n 2 (2n + 1)! dx 1−x ' ( n n (−1) 2 n! 1 − x d n 2 n 1+x Vn (x) = (1 − x ) (2n)! 1 + x dx n 1−x ' ( (−1)n 2n n! 1 + x d n 2 n 1−x (1 − x ) . Wn (x) = (2n)! 1 − x dx n 1+x
Un (x) =
(18.9b) (18.9c)
(18.9d)
The Chebyshev polynomials are solutions of the second order differential equation 2 d 2 d 2 + n Tn (x) (1 − x ) 2 − x dx dx 2 d 2 d + n(n + 2) Un (x) (1 − x ) 2 − 3x dx dx d2 d + n(n + 1) Vn (x) (1 − x 2 ) 2 − (2x − 1) dx dx 2 d d + n(n + 1) Wn (x) (1 − x 2 ) 2 − (2x + 1) dx dx
18.2
= 0,
(18.10a)
=0
(18.10b)
= 0 and
(18.10c)
= 0.
(18.10d)
Computational Aspects and Programs
18.2.1 Computational Aspects The evaluation of the Chebyshev polynomials could be based on the recurrence formula above or on the direct evaluation of the corresponding trigonometric relations. By extending the Chebyshev polynomials outside the range [−1, 1] on the real axis, the trigonometric functions will be mapped on the corresponding
220
18 Chebyshev Polynomials
hyperbolic functions. These equations can be generalized to the complex domain via conformal mapping. For details see [2]. With z ∈ C the equations read " " 1 (z + (z + 1)(z − 1) )n + (z − (z + 1)(z − 1) )n , 2 √ √ 1 (z + (z + 1)(z − 1) )n − (z − (z + 1)(z − 1) )n Un−1 (z) = √ 2 (z + 1)(z − 1) √ √ (z + (z + 1)(z − 1) )n+1 + (z − (z + 1)(z − 1) )−n Vn (z) = √ and z + (z − 1)(z + 1) + 1 √ √ (z + (z + 1)(z − 1) )n+1 − (z − (z + 1)(z − 1) )−n Wn (z) = √ . z + (z − 1)(z + 1) − 1 Tn (z) =
(18.11a) (18.11b) (18.11c) (18.11d)
Even for non-integer values of n Eq. (18.11) gives the same results as the corresponding hypergeometric functions. The Chebyshev polynomials are related to the Jacobi polynomials [3] via (− 12 ,− 12 )
Tn (x) = Pn
(− 12 ,− 12 )
(x)/Pn
( 12 , 12 )
Un (x) = (n + 1)Pn
(x)/Pn
( 21 ,− 12 )
Vn (x) = (2n + 1)Pn (− 12 , 21 )
Wn (x) = Pn
(x)/Pn
(18.12b)
(1),
( 12 ,− 12 )
(x)/Pn
(− 12 , 12 )
(18.12a)
(1),
( 12 , 12 )
(1) and
(1).
(18.12c) (18.12d)
Thus, from Eq. (15.25) we get the Chebyshev functions 1 1−z ), Ta (z) = 2 F1 (−a, a; ; 2 2 3 1−z Ua (z) = (a + 1) 2 F1 (−a, a + 2; ; ), 2 2 1 1−z Va (z) = 2 F1 (−a, 1 + a; ; ) and 2 2 3 1−z Wa (z) = (2a + 1) 2 F1 (−a, 1 + a; ; ), 2 2
(18.13a) (18.13b) (18.13c) (18.13d)
18.2 Computational Aspects and Programs
221
with z ∈ C and a an arbitrary complex index. Equation (18.11) are the basis of the direct computation, and Eq. (18.13) of the computation via hypergeometric functions. Shifted Chebyshev polynomials or functions will be computed by transforming the arguments x → s(x) accordingly. The roots of the Chebyshev polynomials can be easily derived from their trigonometric representation. For example, due to Eq. (18.1a) the roots of the Chebyshev polynomial of first kind are given by nϑ = π2 . Thus we get for kπ ) , k = −(2n − 1), −(2n − 3), · · · , −1, (18.14a) 2n (n − k + 1)π Un (xr ) = 0 for xr = cos( ) , k = 1, 2, · · · , n, (18.14b) n+1 Tn (xr ) = 0 for xr = cos(
Vn (xr ) = 0 for xr = cos( Wn (xr ) = 0 for xr = cos(
(n − k + 12 )π n+
1 2
(n − k + 1)π n+
1 2
) , k = 1, 2, · · · , n and
(18.14c)
) , k = 1, 2, · · · , n.
(18.14d)
18.2.2 Programs The Class chebypoly The SPECFUNPHYS class chebypoly returns the polynomial coefficients of the Chebyshev polynomials and shifted Chebyshev polynomials. As a subclass of polymeth it comes with same methods as polymeth. The syntax is [obj, C] = chebypoly(n, wcheby). The input argument “n” is the maximum degree of the polynomials, a positive scalar integer. The optional input argument “wcheby” with default value “T” is a scalar character and tells chebypoly which Chebyshev polynomial shall be evaluated. Possible values are • • • • • • • •
“T” Chebyshev Polynomial of first kind (default) “U” Chebyshev Polynomial of second kind “V” Chebyshev Polynomial of third kind “W” Chebyshev Polynomial of fourth kind “Ts” shifted Chebyshev Polynomial of first kind T* “Us” shifted Chebyshev Polynomial of second kind U* “Vs” shifted Chebyshev Polynomial of third kind V* “Ws” shifted Chebyshev Polynomial of fourth kind W*
222
18 Chebyshev Polynomials
The output arguments are the class object “obj” and an array of the polynomial coefficients “C”. The rows run from degree equal to 0 up to the maximum value n, and the columns are from right to left the coefficient to x 0 , x 1 , · · · x n . The object “obj” comes with properties “polycoef”, a table of the polynomial coefficients, “polynorm”, a vector of the norm, “polyint”, the normalization interval (value either [−1, +1] or [0, 1] for the shifted Chebyshev polynomials, and “info”, with the information about the kind of polynomial. The Class chebyx The SPECFUNPHYS class chebyx returns the polynomial values by choosing one of the computational methods listed above. The syntax is [obj, P] = chebyx(n, x, wcheby, wcom, grtrafo) with input arguments “n”, the maximum degree of the Chebyshev polynomial; “x”, the position at which the polynomials shall be evaluated (optional with default values −1 · · · + 1 for Chebyshev polynomials and 0 · · · 1 for shifted Chebyshev polynomials). “wcheby” to select the polynomial in quest with default value “T”; for the possible values see chebypoly. “wcom” (optional) serves for selecting the computational method for the polynomial evaluation. Default value is “rec”, and the evaluation is based on the recurrence equations; for “direct” or “d” the evaluation is based on Eqs. (18.11) and for “2F1” the evaluation is based on the representation of the polynomials via Gauss hypergeometric functions, Eqs. (18.13). Whereas for convenience the shifted Chebyshev polynomials can be evaluated by selecting the corresponding name (see chebypoly above), general shifted polynomials, Eq. (18.7), can be computed with the help of the optional input argument “grtrafo” a two-component real vector of the scaling interval [a, b]. Example, see Fig. 18.2: % Visualization of T(x) scaled versus non-scaled n = 3; % polynomial degree x = linspace(-0.5,1.5); % position for % evaluation gr = [-0.5,1.5]; % scaling interval % the non-scaled polynomial: yT = chebyx(n, x, ’T’, ’d’).value; % scaled with respect to gr: yTgr = chebyx(n,x,’T’, ’d’, gr).value; figure, plot(x,yT,x,yTgr), shg legend(’T’, ’T-s’)
The output arguments are the class object “obj” and an array of the polynomial values “C”. The object comes with the properties “value”, the polynomial values and C = obj.value. “z”, the position at which the function was evaluated, “degree”, the input value n (degree of the polynomial) and “info” with information about the evaluation method and the Chebyshev polynomial.
18.2 Computational Aspects and Programs
223
10 T T-s
8
fun
6 4 2 0 -2 -0.5
0
0.5
1
1.5
x
Fig. 18.2 Visualization of the Chebyshev polynomial of first kind T3 (x). Solid line: the nonscaled polynomial; dotted line: scaled with respect to the interval [−0.5, 1.5], see also Fig. 18.1
The Function chebyzero The SPECFUNPHYS function Cz = chebyzero(n, wcheby, grtrafo) returns the roots of the selected Chebyshev polynomial. The input arguments are the polynomial degree “n”, a positive integer scalar; the character “wcheby” (optional) to select the Chebyshev polynomial in quest with default value “T” (for supported values see chebypoly above), and the optional argument “grtrafo” for general coordinate transformation, see chebyx. The output argument “Cz” is a row vector of the corresponding roots. Thus, e.g., Cz = chebyzero(5) returns the roots of the Chebyshev polynomial of first kind and degree 5 T5 (x), and Cz = chebyzero(5, ’U’, [-3, 3]) the roots of the Chebyshev polynomial of second kind and degree 5, scaled with respect of the integral [−3, 3] U5[−3,3] (x). Example: Approximation via Chebyshev Polynomial Chebyshev polynomials are quite frequently used to approximate data. Any orthogonal polynomials or other function families could be used in a similar way. The MATLAB example below is not restricted to Chebyshev polynomials. Let us assume x is a parameter vector and y(x) the measurement data. With A(x) · a = y, a is given by a = AL (x)−1 y and AL the left inverse matrix of A. (A must not necessarily have an inverse). In MATLAB the left inverse will be estimated with the backslash operator. In our example the matrix A is given by ⎛
T0∗ (x1 ) T1∗ (x1 ) T2∗ (x1 ) ⎜ T ∗ (x2 ) T ∗ (x2 ) T ∗ (x2 ) 1 2 ⎜ 0 A=⎜ ⎝ ... ... ... T0∗ (xm ) T1∗ (xm ) T2∗ (xm )
⎞ · · · Tn∗ (x1 ) · · · Tn∗ (x2 ) ⎟ ⎟ ⎟, .. . ... ⎠ · · · Tn∗ (xm )
(18.15)
224
18 Chebyshev Polynomials 0.025
y
1.8 1.6
0.02
1.4 0.015 1.2 0.01
1
0.005
0.8 0.6
0
0.2
0.4
0.6
x
0.8
1
0
0
0.5
x
1
Fig. 18.3 Approximation with Chebyshev polynomial Tn∗ (x), n = 0 · · · 7. On the left-hand side the original data (solid line) and the approximated data (dashed line). On the right-hand side the deviation δ
with n the maximum polynomial degree and m the number of data. The result for the scaled Chebyshev polynomial of first kind is plotted on Fig. 18.3. The residuum δ = |A · a − y| is plotted on the right-hand side. The MATLAB program reads % data x = linspace(0,1,50).’;
% dummy parameter data % dummy measurement data y = polyval(randn(1,7),x) + randn(size(x))/100; % Chebyshev polynomial value T* n = 7; % polynomial degree for approximation obj = chebyx(n,x,’Ts’); % polynomial values % approximation A = rot90(obj.value); % matrix for least square fit a = A\y; % coefficient vector % test and visualization ytest = A*a; delta = abs(y-ytest); subplot(1,2,1), plot(x,y,x,ytest) subplot(1,2,2), bar(x,delta)
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover, New York (1972) 2. Mason, J.C., Handscomb, D.C.: Chebyshev Polynomials. Chapman & Hall, London (2003) 3. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders, B.V. (eds.): NIST Digital Library of Mathematical Functions. (2017). http://dlmf.nist.gov. Rel. 1.0.17
Bernoulli and Euler Polynomials
19
Abstract
Focus of this chapter are Bernoulli numbers and polynomials, and Euler numbers and polynomials in the complex domain. For the evaluation several methods can be used in dependence of the polynomial degree and argument: Direct integration, direct integration in combination with argument transformations, or expansions with respect to trigonometric series. Corresponding MATLAB code can be downloaded.
Focus of this chapter are Bernoulli numbers and polynomials, and Euler numbers and polynomials. Applications can be found, e.g., in statistical physics. Function Overview Bernoulli The SPECFUNPHYS class bernn returns the Bernoulli numbers and the SPECFUNPHYS class bernpoly the corresponding polynomial coefficients. The SPECFUNPHYS class bernx allows the evaluation of Bernoulli polynomials. The computation is not restricted to the interval [0, 1], but complex numbers are only supported for the polynomial representation. Euler The SPECFUNPHYS class eulen returns the Euler numbers and the SPECFUNPHYS class eulepoly the corresponding polynomial coefficients. The SPECFUNPHYS class eulex supports the direct evaluation of Euler polynomials. The computation is not restricted to the interval [0, 1], but complex numbers are only supported for the polynomial representation. Methods The SPECFUNPHYS class bepolymeth comes with additional methods (plot and computing the n-th derivative) for the classes bernpoly and eulepoly, and bexplot with an additional plot-method for bernx and eulex.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_19
225
226
19.1
19 Bernoulli and Euler Polynomials
Bernoulli Numbers and Bernoulli Polynomials
19.1.1 Equations Some Bernoulli numbers and Bernoulli polynomials are, e.g., listed in [1, 2] as well as most of the following equations. The generating function for the Bernoulli polynomials Bn (x) reads ∞
t exp(x t) tn = Bn (x) . exp(t) − 1 n!
(19.1)
n=0
Thus, e.g., B0 (x) = 1,
1 B1 (x) = x − , 2
1 B2 (x) = x 2 − x + , 6
··· .
(19.2)
The Bernoulli numbers Bn are given by the Bernoulli polynomials Bn = Bn (0), e.g., B0 = 1,
1 B1 = − , 2
B2 =
1 , 6
B2n+1 = 0 for n > 1. (19.3)
The derivative of the Bernoulli polynomials is given by d Bn (x) = n Bn−1 (x), dx
(19.4)
and therefore if we know the integration constant it will be straightforward to compute Bernoulli polynomials by direct integration. The polynomial values between 0 ≤ x ≤ 1 can be evaluated by ∞
2(−1)n+1 (2n)! cos(2πkx) B2n (x) = , (2π)2n k 2n
n ≥ 1,
(19.5a)
k=1
∞
B2n+1 (x) =
2(−1)n+1 (2n + 1)! sin(2πkx) , (2π)2n+1 k 2n+1
n ≥ 0.
(19.5b)
k=1
For sufficiently large n values these series will quickly converge due to the denominator. Bn (−x) = (−1)n [Bn (x) + nx n−1 ]
(19.6a)
19.1 Bernoulli Numbers and Bernoulli Polynomials
227
allows to compute negative values and from Bn (x + 1) = Bn (x) + nx n−1
(19.6b)
we get Bn (x + m) = Bn (x) + n
m−1
(x + k)n−1 ,
m∈N
(19.6c)
k=0
to compute Bernoulli polynomials for arbitrary large real arguments.
19.1.2 Programs Bernoulli Numbers can be evaluated with the SPECFUNPHYS class bernn with syntax [obj, Bn] = bernn(n, all). The input argument “n” is the n-th Bernoulli number starting with 0. “all” is optional and with “all” equals ‘a’ all Bernoulli numbers up to “n” will be returned, otherwise only one. The output arguments are the class object “obj” with properties “Bn”, the Bernoulli number(s) and “info” with some information. The first 36 Bernoulli numbers are table based [1] all others are computed via Eqs. (19.5) for x = 0. Bernoulli Polynomial Coefficients are returned from the SPECFUNPHYS class bernpoly with syntax [obj, Bk] = bernpoly(n). The input argument “n” is the polynomial degree with n ≥ 0. All polynomial coefficients up to “n” will be evaluated. The output arguments are the class object “obj” with properties “polycoef”, a table of the polynomial coefficients and “info” with some basic information. “Bk” is an array of polynomial coefficients; in the first row the coefficients for degree equal to 0 and in the n-th row for degree n − 1. For degree smaller than 15 the result is table based [1] and higher orders are computed with the help of the MATLAB function polyint via Eq. (19.4) and the integration constant via Eq. (19.5). The class bernpoly comes in addition with methods plot, for plotting, deri to compute the n-th derivative and polyvalue to evaluate the Bernoulli polynomials. All methods are located in the class bepolymeth. The syntax is obj = plot(obj, nw, xi, ah). “obj” is the bernpoly class object. All other input arguments are optional. “nw” is an integer vector of polynomial degrees which shall be plotted (default all shall be plotted). “xi” is either a two component real vector with the plot interval borders, or a vector of real numbers for plotting; default is 100 equidistant values between 0 and 1. “ah” is an axes object as target for plotting (default, a new figure window opens). Pder=deri(obj,nd) computes the n-th derivative of the polynomials located in the class object “obj”. “nd” is a scalar integer, the nd-th derivative of the polynomial, stored in the output array “Pder”. The n-th row are polynomial coefficients of the ndth derivative of the polynomial of degree n+1. The method with syntax [res, n] = polyvalue(obj,x,n) evaluates the polynomials located in the class object
228
19 Bernoulli and Euler Polynomials
“obj”; “x, n” are optional. “x” is the position at which the polynomials shall be evaluated; default are 100 equidistant values in [0, 1]. “n” is an integer vector of the degree of the polynomials in quest; default value is all. The output arguments are the polynomial values “res”, an array with fix degree for each row and “n” the corresponding vector of the polynomial degrees. Bernoulli Polynomial Values can be computed via the SPECFUNPHYS class bernx with syntax [obj, Bn] = bernx(n, x, wcom). The input argument “n” is the Bernoulli polynomial degree, a positive integer value. “x” (optional) are a vector with the positions at which the polynomial shall be evaluated. Default value is 0 · · · 1. In case “x” is complex the polynomial representation of the Bernoulli polynomial will be used. By default, for real vectors “x” and degrees lower 11 the polynomial representation will be used, otherwise the trigonometric series, Eq. (19.5), and if necessary in combination with the coordinate transformation Eq. (19.6). The optional input argument “wcom” allows to select the computational technique. The supported values are “d” for default (see above), “poly” for the polynomial representation, and “trig” for the series representation in combination with the argument transformation if necessary. The output arguments are the class object “obj” with properties “value”, the polynomial values at position “z”, “degree”, the degree of the polynomial, and “info” with some general information about the evaluation. bernx comes in addition with the method plot located in the class bexplot. The syntax is [obj, fh]=plot(obj, fh) with “obj” the bernx class object and optional the figure handle “fh” to create the plot in the figure with object handle fh. Examples
By the following example a plot can be created to uncover the similarity between a sin-function and a Bernoulli polynomial: x = linspace(0,1); % coordinates for sin-plot yyaxis left plot(x,sin(x*2*pi)), shg % sin-plot for left y-axis title(’left: sin(2\pi x)’) fh = gcf; % figure handle yyaxis right [obj, fh] = bernx(3).plot(fh); shg
With val=bernpoly(7).polyvalue; all Bernoulli polynomials of degree 0 to 7 based on the polynomial representation will be evaluated. obj=bernx(7,[], ’trig’); computes the Bernoulli polynomial of degree 7 based on the trigonometric series representation. In both cases the polynomials are evaluated at the same (default) positions x = 0 · · · 1. For high polynomial degrees bernx might be more accurate than bernpoly(n).polyvalue, and if only one single polynomial is of interest bernx might be more efficient.
19.2 Euler Numbers and Euler Polynomials
19.2
229
Euler Numbers and Euler Polynomials
19.2.1 Equations Some Euler numbers and Euler polynomials are, e.g., listed in [1, 2] as well as most of the following equations. The generating function for the Euler polynomials En (x) reads ∞
2 exp(x t) tn = En (x) . exp(t) + 1 n!
(19.7)
n=0
Thus, e.g., E0 (x) = 1,
1 E1 (x) = x − , 2
E2 (x) = x 2 − x,
··· .
(19.8)
The Euler numbers En can be derived from the corresponding polynomials via
1 En = 2 En , e.g., 2 n
E0 = 1,
E2 = −1,
E4 = 5 and
E2n+1 = 0 for n ≥ 0.
(19.9) The derivative of the Euler polynomial follows the same relation as the formula for the Bernoulli polynomials: d En (x) = n En−1 (x), dx
(19.10)
and therefore if we know the integration constant it will be straightforward to compute Euler polynomials by direct integration. For polynomials of odd degree this constant will be 0. The polynomial values between 0 ≤ x ≤ 1 can be evaluated by ∞
E2n (x) =
4(−1)n (2n)! sin((2k + 1)πx) , π 2n+1 (2k + 1)2n+1
n > 0,
(19.11a)
k=0
∞
E2n−1 (x) =
4(−1)n (2n − 1)! cos((2k + 1)πx) , π 2n+1 (2k + 1)2n
n ≥ 1. (19.11b)
k=0
For sufficiently large n values these series will quickly converge due to the denominator. En (−x) = (−1)n+1 [En (x) − 2x n ]
(19.12a)
230
19 Bernoulli and Euler Polynomials
allows to compute negative values and from En (x + 1) = 2x n − En (x)
(19.12b)
we get En (x + m) = (−1)m En (x) + 2
m−1
(−1)k (x + m − 1 − k)n ,
m∈N
(19.12c)
k=0
to compute Euler polynomials for arbitrary large real arguments. These transformations are only necessary for the series expansion, Eq. (19.11). Complex arguments are only supported in the polynomial representation.
19.2.2 Programs The syntax of the classes to evaluate Euler polynomials, respectively, Euler numbers is similar to the corresponding Bernoulli classes. Thus in short: Euler Numbers can be evaluated with the SPECFUNPHYS class eulen with syntax [obj, En] = eulen(n, all). Because E2n+1 = 0 only even Euler numbers will be evaluated. The input argument “n” should be even, n = 0, 2, 4, · · · . “all” is optional and with “all” equals “a” all even Euler numbers up to “n” will be returned, otherwise only one. The output arguments are the class object “obj” with properties “En”, the Euler number(s) and “info” with some information. The first 36 Euler numbers are table based [1] all others are computed via Eqs. (19.11) for x = 12 . Euler Polynomial Coefficients are returned from the SPECFUNPHYS class eulepoly with syntax [obj, Ek] = eulepoly(n). The input argument “n” is the polynomial degree with n ≥ 0. All polynomial coefficients up to “n” will be evaluated. The output arguments are the class object “obj” with properties “polycoef”, a table of the polynomial coefficients and “info” with some basic information. “Ek” is an array of polynomial coefficients; in the first row the coefficients for degree equal to 0 and in the n-th row for degree n − 1. For degree smaller than 15 the result is table based [1] and higher orders are computed with the help of the MATLAB function polyint via Eq. (19.10) and if necessary the integration constant via Eq. (19.11). The class eulepoly comes in addition with methods plot, for plotting, deri to compute the n-th derivative and polyvalue to evaluate the Bernoulli polynomials. All methods are located in the class bepolymeth. For details and examples see Sect. (19.1.2). Euler Polynomial Values can be computed via the SPECFUNPHYS class eulex with syntax [obj, En] = eulex(n, x, wcom). The input argument “n” is the Euler polynomial degree, a positive integer value. “x” (optional) are a vector with the positions at which the polynomial shall be evaluated. Default value is 0 · · · 1. In case “x” is complex the polynomial representation of the Euler polynomial
19.2 Euler Numbers and Euler Polynomials
231
Bernoulli polynomial: degree = 8 Euler polynomial: degree = 8
0.04
6
0.03 5 0.02 4
0
3
value
value
0.01
-0.01 2 -0.02 1 -0.03 -0.04
0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
x
Fig. 19.1 Left axis: Bernoulli polynomial of degree 8, solid line. Right axis: Euler polynomial of degree 8, dashed line
will be used. For real vectors “x” and degrees lower than 11 the polynomial representation will be used by default, otherwise the trigonometric series, Eq. (19.5), if necessary in combination with the coordinate transformation Eq. (19.6). The optional input argument “wcom” allows to select the computational technique. The supported values are “d” for default (see above), “poly” for the polynomial representation, and “trig” for the series representation in combination with the argument transformation if necessary. The output arguments are the class object “obj” with properties “value”, the polynomial values at position “z”, “degree”, the degree of the polynomial, and “info” with some general information about the evaluation. eulex comes in addition with the method plot located in the class bexplot, see Sect. (19.1.2) above. Example
Bernoulli and Euler polynomial plot. Figure 19.1 was plotted with the following tiny program (bevisu.m): x = linspace(0,1,250); yyaxis left % left y-axis [obj, fh] = bernx(8).plot% Bernoulli polynomial degree 8 % fh is the figure handle, which will be used to plot % the Euler polynomial into the same figure yyaxis right % right y-axis obj = eulex(8).plot(fh) % Euler polynomial degree 8
232
19 Bernoulli and Euler Polynomials
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover , New York (1972) 2. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt A. M. (1981)
Riemann Zeta Function
20
Abstract
Topic of this chapter is the Riemann zeta function and its non-trivial zeros. The evaluation of the Riemann zeta function is based on a series expansion and if necessary additionally on transforming the function argument. The first 50 nontrivial zeros are table based, additional non-trivial zeros will be numerically evaluated. Corresponding code for evaluating the Riemann zeta function and computing the non-trivial zeros can be downloaded.
Topic of this chapter is the Riemann zeta function [1,3] and its non-trivial zeros. The Riemann zeta function plays an important rôle in number theory especially related to prime numbers. In theoretical physics the zeta function is applied to regularizations. Applications can be found in quantum dynamics, e.g., the Casimir effect, spectral distributions of quantum chaotic systems [4], or in string theory [6]. Function Overview The SPECFUNPHYS class riemzeta returns the function values of the Riemann zeta function. The SPECFUNPHYS class riemzetaroot supports the computations of the so-called non-trivial zeros, related to the function argument s = 12 + it of the zeta function.1 riemzetaroot comes in addition with a method to test the computed zeros. In addition, in the corresponding program folder lives a data file riemnulllist.mat with the first 50 non-trivial zeros [5].
1 The Riemann hypothesis asserts that all non-trivial zeros lie in the line with real part of s equal 0.5.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_20
233
234
20 Riemann Zeta Function
20.1
Equations and Evaluation
20.1.1 Equations The Riemann zeta function ζ is defined by ζ (s) =
∞ . 1 1 = s n 1 − p−s
with
(s) > 1 .
(20.1)
p prime
n=1
The ζ -function represented by Eq. (20.1) is absolute convergent in the complex half-plane, and in the complex plane, except for the pole at s = 1, by analytic continuation. The ζ (s)-function can be evaluated in closed form for even integer values of s and for negative integers: ζ(2 n) =
(2π)2n |B2n | , 2(2n)!
Bn+1 , n+1 ζ(−2n) = 0 , ζ(−n) = −
(20.2a)
thus
(20.2b)
for n = 1, 2, 3, · · · .
(20.2c)
The last equation corresponds to the so-called trivial zeros of the Riemann ζ function. From Eq. (20.1) we get formally for s = −1, ζ(−1) = 1+2+3+· · · , thus a divergent series; but from the analytic continuation, Eq. (20.2b), ζ(−1) = − B22 = 1 – a simple example for the ζ regularization. − 12 For (s) > 0 the evaluation in SPECFUNPHYS class riemzeta is based on [2]. With s = σ + i t ζ(s) is given by ek =
n
n j =k
(20.3a)
j
1 ζ (s) = 1 − 21−s
) n (−1)k−1 ks
k=1
with |γn (s)| ≤ and |γn (s)| ≤
2n 1 (−1)k−1 ek−n + n 2 ks
* + γn (s)
(20.3b)
k=n+1
π 1 1 + | σt | exp |t| 8n |1 − 21−s | 2
1 4|σ | 8n |1−21−s ||Γ (s)|
for σ > 0
(20.3c)
for − (n − 1) < σ < 0 . (20.3d)
20.1 Equations and Evaluation
235
To optimize the convergency we use for (s) < 0 ζ (s) = 2s π s−1 sin
πs Γ (1 − s)ζ(1 − s) 2
∀ s ∈ C\{0, 1} ,
(20.4)
and restrict the evaluation via series approximation to positive real parts of the argument s.
20.1.2 Evaluation The evaluation of the Riemann zeta function via riemzeta is based on the series approximation (20.3b) with syntax [obj, zetaval] = riemzeta(s, n). The input argument “s” is the function argument ζ(s), an arbitrary complex array. “n” (optional, given by γn (s)) is the upper integer value of the first series in Eq. (20.3b) and either a scalar value or of the same size as “s”. Output arguments are the object “obj” with properties “zeta” (function value), “s” (function argument), “nek” (summation limit of the first sum), and “info” with some general information. In case of the summation “info” comes with a value for the accuracy based on γn (s). This value should be as small as possible (< 10−9 ). The output argument “zetaval” equals obj.zeta. The zeros of ζ( 12 + i · t) can be estimated with the SPECFUNPHYS class riemzetaroot with syntax [obj, tzero] = riemzetaroot(t0, t1, dt). The zeros within the interval [t0, t1] will be searched. Thus the input arguments “t0”, “t1” are real scalar values. For the search process the interval will be split into subintervals of length dt. The optional input argument “dt” is a real scalar value with default value 0.5. Output arguments are the object “obj” with properties “t” (s = 12 + i · t), “fval”, the corresponding value of the ζ -function and “info” with some general information, and in addition “tzero” the t-values (equal obj.t). riemzetaroot comes in addition with the method [iszetazero, obj] = zerotest(obj,n,dt,nofig) to test if “obj.t” corresponds to a root of ζ( 12 + i · t). The evaluation of riemzetaroot is based on the MATLAB-functions fminbnd and fzero. Thus in an unlikely case it could be that only a close to zero value will be returned. Therefore zerotest evaluates the surrounding of obj.t and checks for changes in sign of the real and imaginary function value. The input arguments are the object “obj”, the optional integer vector “n” with the row numbers of obj.t to check (default is all), “dt” (optional) the step size for evaluating the ζ -function with default value 0.1 and “nofig” (optional) if a figure shall be plotted (default) or not (“y”). The output argument “iszetazero” is a cell variable with the corresponding information and “obj” the object of the class riemzetaroot.
236
20 Riemann Zeta Function 4
3 2
3
| |
1
2
0 -1
1 -2
0
0
5
10
15
20
25
30
35
40
45
50
t
Fig. 20.1 Absolute value of the Riemann ζ(s)-function for s = color coded with the angle of s
1 2
+ i · t, t = 0 · · · 50. The line is
Figure 20.1 shows the absolute vales of the ζ -function along the strip s = + i · t color coded with the angle of ζ . The figure was created with the program visuzero: 1 2
% computing the zeros between 14 ... 50 obj = riemzetaroot(14,50); t = linspace(0,50,200); % t values for visualization t = [t,obj.t.’]; t = sort(t); s = 1/2 + i*t; % zeta function argument obj = riemzeta(s); % evaluation of the zeta function % visualization surface([t;t],[abs(obj.zeta);abs(obj.zeta)],... [zeros(size(t));zeros(size(t))],... [angle(obj.zeta);angle(obj.zeta)],... ’facecolor’,’none’, ’edgecolor’, ’flat’,... ’edgelighting’,’phong’, ’linewidth’, 2), shg xlabel(’t’), ylabel(’|\zeta|’), colorbar
References 1. Abramowitz, M., Stegun, I.A.: Handbook of Mathematical Functions. Dover Pub., New York (1972) 2. Gourdon X., Sebah, P.: Numerical evaluation of the Riemann zeta-function (2019). http:// numbers.computation.free.fr/Constants/Miscellaneous/zetaevaluations.pdf 3. Gradstein, I.S., Rhysik, I.M.: Tafeln · Tables II. Verlag Harry Deutsch Thun, Frankfurt (1981) 4. Gutzwiller, M.C.: Chaos in Classical and Quantum Mechanics. Springer, Berlin (1990) 5. Wikipedia. Liste nicht-trivialer Nullstellen der Riemannschen Zetafunktion. https://de. wikipedia.org/wiki/Liste_nicht-trivialer_Nullstellen_der_Riemannschen_Zetafunktion 6. Zwiebach, B.: A First Course in String Theory. Cambridge University Press, Cambridge (2009)
Piecewise Interpolation Polynomials
21
Abstract
Topics of this chapter are piecewise polynomial interpolations based on Lagrange, Hermite, or extended Hermite polynomials of arbitrary degree. The basic idea is to divide the space of interest into smaller subintervals carrying a local coordinate system. Piecewise interpolation polynomials can be used, e.g., for interpolating data. The focus here are finite element applications in quantum dynamics. Thus as an example we will apply piecewise Lagrange interpolation polynomials for a finite element ansatz of the radial Schrödinger equation for Hydrogen atoms. MATLAB code for computing the interpolation coefficients and code with respect of the finite element example can be downloaded.
Topics of this chapter are piecewise polynomial interpolations based on Lagrange, Hermite, or extended Hermite polynomials. The basic idea is to divide the space of interest [xa , xb ] into smaller subintervals carrying a local coordinate system x˜ running from [0, +1]. MATLAB offers many functions for interpolating data. The intention here is to use piecewise interpolation polynomials, e.g., for solving differential equations via finite elements. As an example we will apply interpolation polynomials onto a finite element ansatz for the radial Schrödinger equation of the Hydrogen atom. Function Overview The MATLAB-function pchip is a piecewise cubic Hermite interpolation polynomial, thus based on two nodal points. The SPECFUNPHYS-class ippolynom returns the interpolation coefficients of arbitrary Lagrange, Hermite, or extended Hermite polynomials and the function Hatomeig shows as an application the finite element solution for the Hydrogen atom based on Lagrange interpolation polynomials.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_21
237
238
21 Piecewise Interpolation Polynomials
0.8
0.6 local coordinates
0.4
1 0.5 0
0.2
0
0.25
0.5
0.75
1
0
-0.2 0
2
4
6
8
10
12
14
16
18
20
global coordinates
Fig. 21.1 Graphical example of local coordinates uncovered by a radial hydrogen wave function. The entire space of interest is divided into subintervals carrying local coordinates with five nodal points
21.1
Interpolation Polynomials
Figure 21.1 uncovers graphically local coordinates.
21.1.1 Lagrange Interpolation Polynomials Lagrange interpolation polynomials can be either derived from a polynomial approximation ansatz or from a system of linear equations for the polynomial coefficients. The Lagrange polynomials Lnk (x), ˜ x˜ local coordinates, hold Lnk (x˜i ) = δki at the nodes x˜i . This allows to derive a system of linear equations, which is more favorable for explaining finite element applications. Because we will discuss finite elements in quantum dynamics as an example we will use a “quantum picture,” but the derivation would be exactly the same for any other smooth function. (In the following we will denote all interpolation polynomials by Φ and omit the polynomial order n.) To derive the Lagrange interpolation polynomial, we only assume that our interpolation polynomial fulfills Φα (x˜β ) = δα,β
(21.1)
at the (equidistant) nodes x˜α . On each of the finite elements the quantum wave function is given in local coordinates by x|ψ ˜ =
α
Φα (x) ˜ x˜α |ψ =
α
Φ (x) ˜ α int er. polynom
ψα ,
(21.2)
21.1 Interpolation Polynomials
239
with correct values at the nodes x˜ α . For local coordinate values between the nodes, the wave function will be approximated by the Lagrange interpolation polynomial ˜ = Φα (x)
n
Cαi x˜ i .
(21.3)
i=0
Example
A Lagrange interpolation polynomial of order n has n + 1 linear independent coefficients Cαi and therefore n + 1 equidistantly distributed nodal points on the interval 0 ≤ x˜ ≤ +1. For example, for 3 nodes we get n = 2, x˜0 = 0, x˜1 = 0.5, x˜2 = +1 and therefore a system of three linear equations for fixed index α Φ0 (x˜0 ) = Φ0 (0) = C00 = 1 1 1 Φ0 (x˜1 ) = Φ0 (0.5) = C00 + C01 + C02 = 0 2 4 Φ0 (x˜2 ) = Φ0 (+1) = C00 + C01 + C02 = 0, and additional similar equations for Φ1 and Φ2 . Thus, for the polynomial coefficients Cαi we get the following matrix equation ⎛
⎞ ⎛ ⎞ ⎛ 10 0 10 C00 C10 C20 ⎝ 1 1 1 ⎠ · ⎝ C01 C11 C21 ⎠ = ⎝ 0 1 2 4 00 11 1 C02 C12 C22
⎞ 0 0⎠. 1
Obviously, the example above can be generalized to a polynomial of arbitrary order: A ·
C
nodes coeff icient mat rix
=
1
⇒ C = A−1
.
(21.4)
unity mat rix
Computing the inverse matrix A−1 will lead to the unknown coefficients of the Lagrangian interpolation polynomial. An example for Lagrange interpolation polynomials is plotted in Fig. 21.2.
21.1.2 Hermite Interpolation Polynomials For Lagrange interpolation polynomials the wave function was computed exactly at the nodal points. At the nodal points the first derivative is only approximately known. For Hermite interpolation polynomials we evaluate the value of the wave
240
21 Piecewise Interpolation Polynomials 1
1 0.8
0.5
0.6 0.4
0
0.2 0
0
0.2
0.4
0.6
0.8
1
1
-0.5
0
0.2
0.4
0.6
0.8
1
0
0.2
0.4
0.6
0.8
1
1 0.5
0.5
0 0 -0.5
-0.5 0
0.2
0.4
0.6
0.8
1
-1
Fig. 21.2 The lowest four Lagrange interpolation polynomials. The nodes are equidistant in [0, 1]. Thus for two nodes, (0, +1), the interpolation polynomials are linear; for three nodes, (0, 0.5, +1) quadratic and so on. On top from left to right: 1st and 2nd order and bottom from left to right 3rd and 4th order of the Lagrange interpolation polynomial. Obviously each of the interpolation polynomials fulfills Ln,k (x˜i ) = δk,i
function and in addition its first derivative exactly at the nodal points. Therefore we have to take into account the first derivative via
d x|ψ| ˜ Φα (x) (21.5) x|ψ ˜ = ˜ x˜α |ψ + Φ¯ α (x) ˜ x= ˜ x˜ α d x˜ α = Φα (x)ψ ˜ α + Φ¯ α (x) ˜ ψ¯ α , α
and for the derivative of the wave function
d ˜ d x˜ x|ψ
d x|ψ ˜ = Φα (x)ψ ˜ α + Φ¯ α (x) ˜ ψ¯ α , d x˜ α which leads to Φα (x˜β ) = δαβ ⇒ for n nodes n equations d ¯ Φα (x˜β ) = δαβ ⇒ for n nodes n equations d x˜ d Φα (x˜β ) = 0 and Φ¯ α (x˜β ) = 0. d x˜
(21.6a) (21.6b) (21.6c)
21.1 Interpolation Polynomials
241
Therefore for n nodal points we obtain 2n linear equations and thus a polynomial of order 2n − 1. Example
With x˜ ∈ [0, +1] and two nodes, x˜0 = 0 and x˜1 = +1, the Hermite interpolation polynomials will be of order three. For example, for α = 0 we obtain Φ0 (x) ˜ = C00 + C01 x˜ + C02 x˜ 2 + C03 x˜ 3 d Φ0 (x) ˜ = C01 + 2C02 x˜ + 3C03 x˜ 2 d x˜ Φ¯ 0 (x) ˜ = C¯00 + C¯01 x˜ + C¯02 x˜ 2 + C¯03 x˜ 3 ⇒
⇒
d ¯ ˜ = C¯01 + 2C¯02 x˜ + 3C¯03 x˜ 2 , Φ0 (x) d x˜
and hence for α = 0 a system of four linear equations at the nodal points: Φ0 (x˜0 ) = C00 = 1 Φ0 (x˜1 ) = C00 + C01 + C02 + C03 = 0 d Φ0 (x˜0 ) = C01 = 0 d x˜ d Φ0 (x˜1 ) = C01 + 2C02 + 3C03 = 0 d x˜ .. . which could be as well mapped on a matrix equation ⎛
⎞ ⎛ 1000 C00 ⎜ 0 1 0 0 ⎟ ⎜ C01 ⎜ ⎟ ⎜ ⎝ 1 1 1 1 ⎠ · ⎝ C02 C03 0123 A
C¯00 C10 C¯01 C11 C¯02 C12 C¯03 C13
⎞ ⎛ 1 C¯10 ⎜0 C¯11 ⎟ ⎟=⎜ C¯12 ⎠ ⎝ 0 C¯13 0
⎞ 000 1 0 0⎟ ⎟. 0 1 0⎠ 001
(21.7)
C
Thus, the coefficient matrix C will be given by the inverse of the nodal matrix A, C = A−1 . Obviously the equations above can be generalized to an arbitrary number of nodes. An example of Hermitian interpolation polynomials is plotted in Fig. 21.3.
242
21 Piecewise Interpolation Polynomials Hermite Interpolation polynomial
1 0.5 0 0
0.25
0.5
0.75
1
0
0.25
0.5
0.75
1
0
0.25
0.5
0.75
1
0.2 0 -0.2 1 0 -1
x
Fig. 21.3 Hermite interpolation polynomials for three nodes, thus we get six polynomials of order ˜ Φ¯ α (x) ˜ and ddx˜ Φ¯ α (x) ˜ 5. From top to bottom Φα (x),
21.1.3 Extended Hermite Interpolation Polynomials The next higher interpolation step is to take in addition the second derivative into account which leads to extended Hermite interpolation polynomials. Hence we get x|ψ ˜ (21.8a)
d d2 ¯ ¯ ¯ x|ψ| ˜ ˜ x˜α |ψ + Φα (x) ˜ ˜ x|ψ| ˜ Φα (x) = x=xα + Φα (x) x=xα d x˜ d x˜ 2 α Φα (x)ψ (21.8b) = ˜ α + Φ¯ α (x) ˜ ψ¯ α + Φ¯¯ α (x) ˜ ψ¯¯ α α
and therefore the polynomials have to fulfill Φα (x˜β ) = δαβ ,
d Φα (x˜β ) = 0 and d x˜
d2 Φα (x˜β ) = 0 d x˜ 2
(21.8c)
Φ¯ α (x˜β ) = 0 ,
d d2 Φ¯ α (x˜β ) = δαβ and Φ¯ α (x˜β ) = 0 d x˜ d x˜ 2
(21.8d)
Φ¯¯ α (x˜β ) = 0 ,
d ¯¯ Φα (x˜β ) = 0 and d x˜
d 2 ¯¯ Φα (x˜β ) = δαβ . d x˜ 2
(21.8e)
For n nodal points a complete description will be given by 3n coefficients and hence the corresponding polynomial is of the order 3n − 1. Obviously, as defined by Eq. (21.8c), the derivatives of Φ vanish at all nodal points and the interpolation ¯ respectively, Φ¯¯ at the nodal points. The coefficient matrix will be polynomial Φ, again given by the inverse of the corresponding nodal matrix.
21.3 The Finite Element Method
21.2
243
Computational Aspects
The SPECFUNPHYS class ippolynom returns the coefficients of the interpolation polynomials. The syntax is [obj, C] = ippolynom(dof, kn) with the input variables “dof”, the degree of freedom and “kn”, the number of nodes, with minimum value 2. For Lagrange interpolation polynomials dof = 1, for Hermite interpolation polynomials dof = 2, and for extended Hermite interpolation polynomials dof = 3. The output variables are the class object “obj” with properties “polycoef”, a table of the polynomial coefficients, “dof”, the degree of freedom, “nodal”, the number of nodal points, and “info” with some general information. The output variable “C” is an array of the polynomial coefficients and corresponds to obj.polycoef. The following examples show how to call the class. The first example to compute and plot the Lagrange polynomial and the second one to extract the derivative polynomials of the Hermite polynomial and to evaluate and to plot their derivative d ¯ ˜ d x˜ Φα (x). >> >> >> >> >> >>
x = linspace(0,1); [obj, C] = ippolynom(1, 4); plot(x,polyval(obj.polycoef.L0,x)) ,grid on, hold on plot(x,polyval(obj.polycoef.L1,x)) plot(x,polyval(obj.polycoef.L3,x)) plot(x,polyval(obj.polycoef.L4,x)), shg
x = linspace(0,1); % plot argument n = 4; % number of nodal points obj = ippolynom(2, n); % polynomial coefficients % figure, hold on, grid on % polynomial values + node position for k = 0:n-1 eval([’dH = obj.polycoef.dH’,num2str(k)]); dHder = polyder(dH); plot(x, polyval(dHder,x),... k/(n-1),polyval(dHder,k/(n-1)),’*’) end
(This example lives in the file dHexample.m).
21.3
The Finite Element Method
The finite element method can be applied to any partial differential equation formulated as boundary value problem. One-dimensional finite elements can be applied either to one degree-of-freedom quantum systems or to single components of the multi-dimensional Schrödinger equation, e.g., the radial Schrödinger equation [1]. For simplification we will restrict the following discussion to bound states of a
244
21 Piecewise Interpolation Polynomials
one-dimensional quantum system. Thus the corresponding Schrödinger equation in the coordinate representation is
$ h¯ 2 d 2 ˆ − + (E − V (x)) x; E|ψ = 0. 2m dx 2
Due to the simplicity of the kinetic energy operator the coordinate representation of the quantum system is preferred for finite elements. The shape of the potential could be almost arbitrary complex. For simplification we set h¯ = 1 ,
m=
1 2
⇒
h¯ 2 = 1. 2m
(21.9)
By multiplication of the Schrödinger equation with the wave function x|ψ from the left, we arrive at the equivalent variational equation δΠ[ψ] = 0 with the functional +∞ d2 ˆ (21.10) ψ|x 2 x|ψ + ψ|x E − V (x) x|ψ dx = Π[ψ]. dx −∞ Because bound states x|ψ = ψ(x) are normalizable we could always find a left and right border, (xa , xb ), in coordinate space beyond which the wave functions vanish effectively: xa |ψ = 0 = xb |ψ
,
(21.11)
and thus we can approximate the functional by a finite integration. Integrating by part leads to ⎡
xb
Π[ψ] ≈
xa
⎤ 2 d ⎣ψ|x x|ψ +ψ|x E − Vˆ (x) x|ψ⎦ dx 2 dx d = ψ|x x|ψ|xxba − dx
xb
xa
(21.12)
2 d x|ψ dx. dx
at the border = 0
Hence, Π[ψ] = −
xb
xa
2 xb d ψ|x [E − V (x)]x|ψdx x|ψ dx + dx xa σ (x)
(21.13a)
21.3 The Finite Element Method
245
and with x|ψ =
(21.13b)
Ci Ni (x),
i
Π[ψ] =
i,j
Ci Cj
d d Ni (x) Nj (x) dx. Ni (x)σ (x)Nj (x) − dx dx
(21.13c)
Up to now nothing had been said about the functions Ni (x) and we are not yet restricted to a finite element approach. Dividing the space into finite elements carrying a local coordinate system, as discussed above, the wave function will be expanded on each of this finite elements by interpolation polynomials. Thus we get (see Fig. 21.1) (n−1)
r = r0
+ h(n)
(21.14)
x loc. coord.
x = 0···1 (n−1)
r = r0
(n)
(n)
· · · r0 + h(n) = r0 ,
with h(n) the length of the n-th finite element, r0(n−1) the global position in space of the left-hand border of the element and x the local coordinate. The size of each of the local elements could be optimized individually and could differ between neighboring elements. This freedom allows to refine the finite element grid if appropriate in the space areas in which the potential shows strong fluctuations and to use a coarser grid in areas in which the potential behaves rather smoothly. For example, for harmonic oscillatory systems a constant spacing is in most cases sufficient, whereas for Coulomb systems a quadratic spacing is numerically more favorable: (n−1)
r0
= (n − 1)2 h0
n = 1, · · · , n max ;
(21.15)
and hence the size of the elements increases linearly h(n) = r0(n) − r0(n−1) = (2n − 1)h0
n = 1, · · · , n max .
(21.16)
The wave function on the n-th finite element is given by r|ψ =
α
Φ (x) α int erpol. basis
·ψα(n)
with r ]r0(n−1) , r0(n−1) + h(n) [,
(21.17)
246
21 Piecewise Interpolation Polynomials (n)
where ψα is the correct value of the wave function at the nodal points and the (n) summation α runs over all interpolation polynomials. Hence the values, ψα , play the rôle of the polynomial expansion coefficients on each of the finite elements and the complete wave function is given by, loosely speaking, putting all pieces together.
21.3.1 Example: The Hydrogen Atom The Schrödinger equation of the hydrogen atom reads '
( e2 h¯ 2 Δ− − E r|ψ = 0 − 2m r
and thus the radial Schrödinger equation in atomic units for vanishing angular momentum l = 0 d2 2 r|ψ = Er|ψ. (21.18) − 2− r dr Under the assumption r|ψ = 0 for rc > r and partial integration we obtain
rc
drr
2
0
d d ψ|r r|ψ − dr dr
2 − E ψ|rr|ψ = 0. r
(21.19)
Hence with Eq. (21.17) we get n
=
(n)
r0
(n−1) r0
r 2 dr[· · · ]
1 0
n
⎡
×⎣
(n−1)
r0
+ xh(n)
Φα ψα(n) Φβ ψβ −
1
E
n
h(n) dx
(n)
α,β
=
2
0
(n−1)
(r0
r0(n−1)
2
+ xh(n)
α,β
+ xh(n) )2 h(n) dx
⎤ (n) Φα ψα(n) Φβ ψβ ⎦
(n)
Φα ψα(n) Φβ ψβ ,
(21.20)
α,β
where in the first line [· · · ] is given by Eq. (21.19) and the derivatives are with respect to the radial coordinate. Transforming these derivations from the global coordinate r to the local coordinate system we get Φγ (x) =
d dx d 1 d Φγ (x) = Φγ (x) = (n) Φγ (x). dr dr dx h dx
(21.21)
21.3 The Finite Element Method
247
In Eq. (21.20) we sum over all finite elements, and therefore for each single finite element the local matrices are given by (n) Si,j
1
=
(n)
Ti,j =
0
(r0(n−1) + xh(n) )2 h(n) Φi (x)Φj (x)dx
1 0
(n) =− Vi,j (n)
(n−1)
(r0
1 0
(n)
+ xh(n) )2 h(n) Φi (x)Φj (x)
(21.22a) (21.22b)
2(r0(n−1) + xh(n) )h(n) Φi (x)Φj (x) (n)
Hi,j = Ti,j + Vi,j .
(21.22c) (21.22d)
Because the structure of the local matrices is independent from the individual finite element, computation is significantly simplified due to this local approach. Therefore it is sufficient to evaluate the integrations only once for each p, e.g.,
1
x p Φi (x)Φj (x)dx
p = 0, 1, 2.
0
The contribution from all the finite elements via local matrices is assembled to construct the global matrices H and S which results finally in a generalized realsymmetric eigenvalue problem H |ψ >= ES|ψ >,
(21.23)
which could be efficiently evaluated with the MATLAB-function eigs. Because the wave function has to behave smoothly at the element boundary, the local wave function for the n-th element at the right border equals the local wave function at the left border of the neighboring (n + 1)-th finite element. Thus in the global matrices the local matrices overlap at the border of the elements. An example is presented in Fig. 21.4 for five elements. For example, for Lagrange interpolation polynomials with three nodes each block of this Hamiltonian matrix, except the first and the last one, has the following structure: ⎛ ⎜ H (n) = ⎝
⎞ (n) (n) (n) + H00 H01 H02 ⎟ (n) (n) (n) H01 H11 H12 ⎠ (n) (n) (n) (n+1) H02 H12 H22 + H00
(n−1)
H22
,
(21.24)
and similar for the mass or normal matrix S. For Lagrange interpolation polynomials only the first and last matrix element in each matrix block will overlap. For Hermite interpolation polynomials the first derivative have to be taken into account and therefore a 2 × 2 sub-block will overlap and for extended Hermite interpolation polynomials a 3 × 3 sub-block will overlap.
248
21 Piecewise Interpolation Polynomials
Fig. 21.4 Example for the global Hamiltonian matrix for five finite elements. Each of the blocks is given by the local matrix
A realization of the equations above is given by the SPECFUNPHYS-program E = Hatomeig(n, m, rmax). The structure of this program is as follows: function E = Hatomeig(n, m, rmax) %% % % % % %
Finite element ... first argument n: number of nodes 2nd argument number of finite elements rmax integration limit example: n = 6; m = 1000; rmax = 100000; E = Hatomeig(n, m, rmax);
% testing inputs ..... %% Lagrange interpolation polynomial [obj, C] = ippolynom(1,n); ... % some matrix gymnastic %% auxiliary integrals
21.3 The Finite Element Method for ni=1:n for nj=1:ni zwi = polyint(conv(Cli(ni,:),Cli(nj,:))); % x^0* Clint0(ni,nj) = polyval(zwi,1)-polyval(zwi,0); Clint0(nj,ni) = Clint0(ni,nj); ... % x^1* ... % x^2* % Derivation zwi = polyint(conv(Cliabl(ni,:),Cliabl(nj,:)));%x^0 Clabint0(ni,nj) = polyval(zwi,1)-polyval(zwi,0); Clabint0(nj,ni) = Clabint0(ni,nj); ... % x^1 ... % x^2 end end %% FE quadratic spacing ml = 1:m; % index FE h0 = rmax/(m-1)^2; % stepsize h = (2*ml-1)*h0; r0 = (ml-1).^2*h0; %% Computation of the integrals S = h(1)*(r0(1)^2*Clint0 + 2*h(1)*r0(1)*Clint1 + ... h(1)^2*Clint2); S = S(:); % T = (r0(1)^2*Clabint0 + 2*h(1)*r0(1)*Clabint1 + ... h(1)^2*Clabint2)/h(1); T = T(:); % V = -2*h(1)*(r0(1)*Clint0 + h(1)*Clint1); V = V(:); % for k=2:m Sneu = h(k)*(r0(k)^2*Clint0+2*h(k)*r0(k)*Clint1+ ... h(k)^2*Clint2); Sneu = Sneu(:); S(end) = S(end)+Sneu(1); Sneu(1) = []; S = [S;Sneu]; ... T ... V end %% Eigenvalue equation H = T + V; %% Indexgymnastics ... % creating sparse matrices S = sparse(iz,is,S); H = sparse(iz,is,H); figure, spy(H), shg %% solving the generalized eigenvalue problem E = eigs(H,S,25,-1);%’sa’)% 25 eigenvalues E = E/2; % use format rat
249
250
21 Piecewise Interpolation Polynomials
Calling E = Hatomeig(n, m, rmax) with n = 6; m = 1000; rmax= 100000; returns the first 25 eigenvalues together with a figure uncovering the structure of the Hamiltonian matrix and its sparsity. The differences between the computed values and the correct values are approximately 10−12 for the example above. A more thorough discussion with additional examples can be found in [1], and some additional MATLAB-programs in [2].
References 1. Schweizer, W.: Numerical Quantum Dynamics. Kluwer Academic Publishers, Dordrecht (2001) 2. Schweizer, W.: Simulation physikalischer Systeme - Computational Physics mit M ATLAB . Walter de Gruyter GmbH, Berlin (2017)
Wigner- and Clebsch-Gordan Coefficients
22
Abstract
Angular momenta and their coupling are a particular important concept for quantum systems. The chapter target is the Clebsch-Gordan coefficients, Wigner 3j-, 6j-, and 9j-symbols. The evaluations are based on finite summations and the quantum angular momentum coupling rules. The corresponding MATLAB code can be downloaded.
Angular momenta and their coupling are a particular important concept for quantum systems. The chapter target is the Clebsch-Gordan coefficients, Wigner 3j-, 6j-, and 9j-symbols. Function Overview The SPECFUNPHYS class jjCG supports the evaluation of Clebsch-Gordan coefficients, jj3j allows the evaluation of the Wigner 3j-symbol, jj6j serves for the evaluation of the Wigner 6j-symbol, and jj9j evaluates the Wigner 9j-symbol.
22.1
Fundamental Equations and Computation
22.1.1 Basic Aspects The components of the angular momentum operator hold the following commutator relations: [ˆri , Lˆ j ] = ij k i h¯ rˆk © The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_22
(22.1a)
251
252
22 Wigner- and Clebsch-Gordan Coefficients
[pˆi , Lˆ j ] = ij k i h¯ pˆ k
(22.1b)
[Lˆ i , Lˆ j ] = ij k i h¯ Lˆ k ,
(22.1c)
which are sometimes summarized by the easy-to-memorize expressions ˆ rˆ × Lˆ = i h¯ rˆ , · · · , Lˆ × Lˆ = i h¯ L.
(22.2)
For non-vanishing commutator equations we cannot simultaneously assign eigenvalues to all three components of the angular momentum operator. But we can simultaneously measure the angular momentum square Lˆ2 = Lˆ 21 + Lˆ 22 + Lˆ 23 with any component of Lˆ since these operators commute [Lˆ2 , Lˆ i ] = 0 , i = 1, · · · , 3.
(22.3)
Thus the angular momentum eigenstates can be labeled by the eigenvalues of Lˆ2 and one angular momentum component. It is customary to choose Lˆ2 and Lˆ z . Denoting the corresponding eigenvalues by l and m, we obtain Lˆ2 |lm = l(l + 1)h¯ 2 |lm
l = 0, 1, 2, · · ·
and
Lˆ z |lm = mh¯ |lm m = −l, −l + 1, · · · , l − 1, l.
(22.4)
For practical purposes it is more comfortable to define the non-Hermitian ladder operators Lˆ + = Lˆ x + i Lˆ y
and Lˆ − = Lˆ x − i Lˆ y ,
(22.5)
and [Lˆ + , Lˆ − ] = 2h¯ Lˆ z ,
(22.6)
which fulfill the commutator relations [Lˆ z , Lˆ ± ] = ±h¯ Lˆ ± and " Lˆ ± |lm = h¯ l(l + 1) − m(m ± 1) |lm ± 1.
(22.7)
In spherical coordinates the angular momentum operators hold h¯ ∂ Lˆ z = i ∂φ
∂ ∂ Lˆ ± = h¯ exp(±iφ) ± + i cot θ ∂θ ∂φ
∂ 1 ∂2 ∂ sin θ + , Lˆ2 = −h¯ 2 sin θ ∂θ ∂θ sin2 θ ∂φ 2
(22.8a) (22.8b) (22.8c)
22.1 Fundamental Equations and Computation
253
and the eigenfunctions of Lˆ2 and Lˆ z in spherical coordinates are the spherical harmonics.
(2l + 1)!(l − m)! 1/2 m Pl (cos θ ) 4π(l + m)! (−1)m (2l + 1)!(l − m)! 1/2 exp(imφ) = 2l l! 4π(l + m)!
l+m d m sin θ (cos2 θ − 1)l , (22.9) d cos θ
θ φ|lm = Yl.m (θ, φ) = (−1)m
with Plm (cos θ ) are associated Legendre functions (see Chap. 3 for more details).
22.1.2 Clebsch-Gordan Coefficients and Wigner 3j-Symbols In addition to the orbital angular momentum quantum particles possess spin. The total angular momentum is defined by Jˆ = Lˆ + Sˆ with Sˆ the spin operator. In general, let Jˆ1 and Jˆ2 be two angular momenta, and let [Jˆ1 , Jˆ2 ] = 0, then the total angular momentum operator is Jˆ = Jˆ1 + Jˆ2 . The corresponding eigenkets can be labeled either by |j1 m1 , j2 m2 or by |j1 j2 J M, with ji , mi the quantum numbers of the single angular momenta and J, M the quantum numbers of the total angular momentum. The Clebsch-Gordan coefficients (CG) are the unitary transformation between both sets [1]
|j1 j2 J M =
m1 m2
C(j1 j2 J ; m1 m2 M) |j1 m1 |j2 m2 .
(22.10)
CG
The permitted values of J range from |j1 − j2 | to j1 + j2 in steps of one, and M = m1 + m2 . The total number of states |j1 j2 J M for all possible J ’s satisfies j 1 +j2
(2J + 1) = (2j1 + 1)(2j2 + 1).
(22.11)
J =|j1 −j2 |
The 3j-symbols are modified Clebsch-Gordan coefficients, but computationally more useful due to their symmetry properties. They are defined by
j1 j2 J m1 m2 M
=
(−1)j1 −j2 −M C(j1 j2 J ; m1 m2 (−M)). √ 2J + 1
(22.12)
254
22 Wigner- and Clebsch-Gordan Coefficients
The symmetry properties of the 3j-symbols are best uncovered by the Regge symbols, which are defined by
j1 j2 J m1 m2 M
⎡
⎤ −j1 + j2 + j3 j1 − j2 + j3 j1 + j2 − j3 = ⎣ j 1 − m1 j 2 − m2 j 3 − m3 ⎦ . j 1 + m1 j 2 + m2 j 3 + m3
(22.13)
The Regge symbol vanishes if one of its elements become negative or if one of its columns or rows is unequal j1 +j2 +j3 . Hence all symmetries and selection rules of the 3j-symbol are uncovered by the Regge symbol (Unfortunately the used symbols and the exact definition of the symbols, e.g., by (−1)j1 +j2 −j , differs from author to author.) The value of the 3j-symbol is given by [2] *
) j1 j2 J m1 m2 M
= (−1)−2j1 −m1 −j2 −M
(j1 + j2 − J )!(j1 − m1 )!(j2 − m2 )!(J − M)!(J + M)! (j1 + j2 + J + 1)!(j1 − j2 + J )!(j2 − j1 + J )!(j1 + m1 )!(j2 + m2 )! (j1 + m1 + s)!(j1 + J − m1 − s)! , (−1)s s!(j − m1 − s)!(j1 − J + m1 + s)!(J + M − s)! 1 s
1 2
(22.14)
where the sum runs over values of s for which the argument of the factorial is nonnegative. (Additional recursion relations can be found in [2].)
22.1.3 Wigner 6j-Symbols For three angular momenta j1 , j2 , j3 there are two ways to couple them to the total angular momentum J : (j1 , j2 ) → J12 ; (J12 , j3 ) → J and (j2 , j3 ) → J23 ; (J23 , j1 ) → J . Both ways lead to complete bases, thus there have to be a unitary transformation between both sets. The corresponding recoupling matrix in this transformation is independent from the magnetic quantum numbers m and ! j1 j2 j12 proportional to the Wigner 6j-symbol [2] . The Wigner 6j-symbol could j3 J j23 be evaluated via [4] j1 j2 j3 j4 j5 j6
!
=
(−1)
36
k=1 (jk −mk )
m1 ,...,m6
×
j1 j5 j6 m1 −m5 m6
j1 j2 j3 −m1 −m2 −m3
j4 j2 j6 m4 m2 −m6
j4 j5 j3 −m4 m5 m3
(22.15)
with the summation over all six magnetic quantum numbers mi allowed by the selection rule of the 3-j symbols.
22.2 Evaluation
255
22.1.4 Wigner 9j-Symbols Similar to the 6j-symbol the 9j-symbol is proportional to the recoupling matrix for four angular momenta. For four angular momenta j1 , j2 , j3 , j4 we have the following possibilities: (j1 , j2 ) → j12 ; (j3 , j4 ) → j34 ; (j12 , j34 ) → J and (j1 , j3 ) → j13 ; (j2 , j4 )⎧→ j24 ; (j13⎫, j24 ) → J . The corresponding 9j-symbol ⎨ j1 j2 j12 ⎬ is given by Edmonds [2] j3 j4 j34 and can be evaluated via [3] ⎩ ⎭ j13 j24 J ⎧ ⎫ ⎨ j11 j12 j13 ⎬ j11 j12 j13 j21 j22 j23
j21 j22 j23 = ⎩ ⎭ m11 m12 m13 m21 m22 m23 m11 ,...,m33 j31 j32 j33
(22.16) j31 j32 j33 j11 j21 j31 × m31 m32 m33 m11 m21 m31
j12 j22 j32 j13 j23 j33 × , m12 m22 m32 m13 m23 m33 where the summation is about all allowed quantum number mij .
22.2
Evaluation
22.2.1 Clebsch-Gordan Coefficients and Wigner 3j-symbols Clebsch-Gordan Coefficients The Clebsch-Gordan coefficients can be evaluated with SPECFUNPHYS class jjCG. The syntax is [obj, er] = jjCG(j1,j2,j3,m1,m2,m3) with j 3 = J and m3 = M = m1 + m2 , see Eq. (22.10). The computation is based on Eqs. (22.12) and (22.14). The output arguments are the class object “obj” with a table (property Clebsch-Gordan) of all relevant Clebsch-Gordan coefficients and some general information and a vector or array “er” with the same information as obj.ClebschGordan. Syntax: [obj, er] = jjCG(j1,j2) all allowed Clebsch-Gordan coefficients based on the angular momenta j1 , j2 will be evaluated. With [obj, er] = jjCG(j1,j2,m3) the total list will be restricted on Clebsch-Gordan coefficients with value M = m3 , and additionally restricted on the total angular momentum j3 via [obj, er] = jjCG(j1,j2,j3,m3). [obj, er] = jjCG(j1,j2,j3,m1,m2) or [obj, er] = jjCG(j1,j2,j3,m1,m2,m3) evaluates the single ClebschGordan coefficient with m1 + m2 = m3 .
256
22 Wigner- and Clebsch-Gordan Coefficients
Wigner 3j-Symbols The SPECFUNPHYS class jj3j returns the values of the Wigner 3j-symbol. The evaluation is based on Eq. (22.14). (Please note: m1 + m2 + m3 = 0.) The syntax follows the class jjCG: [obj, er] = jj3j(j1,j2); all allowed values based on the angular momenta j1 , j2 will be evaluated. [obj, er] = jj3j(j1,j2,m3); the evaluation will be restricted to magnetic quantum number equal to m3 [obj, er] = jj3j(j1,j2,j3,m3); the evaluation will be in addition restricted to angular momentum j3 , and finally with [obj, er] = jj3j(j1,j2,j3,m1,m2) or [obj, er] = jj3j(j1,j2,j3,m1,m2,m3) only the single value based on all quantum numbers will be computed. The output variable is again the object “obj” with properties “JJ3j”, a table of the corresponding values of the 3j-symbol and “info” with some additional information. “er” is an array with the values of the 3j-symbol. Example >> obj = jj3j(0.5,1,0.5); >> obj.JJ3j ans = 4x7 table
% j1=0.5, j2=1, m3=0.5
j1 ___
j2 __
j3 ___
m1 ____
m2 __
m3 ___
jj3j ________
0.5 0.5 0.5 0.5
1 1 1 1
0.5 0.5 1.5 1.5
-0.5 0.5 -0.5 0.5
0 -1 0 -1
0.5 0.5 0.5 0.5
0.40825 -0.57735 -0.40825 -0.28868
22.2.2 Wigner 6j-Symbols The evaluation of the Wigner 6j-symbols is based on Eq. (22.15). The syntax of the SPECFUNPHYS class jj6j is [obj, er] = jj6J(j1,j2,j3) for the evaluation of all allowed values for the three angular momenta j1 , j2 , j3 we want to couple and [obj, er] = jj6j(j1,j2,j3,J) restricted to the total angular momentum J . With [obj, er] = jj6j(j1,j2,j2,j3,j4,j5,j6) the corresponding single value will be computed. Example >> obj = jj6j(1,0.5,2,2.5); % j1=1, j2=0.5, j3=2, J=2.5 >> obj.JJ6j ans = 4x7 table
22.2 Evaluation
257
j1 __
j2 ___
j12 ___
j3 __
J ___
j23 ___
jj6j _______
1 1 1 1
0.5 0.5 0.5 0.5
0.5 0.5 1.5 1.5
2 2 2 2
2.5 2.5 2.5 2.5
1.5 2.5 1.5 2.5
-0.2582 0.1972 0.17078 0.14907
Please note that the total angular momentum J is on table position “5” and the third angular momentum j3 we want to couple is on position “4”. The output arguments are the object “obj” with properties “JJ6j”, a table of the corresponding values and property “info” with some general information, and “er” an array of the corresponding values.
22.2.3 Wigner 9j-Symbols Wigner 9j-symbols can be evaluated with the SPECFUNPHYS class jj9j with syntax [obj, er] = jj9j(j1,j2,j3,j4) to evaluate all possible 9jsymbols based on the coupling angular momenta (j1 , j2 , j3 , j4 ) and [obj, er] = jj9j(j1,j2,j3,j4, J) restricted to the total angular momentum J ; with [obj, er] = jj9j(j11,j12,j13, j21,j22,j23, j31,j32,j33) the corresponding single value will be computed. The output arguments are the object “obj” with property “JJ9j”, a table of the corresponding values of the Wigner 9j-symbol and property “info” with some general information, and array “er”, an array with the values of the 9j-symbol. The computation is based on Eq. (22.16). Please note that the angular momenta (j1 , j2 , j3 , j4 ) are on position “j11”, “j12”, “j21”, “j22” and the total angular momenta “J” is on table position “j33”. Example >> obj=jj9j(1,2,0.5,1.5,0) % j1=j11=1,j2=j12=2,j21=j3=0.5,j22=j4=1.5,j33=J=0 >> obj.JJ9j ans = 4x10 table j11 j12 j13 j21 j22 j23 j31 j32 j33 jj9j ___ ___ ___ ___ ___ ___ ___ ___ ___ _________ 1 2 1 0.5 1.5 1 0.5 0.5 0 0.11785 1 2 1 0.5 1.5 1 1.5 1.5 0 0.058926 1 2 2 0.5 1.5 2 0.5 0.5 0 0.070711 1 2 2 0.5 1.5 2 1.5 1.5 0 -0.035355
258
22 Wigner- and Clebsch-Gordan Coefficients
References 1. Biedenharn, L.C., Louck, J.D.: Angular Momentum in Quantum Physics. Addison-Wesley, Reading (1981) 2. Edmonds, A.R.: Angular momentum in quantum dynamics. Princeton University Press, New York (1957) 3. Olver, F.W.J., Olde Daalhuis, A.B., Lozier, D.W., Schneider, B.I., Boisvert, R.F., Clark, C.W., Miller, B.R., Sounders B.V. (eds.): NIST Digital Library of Mathematical Functions. http://dlmf. nist.gov, Rel. 1.0.17 (2017) 4. Wikipedia. 6j-symbol (2019). https://en.wikipedia.org/wiki/6-j_symbol
Coordinate Systems
23
Abstract
Coordinate systems play an important rôle in many areas of physics. Focus of this chapter is coordinates for which the three dimensional Laplace–Beltrami operator becomes separable. In detail 11 independent coordinate systems, plus some important combinations and their mutual transformations will be discussed. For completeness Jacobi coordinates and hyperspherical coordinates are added. Related code for mutual transformations can be downloaded.
Coordinate systems play an important rôle in many areas of physics, e.g., in classical dynamics, electrodynamics, and quantum dynamics to list only a few. Topics of this chapter are coordinates for which the three dimensional Laplace–Beltrami operator becomes separable. For applications we will focus on the Schrödinger equation. Function Overview sph2cart The MATLAB function sph2cart transforms spherical coordinates to cartesian coordinates. The inverse transformation is given by the MATLAB function cart2sph. CoordTrafo The SPECFUNPHYS class CoordTrafo supports the transformation between all coordinate systems listed in Table 23.1. Cone The SPECFUNPHYS function cone2c supports the transformation from cone coordinates to cartesian coordinates. Ellipsoidal The SPECFUNPHYS function edal2c supports the transformation from ellipsoidal coordinates to cartesian coordinates. d-spherical The SPECFUNPHYS function hyper2c supports the transformation from hyperspherical coordinates to cartesian coordinates, and the inverse transformation from d-dimensional cartesian coordinates to hyperspherical coordinates is evaluated by the SPECFUNPHYS function c2hyper.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 W. Schweizer, Special Functions in Physics with MATLAB, https://doi.org/10.1007/978-3-030-64232-7_23
259
260
23.1
23 Coordinate Systems
Separability in Three Dimensions
For a three dimensional system it can be shown that the Laplace–Beltrami operator Δ can be separated in 11 different curvilinear coordinates. For each of these coordinates the potential V (r) has to fulfill certain properties that the Schrödinger equation becomes separable, thus can be mapped on three one-dimensional differential equations. For all orthogonal curvilinear coordinates qj in three dimensions the following conditions hold: ds 2 = dx 2 + dy 2 + dz2 , cartesian coordinates =
3
and gij = δij gii
gij dqi dqj
(23.1a) (23.1b)
i,j =1
with ds 2 the line element in q-space. The nabla operator ∇q1 ,q2 ,q3 is proportional to the momentum operator: ∇ q1 ,q2 ,q3 =
∂ ∂ ∂ 1 1 1 ,√ ,√ , √ g11 ∂q1 g22 ∂q2 g33 ∂q3
(23.1c)
and kinetic energy operator is given by the Laplace–Beltrami operator Δq1 ,q2 ,q3 Δq1 ,q2 ,q3
√
3 g ∂ 1 ∂ . = √ g ∂qi gii ∂qi
(23.1d)
i=1
To obtain the probability of presence in the new coordinate system we need the corresponding volume element: dV =
√ gdq1 dq2 dq3
(volume element),
(23.1e)
with g = g11 g22 g33 . The Schrödinger equation becomes separable if the potential can be written as V (q1 , q2 , q3 ) =
3 1 V (qi ) gii
.
(23.2)
i=1
Based on Eq. (23.2) it can be proofed if and for which coordinate systems a given one-particle quantum system is separable. (1) Cartesian Coordinates x, y, z
− ∞ < x, y, x < ∞.
(23.3)
23.1 Separability in Three Dimensions
261
If the potential can be written as V (r) = V1 (x) + V2 (y) + V3 (z)
(23.4a)
the quantum system becomes separable and with a product ansatz for the wave function r|ψ = X(x) · Y (y) · Z(z)
(23.4b)
we obtain three one-dimensional differential equations
d2 − Ux + x dx 2 d2 − Uy + y dy 2
d2 − Uz + − x − y dz2
=0
(23.4c)
=0
(23.4d)
=0
(23.4e)
,
with = 2m/h¯ E, E the energy, and U (r) = 2m/h¯ V (r) and x , y separation constants. For example, the 3d-harmonic oscillator becomes separable in cartesian coordinates and spherical coordinates. (2) Spherical Coordinates x = r sin θ cos φ
0≤r