# Request for comment: package for scientific and mathematical constants

**URL:** <https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155>\
**Category:** Numerics\
**Tags:** proposal, numbers\
**Created:** [June 8, 2017, 12:55am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155 "2017-06-08T00:55:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasiha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fasiha/32/1146_2.png) [@fasiha](https://discourse.julialang.org/u/fasiha)\
**Post date:** [June 8, 2017, 12:55am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/1 "2017-06-08T00:55:20Z")

</div>

I’m refactoring some of our code and am wondering what to do with a few scientific constants we use, like speed of light, permittivity of free space, and the like. I was intrigued to see a stand-alone package, [Tau.jl](https://github.com/JuliaMath/Tau.jl) but that offers a bit more than just the τ constant.

Would it be appropriate to create a Constants.jl package and put these things in there? Would that be broadly useful to the community? Or would it attract controversy as we had to decide which constants were too specialized for inclusion, or naming, etc.?

At a minimum I’d consider adding the defined entries in Wikipedia’s [physical constants](https://en.wikipedia.org/wiki/Physical_constant) article.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 8, 2017, 1:01am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/2 "2017-06-08T01:01:04Z")

</div>

It would be nice if it was integrated with Unitful.jl so that way the quantities by default had units.

---

<div class="post-metadata">

**Author:** ![traktofon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/traktofon/32/591_2.png) [@traktofon](https://discourse.julialang.org/u/traktofon)\
**Post date:** [June 8, 2017, 2:31am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/3 "2017-06-08T02:31:44Z")

</div>

> [@fasiha](#):
>
> Would that be broadly useful to the community?

Speaking for myself, yes.

> [@fasiha](#):
>
> Or would it attract controversy as we had to decide which constants were too specialized for inclusion, or naming, etc.?

Such controversy should not stand against the existence of the package. What exactly to include, will likely be up for discussion, but I don’t see that as a fundamental problem.

---

<div class="post-metadata">

**Author:** ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)\
**Post date:** [June 8, 2017, 2:45am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/4 "2017-06-08T02:45:22Z")

</div>

As a tau partisan, I’d say put tau in Base and put pi in the constants package. Though that ship might have passed…

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [June 8, 2017, 3:51am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/5 "2017-06-08T03:51:06Z")

</div>

I think this is an excellent idea. I suggest not exporting names at the top level, so users can pick and choose by name or domain. For example, `h` could be Planck’s constant in submodule `Constants.Quantum` and not bother someone using finite-difference methods in some other domain.

By “bother”, I mean not threaten with a trap for scoping errors. And since single-character variable names are often used in local scope…

This would also be a perfect destination for all the single-character-name constants now in Base. Once upon a time @StefanKarpinski recognized the unwisdom of such things, but less thoughtful developers prevailed.

---

<div class="post-metadata">

**Author:** ![miguelraz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miguelraz/32/631_2.png) [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Post date:** [June 8, 2017, 4:04am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/6 "2017-06-08T04:04:58Z")

</div>

Perhaps also being able to specify a family of useful units, c = 1, cgs vs mks systems, etc.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 8, 2017, 5:40am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/7 "2017-06-08T05:40:03Z")

</div>

Sounds like this package will have the more bikeshedding than I could imagine. Totally subscribing to the issues.

🍿 😊 🍿 🍾

---

<div class="post-metadata">

**Author:** ![jtravs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jtravs/32/2010_2.png) [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Post date:** [June 8, 2017, 9:05am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/8 "2017-06-08T09:05:41Z")

</div>

Rather than Wikipedia, I would base them directly on CODATA. See e.g. [Fundamental Physical Constants from NIST](http://physics.nist.gov/cuu/Constants/)

I’m in favour of this, and have made heavy use of SciPy’s constants package: [Constants (scipy.constants) — SciPy v0.19.0 Reference Guide](https://docs.scipy.org/doc/scipy-0.19.0/reference/constants.html)

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 9:16am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/9 "2017-06-08T09:16:30Z")

</div>

I often thought about a package to provide physical constants, using a type similar to `Irrational` (there are constants that are multiple of `pi`), that can be automatically converted to the requested precision. In addition, it would be nice to have them with uncertainties, as provided by CODATA. Have a look to [https://github.com/giordano/Measurements.jl](https://github.com/giordano/Measurements.jl)

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [June 8, 2017, 9:28am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/10 "2017-06-08T09:28:21Z")

</div>

Constants (physical and others) should definitely support uncertainty. There are a bunch of related packages in [https://github.com/JuliaIntervals](https://github.com/JuliaIntervals) .

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 8, 2017, 9:36am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/11 "2017-06-08T09:36:01Z")

</div>

There is already a julia package for physical constants [https://github.com/DataWookie/PhysicalConstants.jl](https://github.com/DataWookie/PhysicalConstants.jl) , though it is yet unregistered. Might be a useful starting point to get in touch and either PR to or fork off that.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 9:51am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/12 "2017-06-08T09:51:41Z")

</div>

JuliaIntervals uses a mathematical arithmetic that isn’t what physicists would expect.

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [June 8, 2017, 10:02am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/13 "2017-06-08T10:02:20Z")

</div>

Slightly a side-issue, but, suppose there is a good package for constants and I want to write a simple pendulum simulation for which I need only the force of gravity. How can I make sure all the constants in the world (and their uncertainties and units) don’t take up memory?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 8, 2017, 10:40am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/14 "2017-06-08T10:40:36Z")

</div>

Memory for constants is not something you will have to worry about.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 8, 2017, 10:57am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/15 "2017-06-08T10:57:19Z")

</div>

Not even if it’s all the constants in the world? :-p

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 8, 2017, 11:00am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/16 "2017-06-08T11:00:51Z")

</div>

Constants in math are precisely defined and have no associated uncertainty. In physics there could be measurement error, but by the time it gets to be called a “constant” this is usually not a concern, or the constant is defined to be something that forms the basis of other units (eg speed of light → meter), so it is also exact. Consequently, I am not sure why you want uncertainty, can you give an example of a constant that requires it?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [June 8, 2017, 11:23am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/17 "2017-06-08T11:23:43Z")

</div>

Acceleration due to gravity `g` would certainly be useful to have and has an intrinsic variation over the earth’s surface.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 11:32am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/18 "2017-06-08T11:32:00Z")

</div>

Apart from a few quantities defined to be exact, most physical constants do have measurement uncertainties. See the CODATA database: [Fundamental Physical Constants | NIST](http://physics.nist.gov/cuu/index.html)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 8, 2017, 11:38am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/19 "2017-06-08T11:38:21Z")

</div>

@ChrisRackauckas was right, the bikeshedding is strong in this one 🙂

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 11:40am UTC](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155/20 "2017-06-08T11:40:54Z")

</div>

By the way, this package would be a great candidate for [https://github.com/JuliaPhysics](https://github.com/JuliaPhysics) 😃

[Next page](https://discourse.julialang.org/t/request-for-comment-package-for-scientific-and-mathematical-constants/4155.md?page=2)
