Help language development. Donate to The Perl Foundation

Math::Constants zef:jjmerelo last updated on 2022-11-28
Math::Constants [![.github/workflows/test.yaml](](

Math::Constants - A few constants defined in Raku


#!/usr/bin/env raku

use Math::Constants;

say "We have ", phi, " ", plancks-h, " ",  plancks-reduced-h, " ", 
    c, " ", G, " and ", fine-structure-constant, " plus ",
    elementary-charge, " and ", vacuum-permittivity ;
say "And also  φ ", φ, " α ", α,  " ℎ ",  ℎ, " and ℏ ", ℏ,
    " with e ", e, " and ε0 ", ε0;

say "We are flying at speed ", .1c;


Math::Constants is a collection of Math and Physics constants that will save you the trouble of defining them.

Constants included

### Physical constants

All the physical constants have the CODATA 2018 recommended values. These reflect the new definitions of the kilogram and ampere as of 2019-05-20.

  * [Gravitational constant]( as `gravitation-constant` and `G`.

  * [Speed of light]( as `speed-of-light-vacuum` and `c`. It works also as a suffix for expressing speeds, as in `3c` for 3 times the speed of light. 

  * [Planck constant and reduced constant]( in J/s as `plancks-h` or `ℎ` and `plancks-reduced-h` or `ℏ`.

  * [Boltzmann constant]( as `boltzmann-constant`. Previous versions of Math::Constants had this in eV. The value is now in standard SI units. The eV postfix operator can be used to get the previous value if needed.

  * [Coulomb constant]( as `coulomb-constant` or `K0`.

  * [Mass of an electron]( as `electron-mass`.

  * [Electron volt]( as `electron-volt` and `eV` or as an operator.

  * [Elementary charge]( as `elementary-charge` or `q`.

  * [Faraday constant]( as `faraday-constant` or `F`.

  * [The fine structure constant]( as `fine-structure-constant` or `α`.

  * [Gas constant]( as `gas-constant`.

  * [Avogadro's constant]( as `avogadro-constant` or `L`.

  * [Vacuum magnetic permeability]( as `magnetic-permeability` or `μ0`.

  * [Mass of a neutron]( as `neutron-mass`.

  * [Planck length]( as `planck-length` or `lp`.

  * [Planck mass]( as `planck-mass` or `mp`.

  * [Planck temperature]( as `planck-temperature` or `Tp`.

  * [Planck time]( as `planck-time` or `tp`.

  * [Mass of a proton]( as `proton-mass`.

  * The quantum ratio (elementary charge / Planck constant) as `quantum-ratio`.

  * [Standard acceleration due to gravity]( as `standard-acceleration-gravity` or `g`.

  * [Vacuum electrical permittivity]( as `vacuum-permittivity` or `ε0`.

### Mathematical constants

  * [Golden ratio]( as `phi` or `φ`.

  * [Feigenbaum constants]( as `alpha-feigenbaum-constant` and `delta-feigenbaum-constant` or `δ`.

  * [Apéry's constant]( as `apery-constant`.

  * [Conway's constant]( as `conway-constant` and `λ`.

  * [Khinchin's constant]( as `khinchin-constant` and `k0`.

  * [Glaisher–Kinkelin constant]( as `glaisher-kinkelin-constant` and `A`.

  * [Golomb–Dickman constant]( as `golomb-dickman-constant`. 

  * [Catalan's constant]( as `catalan-constant`. 

  * [Mill's constant]( as `mill-constant`. 

  * [Gauss's constant]( as `gauss-constant`. 

  * [Euler–Mascheroni constant]( as `euler-mascheroni-gamma` and `γ`. 

  * [Sierpiński's constant]( as `sierpinski-gamma` and `k`. 
  * [iⁱ](
  * [ζ(2)](

### Units

"Units" can be used as suffix; the number will be multiplied by its value

 * `eV`, or electron-volts; `1.3eV` is 1.3 divided by the `eV` constant value.
 * `c`, speed of light.
 * `g`, gravitational constant.

Issues and suggestions

Please post them [in GitHub]( Pull requests are also welcome.


JJ Merelo <[email protected]>

Kevin Pye <[email protected]>


Copyright 2016-2022 JJ Merelo

Copyright 2019 Kevin Pye

This library is free software; you can redistribute it and/or modify it under the GPL 3.0.