Spherical harmonics provide a smooth, orthogonal, and symmetry-adapted basis to expand functions on a sphere, and they are used routinely in physical and theoretical chemistry as well as in different fields of science and technology, from geology and atmospheric sciences to signal processing and computer graphics. More recently, they have become a key component of rotationally equivariant models in geometric machine learning, including applications to atomic-scale modeling of molecules and materials. We present an elegant and efficient algorithm for the evaluation of the real-valued spherical harmonics. Our construction features many of the desirable properties of existing schemes and allows us to compute Cartesian derivatives in a numerically stable and computationally efficient manner. To facilitate usage, we implement this algorithm in sphericart, a fast C++ library that also provides C bindings, a Python API, and a PyTorch implementation that includes a GPU kernel.

1.
C.
Müller
,
Spherical Harmonics
(
Springer
,
1966
).
2.
E.
Steiner
,
J. Chem. Phys.
39
,
2365
(
1963
).
3.
M.
Rexer
,
C.
Hirt
,
S.
Claessens
, and
R.
Tenzer
,
Surv. Geophys.
37
,
1035
(
2016
).
4.
R.
Knaack
and
J. O.
Stenflo
,
Astron. Astrophys.
438
,
349
(
2005
).
5.
A.
Morschhauser
,
V.
Lesur
, and
M.
Grott
,
J. Geophys. Res.: Planets
119
,
1162
, (
2014
).
7.
M. A.
Poletti
,
J. Audio Eng. Soc.
53
,
1004
(
2005
).
8.
N. L.
Max
and
E. D.
Getzoff
,
IEEE Comput. Graphics Appl.
8
,
42
(
1988
).
9.
P.-P.
Sloan
, in
Game Developers Conference
(
Peter-Pike Sloan Web Page
,
2008
), Vol.
9
, p.
42
.
10.
H. B.
Schlegel
and
M. J.
Frisch
,
Int. J. Quantum Chem.
54
,
83
(
1995
).
11.
S. A.
Varganov
,
A. T.
Gilbert
,
E.
Deplazes
, and
P. M.
Gill
,
J. Chem. Phys.
128
,
201104
(
2008
).
12.
P. M.
Gill
and
A. T.
Gilbert
,
Chem. Phys.
356
,
86
(
2009
).
13.
S.
Maintz
,
M.
Esser
, and
R.
Dronskowski
,
Acta Phys. Pol., B
47
,
1165
(
2016
).
14.
J. M.
Pérez-Jordá
and
W.
Yang
,
J. Chem. Phys.
104
,
8003
(
1996
).
15.
C. H.
Choi
,
J.
Ivanic
,
M. S.
Gordon
, and
K.
Ruedenberg
,
J. Chem. Phys.
111
,
8825
(
1999
).
16.
L.
Ding
,
M.
Levesque
,
D.
Borgis
, and
L.
Belloni
,
J. Chem. Phys.
147
,
094107
(
2017
).
17.
D. N.
Zotkin
,
R.
Duraiswami
, and
N. A.
Gumerov
, in
2009 IEEE Workshop on Applications of Signal Processing To Audio And Acoustics
(
IEEE
,
2009
), pp.
257
260
.
18.
X.
Li
,
S.
Yan
,
X.
Ma
, and
C.
Hou
,
Applied Acoustics
72
,
646
(
2011
).
19.
T.
Cohen
and
M.
Welling
, in
International Conference on Machine Learning
(
PMLR
,
2016
), pp.
2990
2999
.
20.
M. M.
Bronstein
,
J.
Bruna
,
T.
Cohen
, and
P.
Veličković
, arXiv:2104.13478 (
2021
).
21.
N.
Thomas
,
T.
Smidt
,
S.
Kearnes
,
L.
Yang
,
L.
Li
,
K.
Kohlhoff
, and
P.
Riley
, arXiv:1802.08219 (
2018
).
22.
B.
Anderson
,
T. S.
Hy
, and
R.
Kondor
, in
NeurIPS
(
Curran Associates
,
2019
), p.
10
.
23.
J.
Klicpera
,
F.
Becker
, and
S.
Günnemann
,
Adv. Neural Inf. Process.
34
,
6790
6802
(
2021
).
24.
M.
Geiger
and
T.
Smidt
, arXiv:2207.09453 (
2022
).
25.
A. P.
Bartók
,
R.
Kondor
, and
G.
Csányi
,
Phys. Rev. B
87
,
184115
(
2013
).
26.
A.
Thompson
,
L.
Swiler
,
C.
Trott
,
S.
Foiles
, and
G.
Tucker
,
J. Comput. Phys.
285
,
316
(
2015
).
27.
M. J.
Willatt
,
F.
Musil
, and
M.
Ceriotti
,
J. Chem. Phys.
150
,
154110
(
2019
).
28.
R.
Drautz
,
Phys. Rev. B
99
,
014104
(
2019
).
29.
F.
Musil
,
A.
Grisafi
,
A. P.
Bartók
,
C.
Ortner
,
G.
Csányi
, and
M.
Ceriotti
,
Chem. Rev.
121
,
9759
(
2021
).
30.
A. S.
Christensen
and
O. A.
Von Lilienfeld
,
Mach. Learn.: Sci. Technol.
1
,
045018
(
2020
).
31.
K.
Schütt
,
O.
Unke
, and
M.
Gastegger
, in
International Conference on Machine Learning
(
PMLR
,
2021
), pp.
9377
9388
.
32.
W. H.
Press
,
Numerical Recipes: The Art of Scientific Computing
(
Cambridge University Press
,
2007
).
33.
P.-P.
Sloan
,
J. Comput. Graph. Tech.
2
,
84
(
2013
).
34.
R.
Drautz
,
Phys. Rev. B
102
,
024104
(
2020
).
35.
P.
Alken
, “
GSL-TR-001-20220827 Implementation of associated Legendre functions in GSL,
” GSL Technical Report No. 1, 2022; available at https://www.gnu.org/software/gsl/tr/tr001.pdf.
36.
A.
Paszke
,
S.
Gross
,
F.
Massa
,
A.
Lerer
,
J.
Bradbury
,
G.
Chanan
,
T.
Killeen
,
Z.
Lin
,
N.
Gimelshein
,
L.
Antiga
,
A.
Desmaison
,
A.
Kopf
,
E.
Yang
,
Z.
DeVito
,
M.
Raison
,
A.
Tejani
,
S.
Chilamkurthy
,
B.
Steiner
,
L.
Fang
,
J.
Bai
, and
S.
Chintala
, in
Advances in Neural Information Processing Systems 32
, edited by
H.
Wallach
,
H.
Larochelle
,
A.
Beygelzimer
,
F.
dAlché-Buc
,
E.
Fox
, and
R.
Garnett
(
Curran Associates, Inc.
,
2019
), pp.
8024
8035
.
37.
L.
Dagum
and
R.
Menon
,
IEEE Comput. Sci. Eng.
5
,
46
(
1998
).
38.
M.
Geiger
, and
T.
Smidt
, “
e3nn: Euclidean neural networks
,” arXiv:2207.09453 (
2022
).
39.
C. R.
Harris
,
K. J.
Millman
,
S. J.
van der Walt
,
R.
Gommers
,
P.
Virtanen
,
D.
Cournapeau
,
E.
Wieser
,
J.
Taylor
,
S.
Berg
,
N. J.
Smith
et al,
Nature
585
,
357
(
2020
).
40.
W.
Bosch
,
Phys. Chem. Earth
25
,
655
(
2000
).
41.
F.
Musil
et al, “
Efficient implementation of atom-density representations,
J. Chem. Phys.
154
,
114109
(
2021
).
42.
M. A.
Caro
, “
Optimizing many-body atomic descriptors for enhanced computational performance of machine learning based interatomic potentials,
Phys. Rev. B
100
(
2
),
024112
(
2019
).
43.
Y.
Lysogorskiy
et al, “
Performant implementation of the atomic cluster expansion (PACE) and application to copper and silicon,
npj Comp. Mater.
7
(
1
),
97
(
2021
).
44.
D.
Dusson
et al, “
Atomic cluster expansion: Completeness, efficiency and stability,
J. Comp. Phys.
(published online 2022).
45.
L.
Himanen
et al, “
DScribe: Library of descriptors for machine learning in materials science,
Comp. Phys. Comm.
247
,
106949
(
2020
).
46.
Q.
Qiming
et al, “
PySCF: the Python?based simulations of chemistry framework,
Wiley Interdiscip. Rev.: Comput. Mol. Sci.
8
(
1
),
e1340
(
2018
).
47.
P.
Virtanen
et al, “
SciPy 1.0: fundamental algorithms for scientific computing in Python,
Nat. Methods
17
,
261
272
(
2020
).
48.
M.
Galassi
et al, “
GNU scientific library,
Godalming: Network Theory Limited,
2002
.
49
R.
Schäling
,
The Boost C++ Libraries
(Boris Schäling,
2011
).
50
M.
Ludwig
(2015). “
Spherical harmonics library,
Github.
https://github.com/google/spherical-harmonics
You do not currently have access to this content.