Computing with Functions on the and Disk Heather Wilber | Boise State University ◦ Dr. Alex Townsend | MIT ◦ Dr. Grady Wright | Boise State University

Overview Low rank approximation of BMC functions The Double Fourier Sphere Method Synthesizing a classic technique known as the double Fourier sphere (DFS) method [4, 5, 6] together with The function ˜f (λ, θ) is said to be Let f (x, y, z) be defined on the surface of the unit sphere. f is periodic along the ˜ new algorithmic techniques in low rank function approximation [2,8], we develop a new method of I rank 1 if it is nonzero and can be written as f (λ, θ) = c(θ)r(λ). great circles passing through its poles, but this feature is lost transforming f to a approximation for computation with functions on the sphere and disk. This approximation method preserves I rank at most K if it can be expressed as a sum of K rank 1 functions. rectangular grid: T := f (x, y, z) −→ f (λ, θ), (λ, θ) ∈ [−π, π] × [0, π]. The function ˜f , the bi-periodicity of the sphere, maintains over the poles in every procedure, and is Most functions are of infinite rank, but smooth functions can often be approximated A doubled-up extension of f , recovers this periodicity. near-optimal in its underlying interpolation. It resolves many drawbacks encountered by previous methods, well by a finite, low rank function: (a) and powers a suite of fast, scalable algorithms for computing with functions on the sphere and disk. (c) 0 K 30 ˜ ˜ X The continuous SVD (Karhunen-Loeve` (2) f (λ, θ) ≈ fk(λ, θ) = djcj(θ)rj(λ). 60 expansion) is an optimal way to derive j=1 90 such an approximation [7], but it is computationally expensive. Our method gives a 120 near-optimal approximation with near-optimal computational complexity. (b) 150 Constructing an approximation: (a) The function 0 θ/π 180 f (x, y, z) = cos(xz − sin y) on the sphere, constructed 30

180 Iterative Gaussian elimination (GE) 210 with spherefun. (b) The “skeleton” used to 60 240 approximate f . Samples of f are only taken along the θ/π 90 270 Iterative GE is a near-optimal method for deriving a low-rank approximation [8]. It

180 blue lines. The underlying grid (in gray) shows the 120 proceeds by choosing a maximal value ˜f (λ , θ ), which serves as a pivot. Performing 300 sample points required without low rank techniques. ∗ ∗ 150 ˜ 330 a GE-step with the pivot results in a reduced-rank update of f : 180 0 30 60 90 120 150 180 210 240 270 300 330 360 360 (a) (b) 180λ/π 0 30 60 90 120 150 180 210 240 270 300 330 360 180λ/π ˜f (λ , θ)˜f (λ, θ ) (3) ˜f (λ, θ) ←− ˜f (λ, θ)− ∗ ∗ . The DFS method applied to the world atlas. (a) Outline of the land masses plotted on the surface of ˜ Computing with functions on the sphere: spherefun software f (λ∗, θ∗) the sphere. (b) The projection of the land masses using latitude- coordinates. (c) Land | {z } masses after applying the DFS method. The result is a “function” that is periodic in both longitude A rank 1 approx. to ˜f and latitude. We implement our methods in Chebfun, which is an open-source software package in MATLAB. These libraries make function evaluation, integration, differentiation, vector calculus, root-finding, plotting and Running the algorithm forward K steps ˜ Preservation of symmetry = Smoothness over poles many other computations easy, accurate, and fast. subtracts a series of K rank 1 terms from f . This series of terms, when added together, The transformation T also creates artificial singularities at the poles of f . The reproduces a rank K approximation to ˜f . extended function ˜f exhibits a particular form of symmetry, which we call Problematically, this method does not ˜ block-mirror-centrosymmetric (BMC). Preserving this BMC symmetry in our R preserve the BMC structure of f . Integration: 2 f dΩ −→ sum2(f) approximation techniques enforces ˜f is smooth over the poles. S f = spherefun(@(x,y,z) Structure-preserving GE (a) (b) 1+x+y.ˆ2+x.ˆ2.*y+x.ˆ4+y.ˆ5+ (x.*y.*z).ˆ2); To preserve BMC structure, we must simultaneously eliminate intf = sum2(f); symmetric pairs of rows and columns, as shown in the figure (left). A ∂f cos λ ∂f ∂f exact = 216 /35; f = + sin λ cos θ , * ∂y sin θ ∂λ ∂θ block-pivoting strategy with a 2 × 2 matrix accomplishes this. error = intf-exact Differentiation: ∂ , ∂ , ∂ −→ diff 3.552713678800501e-15 ∂x ∂y ∂z f = spherefun(@(lam,th) Define a matrix M based on the BMC-symmetric values: " # " # cos(1+2*pi*(cos(lam-0.2).*sin(th)) ˜f (λ∗ − π, θ∗) ˜f (λ∗, θ∗) ˜f (λ∗ − π, θ∗) ˜f (λ∗, θ∗) a b M = = = . Vector calculus: div, grad, curl (and all that) +pi*sin(pi*cos(th)))); ˜f (λ∗ − π, −θ∗) ˜f (λ∗, −θ∗) ˜f (λ∗, θ∗) ˜f (λ∗ − π, θ∗) b a dfdy = diff(f, 2); Our structure-preserving GE step, analogous to (3), is given by Poisson’s Equation: ∆ 2u = f −→ Poisson(f) " # S h i ˜f (λ, θ∗) exact = spherefun.sphharm(6,0) ˜f (λ, θ) ←− ˜f (λ, θ) − ˜f (λ∗ − π, θ) ˜f (λ∗, θ) M+ , ˜f (λ, −θ∗) The definition of a BMC function. (a) The function f (λ, θ) written in terms of a quadrant I function + sqrt(14/11)*spherefun.sphharm(6,5); ˜ + h(λ, θ), and a quadrant II function g(λ, θ). The double Fourier extension of f gives a BMC function, f , f = -42*exact; where M  is the -pseudoinverse of M. that is defined by extending f to quadrants III and IV as described in the figure. (b) Illustration of a u = spherefun.Poisson(f,0,16); surf(v) BMC function. err = norm(u-exact,2) Algorithm: Structure-preserving GE on BMC functions 3.794084381686475e-14 Pseudocode for our Set ˜f = 0 and e˜ = ˜f Why not use spherical harmonics? f = spherefun( @(l,t) u = curl(f); 0 0 structure-preserving The spherical harmonic expansion of f is cos(4*l).*cos(t).*sin(t).ˆ4 v = vort(u); for k = 1, 2, 3,..., GE procedure on -cos(t).ˆ2); quiver(u) ∞ `   BMC functions. This X X m surf(f) surf(v) a b Find (λ , θ ) such that M = , where a = e˜ (λ − π, θ ) and is a continuous f (λ, θ) = c`,mY` (λ, θ), (1) k k b a k−1 k−1 k−1 `=0 m=−` idealization and in m b = e˜k−1(λk−1, θk−1) maximizes σ1(M), the largest singular value of M where Y` is the spherical with degree ` and order m. Analogous practice we use a   + e˜k−1(λ, θk) discretization of this to trigonometric expansions, spherical harmonics are the instinctive mathematical Computing with functions on the disk: diskfun software e˜ = e˜ − e˜ (λ − π, θ) e˜ (λ , θ) M  k k−1 k−1 k k−1 k e˜ (λ, −θ ) choice for representing functions on the surface of the sphere [1]. However, highly A variant of the double Fourier method extends functions on the disk to BMC functions. We apply a similar k−1 k procedure and  e˜ (λ, θ )  adaptive discretizations are computationally unfeasible using such methods. Our ˜f = ˜f − e˜ (λ − π, θ) e˜ (λ , θ) M+ k−1 k terminate it after a GE algorithm for constructing approximants. k k−1 k−1 k k−1 k e˜ (λ, −θ ) alternative setting enables fast algorithms via the FFT. k−1 k finite number of end steps. Algebra with disk harmonics: diskharm The sum of six of the References: [1] K. Atkinson and W. Han, Spherical Harmonics and Approximations on the Unit Sphere: An Laplacian produce a rank 6 function. Introduction, Lecture Notes in , Springer Berlin Heidelberg, 2012. [2] M. Bebendorf, Approximation of Geometric convergence for sufficiently analytic functions nu = [1, 1, 2, 3, 5, 8]; boundary element matrices, Numerische Mathematik, 86 (2000), pp. 565–589. [3] G. J. Boer and L. Steinberg, ˜ on , Atmosphere, 13 (1975), pp. 180–191. [4] B. Fornberg, A pseudospectral approach for w = (-1).ˆ(1:6).*(0:5); Theorem: Let f :[−π, π] × [−π, π] → R be a BMC function such that f (λ, ·) is polar and spherical geometries, SIAM J. Sci. Comput., 16 (1995), pp. 1071–1081. [5] P. E. Merilees, The G = diskfun(); continuous for any λ ∈ [−π, π] and f (·, θ) is analytic and uniformly bounded in a pseudospectral approximation applied to the shallow water equations on a sphere, Atmosphere, 11 (1973), pp. 13–20. for j=1:6 [6] S. A. Orszag, Fourier series on spheres, Monthly Weather Review, 102 (1974), pp. 56–75. [7] E. Schmidt, Zur stadium S of radius (1 + α)ρπ, ρ > 1, for θ ∈ [−π, π]. theorie der linearen und nichtlinearen integralgleichungen. iii. teil, Mathematische Annalen, 65 (1908), pp. 370–399. G = G + contour(h) surf(h) diskfun.diskharm(w(j),nu(j)); [8] A. Townsend and L. N. Trefethen, An extension of Chebfun to two dimensions, SIAM Journal on Scientific roots Then, as k → ∞, ||e˜ || → 0. That is, the BMC preserving GE procedure converges. Computing, 35 (2013), pp. C495–C518. end Rootfinding: k ∞ The zero contour of h = 2− cos 4x + sin(7πx sin(y − .1)) Furthermore, this convergences is geometric. Acknowledgements: This work is generously supported by NASA’s Idaho Space Grant Consortium. surf(G) is given by roots(h) and displayed in red. email: [email protected]