RE: newRPL: Handling of units
Hello Claudio,
I've discovered your NewRPL project and I must say it's really exciting to follow your efforts in reimagining the old faithful User RPL, at the same time ironing out some of the limitations that today are perceived as such, but at the time were more than acceptable... "Life is short, and ROM is full", as they say!
What has attracted me most is your treatment of units and angles as native objects: having units attached to vectors and symbolics allows for powerful calculations in a very straightforward manner.
Having read previous posts on the argument, I remember you (or someone else) have expressed interest in a including the units supported by the HP Prime amongst the ones already present in the code, but also that a complete list was not available.
With the help of the emulator I've compiled such a list and took the chance to test the accuracy of the conversion factors. An invaluable help in such a task is the Numericana blog ( http://www.numericana.com/) which in the past has scrutinized the implementation of the units package in the HP50G and the HP Prime. See for example http://www.numericana.com/answer/hp-prime.htm#units
I'll report below my findings, citing references where necessary. At the moment I've used the Alpha 5 Demo to perform my test, but I count on doing on the real hardware as soon as possible!
- Length and Area
Nothing to report here: NewRPL already supports the unit presents on HP50G and HP Prime.
- Volume
Here things get messy and complicated: the culprit is the definition of gallon, which has changed in time and space! Fundamentally, the situation on the HP50G (which I take as reference since it inherits the definitions of the HP48SX/GX) define three different gallons (see http://www.numericana.com/answer/units.htm#floz and http://www.numericana.com/answer/units.htm#gallon for a lenghtier discussion).
- _galUK: Imperial gallon = exactly 4.546092_l
- _galC: New Imperial gallon used in Canada = exactly 4.54609_l (note the missing last digit!)
- _gal: Winchester gallon = exactly 231_in^3
The trick is that _galUK has been in use from 1976 to 1985, when UK switched to _galC. I think it would be more sensible to retain the difference between the two definitions as HP did, and add a new definition for the Canadian (and later UK ounce): 1_galC = 160_ozC.
The HP Prime team has also created alternative definitions for the pint and the bushel to take into account the different gallons, even if the effort has not taken to the full consequences. The HP50's _pt and _bu have been renamed to _liqpt (why?!?) and _buUS, a new _ptUK has been created and a new _bu unit has been defined using the Canadian gallon.
Very confusing, IMHO.
Since all the units have the same relative weight, differing only in the definition of the base unit (with the exception of the _ozfl) I have this proposal for NewRPL:
- a set of US units: _gal, _ozfl (= 1/128_gal), _pt, _qt, _bu, _pk, _tsp, _tbsp
- a set of Old Imperial units: _galUK, _ozUK (= 1/160_galUK), _ptUK, _qtUK, _buUK, _pkUK, _tspUK, _tbspUK
- a set of New Imperial units: _galC, _ozC (= 1/160_galC), _ptC, _qtC, _buC, _pkC, _tspC, _tbspC
A bit overkill, but coherent!
- Speed
HP Prime team has conveniently added definitions for _rad/s, _tr/min (= 2*pi_rad/min) and _tr/s (= 2*pi_rad/s). Very useful to have a dedicated definition so you don't have to navigate Angle and Time menus.
*** WARNING: There is a bug in NewRPL! 1_rpm shouldn't be 60_1/s, but rather 1_1/min ***
- Mass
Here HP Prime team has only renamed the _ton to _tonUS: If my proposal for volume units is accepted, I'd suggest to leave the name unchanged, coherently with the convention of not tagging US customary units with "US".
BTW, could you add the _gmol (= 1_mol) and the _lbmol (= 453.59237_gmol, exactly) to the catalogue? These units were present in the HP50G, under an Equation Library submenu.
- Acceleration
This is a new menu specific of the HP Prime: I find it very convenient, since these units often don't have a dedicated name such as Newton or Ampere and require a lot of keystrokes to be entered. Here we have:
- _m/s^2
- _ft/s^2
- _grav, which is just _ga with a fancy name
- _Gal (= 1_cm/s^2)
- _rad/s^2
- Power
Hp Prime added convenient shortcuts for _MW and _ft*lbf/s.
May I suggest the addition of the metric horsepower (1_ch = 75_m*kgf/s) and the _Btu/h?
- Electricity
HP Prime team added a shortcut for the _A*h.
- Angle
Added the _gon (= 1_grad, it's an alias used in some countries) and the _tr (= 2*pi_rad).
Since you've turned the _sr into a fully recognized unit would you consider adding _spat (= 4*pi_sr), _°^2 (= (pi/180)^2_sr), _arcmin^2 (= 1/3600_°^2) and _arcs^2 (= 1/3600_arcmin^2)? They're currently used in many astronomy textbooks.
- Viscosity
HP Prime team added a shortcut for the _m^2/s. Maybe an alias for the _kg/(m*s) would be useful too? in my textbooks I've never seen Poises or Stokes, but only their cumbersome SI counterparts.
- Light
Nothing to report here, but kudos for having made explicit the presence of steradians in the definitions of some units!
- Radiation
Nothing to report here too.
- Pressure
The _inH2O has a precise and exact definition, based on a conventional value of water density: therefore 1_inH2O is exactly defined as 1_in*1_ga*999.972_kg/m^3 (see: http://www.numericana.com/answer/constants.htm#h2o).
1_torr is not equal to 1_mmHg (and besides, it's _Torr). The explanation is that, as you correctly implemented in NewRPL, 1_mmHg = 1_mm*1_ga*13595.1_kg/m^3 (exactly); on the contrary, the _Torr is defined as (101325/760)_Pa (exactly). The two values are very close, but are not the same... (see: http://www.numericana.com/answer/casio.htm#mmhg).
- Energy
This is complicated: first of all, http://www.numericana.com/answer/casio.htm#ist eloquently asserts that since 1935 all the results published in calories refer to the thermodynamical calorie: 1_cal = 4.184_J. All other definitions of calorie are either unaccurate or bogus or obsolete.
But let's go on: HP Prime team defines two shortcuts for _Wh and _kWh: so far, so good.
Now, here come the _therm...
HP Prime gives three different definitions of _therm, and none of them match the definition of the HP50G or the definition in NewRPL, because they depend on the definition of the _Btu, and they are legion.
To get the things straight:
- The _therm is always defined as 10^5_Btu, whatever a _Btu is.
- NewRPL's _Btu is the so-called Btu_IT: it's definition is precise, accepted and widespread, but unfortunately none of the _therm's is actually defined upon it.
- _thermEC is defined as 10^5_Btu_ISO and it's exactly 105505600_J
- _therm is defined as 10^5_Btu_59°F and it's exactly 105480400_J
- _thermUK is defined as 10^5_some_unknown_Btu_noelsewhere_defined: it's value is exactly 105505585.257348_J. I have no primary source to justify this value, but since all secondary sources bother to list 6 decimals, I assume that the conversion factor is exact.
Next, follows some technical units used in the industry, but not used in scientific papers:
- _toe (Tonne of Oil Equivalent) = exactly 41.868_GJ. Source: https://www.iea.org/publications/freepub...manual.pdf
- _boe (Barrel of Oil Equivalent) = exactly 5.8*10^6_BTU_59°F = 6117863200_J. Source: http://www.irs.gov/pub/irs-drop/n-99-18.pdf
- _tec (Tonne of Coal Equivalent) = 27.84_GJ (as reported by the HP Prime). This one is unconfirmed: none of the definitions I've found on the web match the value reported by the HP Prime.
- _lep (Liter of ??? Equivalent) = 35788320_J (as reported by the HP Prime). I haven't been able to find any info about this unit. Comparing it with the next unit, it's evident that the 'l' stands for 'liters'.
- _bblep (Barrel of ??? Equivalent) = 5689888186.82_J (as reported by the HP Prime). Absolutely no info found about this one, except for the fact that it expresses a _lep in barrels (_bbl) units: multiplying 35788320_J*1_bbl/l you get the value provided by the HP Prime.
- _cf (???) = 1080000_J (as reported by the HP Prime). This one too remains a mystery to me. At least, the conversion factor seems exact.
- Other
The decibel (1_dB = 1) is the last of the units present in the Equation Library and actually is not supported by NewRPL. It should be added for compatibility's sake. Maybe it could be put in the Electricity catalogue, but could also become the first unit of a new Adimensional catalogue.
I hope I haven't been too nitpicky, but I'm really interested in NewRPL, and I wish it sports the most up-to-date set of conversion units!
Regards,
Stefano
|