Skip to content

docs: show the physical constant values that math.js uses - #3740

Merged
gwhitney merged 6 commits into
josdejong:developfrom
YashG1836:docs-physical-constants
Nov 6, 2026
Merged

gwhitney merged 6 commits into
josdejong:developfrom
YashG1836:docs-physical-constants

Conversation

@YashG1836

@YashG1836 YashG1836 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The table of physical constants in docs/datatypes/units.md shows old values that are not the ones math.js returns. For example:

math.elementaryCharge.toString() // '1.602176634e-19 C', docs say 1.60217656535e-19
math.molarVolume.toString()      // '0.022413969545014137 m^3 / mol', docs say 2.241396820e-10

Many of the old values also have their uncertainty digits glued to the number (CODATA 2010 gives G = 6.67384(80)e-11, the table showed 6.6738480e-11).

This PR puts the values from src/type/unit/physicalConstants.js into the table, so the docs match the code (42 rows). Only the value column changes. The commented-out josephson row is left as it is.

AI disclosure: written with an AI coding assistant; the values were copied from src/type/unit/physicalConstants.js and checked against it.

@gwhitney

Copy link
Copy Markdown
Collaborator

As with #3741, this would be more rapidly/eagerly accepted if it included, or came in conjunction with another PR that included, testing all of the values in this table against the code as part of npm run test:all. It's concerning to the maintainers to leave the values free to stray apart from the code in the future. Thanks for considering.

@YashG1836

Copy link
Copy Markdown
Contributor Author

Thanks, good idea. Added in f339b64:

  • A test in test/unit-tests/type/unit/physicalConstants.test.js (runs with npm run test:src, so also in test:all). It reads the "Physical Constants" section of docs/datatypes/units.md (including the adopted values and natural units tables, skipping the commented-out rows) and checks every value against math[name], in the unit the constant is defined in. Plain-number constants like fineStructure are compared directly, and atm (a unit, not a constant) is compared through toSI(). A name that is neither a constant nor a unit fails the test.
  • The test found three more rows that were out of date (fineStructure, weakMixingAngle, sackurTetrode), now fixed too.
  • With the old table from develop, the test fails (first on gravitationConstant). npm run test:src: 6679 passing, eslint clean. I also merged the current develop into the branch.

@gwhitney

gwhitney commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

It seems (?) the new test fails in browser testing... please take a look when you have a chance, thanks.

@YashG1836

Copy link
Copy Markdown
Contributor Author

My mistake, sorry: the test used node:fs in test/unit-tests, and those files are also bundled for the browser tests. Fixed in 452314b:

  • Moved the check to a new file, test/node-tests/physicalConstantsDocs.test.js. It runs with npm run test:node, so it is still part of test:all, but not in the browser. physicalConstants.test.js is back to how it is on develop.
  • The new test still fails with the old table from develop (first on gravitationConstant).
  • test:src: 6693 passing. test:node: 286 passing. eslint is clean. I also merged the current develop into the branch.

@gwhitney
gwhitney merged commit 1d73398 into josdejong:develop Nov 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants