Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,16 @@ Dheemanth D <165369664+Dheemanth07@users.noreply.github.com>
Adriano Fantini <adrfantini@users.noreply.github.com>
Chibuike Anselm <chibuikeanselm@Chibuikes-MacBook-Pro.local>
Jos de Jong <email@josdejong.com>
JSap0914 <JSap0914@users.noreply.github.com>
rrbharath <ryanrbharath@gmail.com>
Lê Vạn Bảo Trọng <32262183+chuanghiduoc@users.noreply.github.com>
Yash Goyal <yashgoyal17305@gmail.com>
Hugohong258 <ugfifkgfufyu@gmail.com>
Spoko Dev <spoko.dev@gmail.com>
Yash Goyal <24110399@iitgn.ac.in>
Wei-Lun Li <b84330808@gmail.com>
wulimammoth <ctelestial@gmail.com>
kevin <5299031+kevin9327@users.noreply.github.com>
WenJing95 <126436871+WenJing95@users.noreply.github.com>
W <184799977+waw666waw666@users.noreply.github.com>
JSap0914 <JSap0914@users.noreply.github.com>

# Generated by tools/update-authors.js
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# unpublished changes since 15.2.0

- Docs: update values of physical constants in units doc page, and
institute a check that they match the values in the math instance (#3740).
Thanks @YashG1836.
- Feat: support bigint in stirlingS2(n,k) and ensure that result is
always of correct type (#3663). Thanks @JSap0914 and @gwhitney.
- Docs: #3401 add pages for String and Boolean types, clarify that concat
Expand Down
90 changes: 45 additions & 45 deletions docs/datatypes/units.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,26 +414,26 @@ Math.js includes the following physical constants. See [Wikipedia](https://en.wi
Name | Symbol | Value | Unit
----------------------|--------------------------------------------------------|-------------------|-------------------------------------------------------
speedOfLight | <i>c</i> | 299792458 | m &#183; s<sup>-1</sup>
gravitationConstant | <i>G</i> | 6.6738480e-11 | m<sup>3</sup> &#183; kg<sup>-1</sup> &#183; s<sup>-2</sup>
planckConstant | <i>h</i> | 6.626069311e-34 | J &#183; s
reducedPlanckConstant | <i><span style="text-decoration:overline">h</span></i> | 1.05457172647e-34 | J &#183; s
gravitationConstant | <i>G</i> | 6.67430e-11 | m<sup>3</sup> &#183; kg<sup>-1</sup> &#183; s<sup>-2</sup>
planckConstant | <i>h</i> | 6.62607015e-34 | J &#183; s
reducedPlanckConstant | <i><span style="text-decoration:overline">h</span></i> | 1.0545718176461565e-34 | J &#183; s


#### Electromagnetic constants

Name | Symbol | Value | Unit
--------------------------|--------------------------------------------------|-----------------------|----------------------------------------
magneticConstant | <i>&mu;<sub>0</sub></i> | 1.2566370614e-6 | N &#183; A<sup>-2</sup>
electricConstant | <i>&epsilon;<sub>0</sub></i> | 8.854187817e-12 | F &#183; m<sup>-1</sup>
vacuumImpedance | <i>Z<sub>0</sub></i> | 376.730313461 | &ohm;
coulomb | <i>&kappa;</i> | 8.9875517873681764e9 | N &#183; m<sup>2</sup> &#183; C<sup>-2</sup>
elementaryCharge | <i>e</i> | 1.60217656535e-19 | C
bohrMagneton | <i>&mu;<sub>B</sub></i> | 9.2740096820e-24 | J &#183; T<sup>-1</sup>
conductanceQuantum | <i>G<sub>0</sub></i> | 7.748091734625e-5 | S
inverseConductanceQuantum | <i>G<sub>0</sub><sup>-1</sup></i> | 12906.403721742 | &ohm;
magneticFluxQuantum | <i><font face="Symbol">f</font><sub>0</sub></i> | 2.06783375846e-15 | Wb
nuclearMagneton | <i>&mu;<sub>N</sub></i> | 5.0507835311e-27 | J &#183; T<sup>-1</sup>
klitzing | <i>R<sub>K</sub></i> | 25812.807443484 | &ohm;
magneticConstant | <i>&mu;<sub>0</sub></i> | 1.25663706212e-6 | N &#183; A<sup>-2</sup>
electricConstant | <i>&epsilon;<sub>0</sub></i> | 8.8541878128e-12 | F &#183; m<sup>-1</sup>
vacuumImpedance | <i>Z<sub>0</sub></i> | 376.730313667 | &ohm;
coulomb | <i>&kappa;</i> | 8.987551792261171e9 | N &#183; m<sup>2</sup> &#183; C<sup>-2</sup>
elementaryCharge | <i>e</i> | 1.602176634e-19 | C
bohrMagneton | <i>&mu;<sub>B</sub></i> | 9.2740100783e-24 | J &#183; T<sup>-1</sup>
conductanceQuantum | <i>G<sub>0</sub></i> | 7.748091729863649e-5 | S
inverseConductanceQuantum | <i>G<sub>0</sub><sup>-1</sup></i> | 12906.403729652257 | &ohm;
magneticFluxQuantum | <i><font face="Symbol">f</font><sub>0</sub></i> | 2.0678338484619295e-15 | Wb
nuclearMagneton | <i>&mu;<sub>N</sub></i> | 5.0507837461e-27 | J &#183; T<sup>-1</sup>
klitzing | <i>R<sub>K</sub></i> | 25812.807459304513 | &ohm;

<!-- TODO: implement josephson
josephson | <i>K<sub>J</sub></i> | 4.8359787011e-14 | Hz &#183; V<sup>-1</sup>
Expand All @@ -444,39 +444,39 @@ josephson | <i>K<sub>J</sub></i> | 4

Name | Symbol | Value | Unit
------------------------|------------------------------|-----------------------|----------------------------------
bohrRadius | <i>a<sub>0</sub></i> | 5.291772109217e-11 | m
classicalElectronRadius | <i>r<sub>e</sub></i> | 2.817940326727e-15 | m
electronMass | <i>m<sub>e</sub></i> | 9.1093829140e-31 | kg
fermiCoupling | <i>G<sub>F</sub></i> | 1.1663645e-5 | GeV<sup>-2</sup>
fineStructure | <i>&alpha;</i> | 7.297352569824e-3 | -
hartreeEnergy | <i>E<abbr>h</abbr> </i> | 4.3597443419e-18 | J
protonMass | <i>m<sub>p</sub></i> | 1.67262177774e-27 | kg
bohrRadius | <i>a<sub>0</sub></i> | 5.29177210903e-11 | m
classicalElectronRadius | <i>r<sub>e</sub></i> | 2.8179403262e-15 | m
electronMass | <i>m<sub>e</sub></i> | 9.1093837015e-31 | kg
fermiCoupling | <i>G<sub>F</sub></i> | 1.1663787e-5 | GeV<sup>-2</sup>
fineStructure | <i>&alpha;</i> | 7.2973525693e-3 | -
hartreeEnergy | <i>E<abbr>h</abbr> </i> | 4.3597447222071e-18 | J
protonMass | <i>m<sub>p</sub></i> | 1.67262192369e-27 | kg
deuteronMass | <i>m<sub>d</sub></i> | 3.3435830926e-27 | kg
neutronMass | <i>m<sub>n</sub></i> | 1.6749271613e-27 | kg
quantumOfCirculation | <i>h / (2m<sub>e</sub>)</i> | 3.636947552024e-4 | m<sup>2</sup> &#183; s<sup>-1</sup>
rydberg | <i>R<sub>&infin;</sub></i> | 10973731.56853955 | m<sup>-1</sup>
thomsonCrossSection | | 6.65245873413e-29 | m<sup>2</sup>
weakMixingAngle | | 0.222321 | -
quantumOfCirculation | <i>h / (2m<sub>e</sub>)</i> | 3.6369475516e-4 | m<sup>2</sup> &#183; s<sup>-1</sup>
rydberg | <i>R<sub>&infin;</sub></i> | 10973731.568160 | m<sup>-1</sup>
thomsonCrossSection | | 6.6524587321e-29 | m<sup>2</sup>
weakMixingAngle | | 0.22290 | -
efimovFactor | | 22.7 | -


#### Physico-chemical constants

Name | Symbol | Value | Unit
--------------------|------------------------------|---------------------|--------------------------------------------
atomicMass | <i>m<sub>u</sub></i> | 1.66053892173e-27 | kg
avogadro | <i>N<sub>A</sub></i> | 6.0221412927e23 | mol<sup>-1</sup>
boltzmann | <i>k</i> | 1.380648813e-23 | J &#183; K<sup>-1</sup>
faraday | <i>F</i> | 96485.336521 | C &#183; mol<sup>-1</sup>
firstRadiation | <i>c<sub>1</sub></i> | 3.7417715317e-16 | W &#183; m<sup>2</sup>
loschmidt | <i>n<sub>0</sub></i> | 2.686780524e25 | m<sup>-3</sup>
gasConstant | <i>R</i> | 8.314462175 | J &#183; K<sup>-1</sup> &#183; mol<sup>-1</sup>
molarPlanckConstant | <i>N<sub>A</sub> &#183; h</i>| 3.990312717628e-10| J &#183; s &#183; mol<sup>-1</sup>
molarVolume | <i>V<sub>m</sub></i> | 2.241396820e-10 | m<sup>3</sup> &#183; mol<sup>-1</sup>
sackurTetrode | | -1.164870823 | -
secondRadiation | <i>c<sub>2</sub></i> | 1.438777013e-2 | m &#183; K
stefanBoltzmann | <i>&sigma;</i> | 5.67037321e-8 | W &#183; m<sup>-2</sup> &#183; K<sup>-4</sup>
wienDisplacement | <i>b</i> | 2.897772126e-3 | m &#183; K
atomicMass | <i>m<sub>u</sub></i> | 1.66053906660e-27 | kg
avogadro | <i>N<sub>A</sub></i> | 6.02214076e23 | mol<sup>-1</sup>
boltzmann | <i>k</i> | 1.380649e-23 | J &#183; K<sup>-1</sup>
faraday | <i>F</i> | 96485.33212331001 | C &#183; mol<sup>-1</sup>
firstRadiation | <i>c<sub>1</sub></i> | 3.7417718521927573e-16 | W &#183; m<sup>2</sup>
loschmidt | <i>n<sub>0</sub></i> | 2.686780111798444e25 | m<sup>-3</sup>
gasConstant | <i>R</i> | 8.31446261815324 | J &#183; K<sup>-1</sup> &#183; mol<sup>-1</sup>
molarPlanckConstant | <i>N<sub>A</sub> &#183; h</i>| 3.990312712893431e-10| J &#183; s &#183; mol<sup>-1</sup>
molarVolume | <i>V<sub>m</sub></i> | 0.022413969545014137 | m<sup>3</sup> &#183; mol<sup>-1</sup>
sackurTetrode | | -1.16487052358 | -
secondRadiation | <i>c<sub>2</sub></i> | 0.014387768775039337 | m &#183; K
stefanBoltzmann | <i>&sigma;</i> | 5.67037441918443e-8 | W &#183; m<sup>-2</sup> &#183; K<sup>-4</sup>
wienDisplacement | <i>b</i> | 2.897771955e-3 | m &#183; K

<!-- TODO: implement spectralRadiance
spectralRadiance | <i>c<sub>1L</sub></i> | 1.19104286953e-16 | W &#183; m<sup>2</sup> &#183; sr<sup>-1</sup>
Expand All @@ -490,8 +490,8 @@ The value of `sackurTetrode` is at `T = 1 K` and `p = 101.325 kPa`.

Name | Symbol | Value | Unit
--------------|------------------------------|---------|-------------------------
molarMass | <i>M<sub>u</sub></i> | 1e-3 | kg &#183; mol<sup>-1</sup>
molarMassC12 | <i>M(<sub>12</sub>C)</i> | 1.2e-2 | kg &#183; mol<sup>-1</sup>
molarMass | <i>M<sub>u</sub></i> | 0.99999999965e-3 | kg &#183; mol<sup>-1</sup>
molarMassC12 | <i>M(<sub>12</sub>C)</i> | 11.9999999958e-3 | kg &#183; mol<sup>-1</sup>
gravity | <i>g<sub>n</sub></i> | 9.80665 | m &#183; s<sup>-2</sup>
atm | <i>atm</i> | 101325 | Pa

Expand All @@ -500,8 +500,8 @@ atm | <i>atm</i> | 101325 | Pa

Name | Symbol | Value | Unit
------------------|-----------------------|--------------------|-----
planckLength | <i>l<sub>P</sub></i> | 1.61619997e-35 | m
planckMass | <i>m<sub>P</sub></i> | 2.1765113e-8 | kg
planckTime | <i>t<sub>P</sub></i> | 5.3910632e-44 | s
planckCharge | <i>q<sub>P</sub></i> | 1.87554595641e-18 | C
planckTemperature | <i>T<sub>P</sub></i> | 1.41683385e+32 | K
planckLength | <i>l<sub>P</sub></i> | 1.616255e-35 | m
planckMass | <i>m<sub>P</sub></i> | 2.176435e-8 | kg
planckTime | <i>t<sub>P</sub></i> | 5.391245e-44 | s
planckCharge | <i>q<sub>P</sub></i> | 1.87554603778e-18 | C
planckTemperature | <i>T<sub>P</sub></i> | 1.416785e+32 | K
38 changes: 38 additions & 0 deletions test/node-tests/physicalConstantsDocs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import assert from 'node:assert'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { approxEqual } from '../../tools/approx.js'
import { create, all } from '../../lib/esm/index.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const math = create(all)

describe('table of physical constants in the docs', function () {
it('should match the values in the code', function () {
const section = fs.readFileSync(path.resolve(__dirname, '../../docs/datatypes/units.md'), 'utf8')
.split('### Physical Constants')[1]
.split(/\n#{2,3} /)[0]
.replace(/<!--[\s\S]*?-->/g, '') // skip the commented-out rows

const rows = section.split('\n')
.map(line => line.split('|').map(cell => cell.trim()))
.filter(cells => cells.length === 4 && cells[2] !== '' && !isNaN(Number(cells[2])))

assert(rows.length > 40, 'the table should be found')
for (const [name, , value] of rows) {
const constant = math[name]
let actual
if (typeof constant === 'number') {
actual = constant // dimensionless constants such as fineStructure
} else if (constant !== undefined) {
actual = constant.toNumber()
} else {
// adopted values such as atm are units, not constants
assert(math.Unit.isValuelessUnit(name), `${name} should be a physical constant or a unit`)
actual = math.unit(1, name).toSI().toNumber()
}
approxEqual(Number(value), actual, 1e-12)
}
})
})
8 changes: 8 additions & 0 deletions tools/update-authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ const replaceEmails = {
author: 'Hugohong258',
email: '<ugfifkgfufyu@gmail.com>'
},
'<24110399@iitgn.ac.in>': {
author: 'Yash Goyal',
email: '<yashgoyal17305@gmail.com>'
},
'<116227558+JSap0914@users.noreply.github.com>': {
author: 'JSap0914',
email: '<JSap0914@users.noreply.github.com>'
}
}

// Commits from which we do not want the author to pop up in the AUTHORS list,
Expand Down
Loading