# Recognize physical constants?

Is there some way to ask Mathematica to recognize physical constants, such as 32 or 9.81 (gravitational acceleration, in different units, at Earth's surface)?

I have in mind something like the "inverse symbolic calculator" for strictly mathematical constants that is described in Can Mathematica propose an exact value based on an approximate one?.

• This is an extremely difficult question without specification of units / what qualifes as a physical constant. If you ask: what is 4? Well, it's the number of quarts in a gallon, the number of cups in a quart, number of quarters in a dollar, number of... etc. How much is 3 mL? Oh, simple, it's 0.6087... teaspoons. Ah, teaspoons aren't a physical constant? OK, it's 0.97 barn*megaparsec, and a barn is such-and-such nuclear cross section and a megaparsec is the typical length scale between galaxies in our universe... etc. – evanb Jan 16 '16 at 0:06
• I don't see how you can expect Mathematica to recognize that 9.8 is supposed to represent the constant for gravitational acceleration near the earth's surface since it is not an artificial intelligence program. Heck, I don't think I would necessarily recognize 9.8 as a special physical constant if I saw it written down without much context. Maybe that's because, as it has been pointed out to me, I am not a natural intelligence. – m_goldberg Jan 16 '16 at 0:52
• @Dr.belisarius. Been there, done that, didn't work. – m_goldberg Jan 16 '16 at 2:14
• Personally, I think it should be developed into a standard mathematica function with unit support and many more things like physical context, recognising closest products of constants and integer numbers of them etc. Great initiative! – Alexey Bobrick Jan 19 '16 at 20:58
• @Mr.Wizard I 100% agree. I tried to answer the original question first, but it was on hold so I couldn't. If you could do whatever magic is required to turn this into an answer to that question, I'd appreciate it. – barrycarter Jan 20 '16 at 0:55

I've now created https://github.com/barrycarter/bcapps/blob/master/MATHEMATICA/nearestPhysicalConstant.mx as a first cut at doing this. Important notes/caveats:

• This is not a professional/"real" package. To use, do math -initfile PhysicalConstant.mx on the command line or <<PhysicalConstant.mx after starting Mathematical.

• The function nearestPhysicalConstant returns the entire list of known constants, sorted by mantissa distance from the argument. You will probably want just the few entries of the result. Example:

Take[nearestPhysicalConstant[Pi*E],5] // TeXForm


$\left( \begin{array}{cc} \{\text{deuteron mag. mom. to nuclear magneton ratio},0.857438,\text{4.8$\grave{ }$*${}^{\wedge}$-9},1\} & -0.00346481 \\ \{\text{deuteron g factor},0.857438,\text{4.8$\grave{ }$*${}^{\wedge}$-9},1\} & -0.00346481 \\ \{\text{atomic unit of electric dipole mom.},\text{8.478353551999999$\grave{ }$*${}^{\wedge}$-30},\text{5.2$\grave{ }$*${}^{\wedge}$-38},C m\} & 0.00613807 \\ \left\{\text{Boltzmann constant in eV/K},0.0000861733,\text{5.000000000000001$\grave{ }$*${}^{\wedge}$-11},\frac{\text{eV}}{K}\right\} & -0.00775961 \\ \{\text{electron to shielded helion mag. mom. ratio},864.058,0.00001,1\} & -0.0100848 \\ \end{array} \right)$

• Taking a closer look at just the first result:

nearestPhysicalConstant[Pi*E][] // InputForm
{{"deuteron mag. mom. to nuclear magneton ratio", 0.8574382311, 4.8*^-9, 1}, -0.003464808832643218}


Assigning x to the result above, here's what the result means:

• x[[1,1]]: the name of the physical constant

• x[[1,2]]: the value of the physical constant. Note that Pi*E is 8.53973, but the constant value is 0.857438. This is considered a close match because I only compare mantissas, not the entire number.

• x[[1,3]]: uncertainty in the physical constant

• x[[1,4]]: units of the physical constant ("1" meaning unitless). I didn't make any effort to clean this up, so you shouldn't rely on it or use it without doublechecking.

• x[]: the difference in mantissas of your provided number and the physical constant.

• I'm using http://physics.nist.gov/cuu/Constants/Table/allascii.txt as my list of constants, but it's far from complete. For example,

includes EarthRadius, where as the NIST list does not, not even in alternate units (and not the earth's diameter or anything like that either).

• All NIST constants are in the SI (metric) system, so nearestPhysicalConstant will recognize 9.8 as being close to "standard acceleration of gravity", but won't recognize 32 (the first result for 32 is "atomic unit of 1st hyperpolarizability"). As others have noted, you should only use nearestPhysicalConstant if you are dealing in SI (metric) units.

• I plan to add more constants, but since there is limited usefulness here. For example, "1.4815*10^23" is the mass of Ganymede, but I'm not sure how useful it would be to add that. Additionally, the function is written inefficiently and may become too slow with the addition of more constants (though I could potentially recode it at some point).

• For reference, I used the following programs to create this "package":

https://github.com/barrycarter/bcapps/blob/master/MATHEMATICA/bc-solve-mathematica-104178.m

https://github.com/barrycarter/bcapps/blob/master/MATHEMATICA/bc-solve-mathematica-104178.pl

I welcome any improvements to this open source code.

• when trying to load the .mx file, I get error message "DumpGet::bgabi: File ./nearestPhysicalConstant.mx was written with ABI 32, which is not compatible with this version of the Wolfram Language." – murray Jan 20 '16 at 18:41
• I wrote it in "9.0 for Linux x86 (32-bit) (November 20, 2012)", what version are you using? Maybe it's a 32/64 bit issue? – barrycarter Jan 20 '16 at 19:03
• I'm using 10.3.1 for Mac OS X x86 (64-bit). – murray Jan 20 '16 at 20:07
• I've now edited github.com/barrycarter/bcapps/blob/master/MATHEMATICA/… so that it's the only file you need to load (and is in "text" format, so should work properly). I'm disappointed that Mathematica MX files are not platform-independent and backwards compatible. – barrycarter Jan 21 '16 at 18:39
• Worked nicely for me to identify 9.81, which is the original example I posted. Sort of worked for 32: the entry in output for "gravity" gives the metric value 9.80665 but not the corresponding English units value. – murray Jan 21 '16 at 22:51