3

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?.

murray
  • 11,888
  • 2
  • 26
  • 50
  • 5
    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 00: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 00:52
  • @m_goldberg You may try to get the truth out of it by training yourself to answer. Here is a short introduction for enhancing your self-awareness – Dr. belisarius Jan 16 '16 at 01:25
  • 2
    @Dr.belisarius. Been there, done that, didn't work. – m_goldberg Jan 16 '16 at 02:14
  • @m_goldberg Then perhaps they are wrong :) – Dr. belisarius Jan 16 '16 at 03:24
  • I was not naive when asking my question! I was hoping there was some resource out there that might be tapped through Mathematica analogous to the resource for mathematical constants that was cited. – murray Jan 16 '16 at 15:38
  • I think this is a good question and am upvoting it. If you're working in metric units (for example), it would be very useful to know if one of your results happens to be a fundamental constant (eg, the speed of light). If something like this doesn't already exist, it would be useful to create. –  Jan 16 '16 at 17:38
  • See http://mathematica.stackexchange.com/questions/104436/have-mathematica-recognize-physical-constant –  Jan 19 '16 at 20:45
  • 1
    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
  • I rather think this question should be merged with the original, closed one. You have made a compelling case that it is possible to answer, but this really isn't a different question, is it? – Mr.Wizard Jan 20 '16 at 00:54
  • 1
    @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. –  Jan 20 '16 at 00:55
  • @barrycarter By the way, in the future if you feel you have a good Answer to a closed Question, please Flag the Question for moderator attention, noting such, and I will most often reopen it. – Mr.Wizard Jan 20 '16 at 01:00

1 Answers1

12

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][[1]] // 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[[2]]: 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,

    /usr/local/Wolfram/Mathematica/9.0/AddOns/Packages/PhysicalConstants/PhysicalConstants.m

    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? –  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 https://github.com/barrycarter/bcapps/blob/master/MATHEMATICA/bc-solve-mathematica-104178.m 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. –  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
  • To be honest, I'm not sure where to stop. I figured NIST was a good first source, but there are so many others, including Imperial System measurements, alternate unit measurements, and much more. For example, 22.4 (liters for 1 mol of ideal gas at STP) is recognized as the Ideal Gas Constant, but 8.314 (Joules per mole per Kelvin) is not. This is very much a work in progress, and I am open to suggestions (or, since it's on github, people are free to edit directly). –  Jan 21 '16 at 23:40
  • Best would be some on-line app that identifies physical constants, akin to the one that identifies mathematical constants -- the one in the link cited in my original post. – murray Jan 22 '16 at 22:05
  • NOTE: Some of the entries in the NIST constant list contained an ellipsis ("..."), which confused Mathematica and made my program give erroneous results. I have now fixed this, and now, both 8.314 and 22.4 are recognized as the Ideal Gas Constant (in different unit terms). –  Jan 23 '16 at 01:41