"Numbers are the product of counting. Quantities are the product of measuring" (Gregory Bateson).
Physical Magnitudes
In physics, a certain magnitude is expressed by two data:
The quantity, which is a number (e.g., 12.5).
The unit, which can be:
Simple (e.g. meter, second, kilogram, etc.).
Compound: an arithmetic expression formed from other simple units (e.g. m/sec²).
An example of the composite magnitude acceleration is 12.5 m/sec².
In this expression, the quantity and the unit (simple or compound) appear "loose", i.e., there is no form of expression of the magnitude that encompasses them. Although this is perfectly admissible in everyday life, it is not so from a formal or computational point of view.
This problem is compounded when one intends to perform (consistent or inconsistent) computations with magnitudes, e.g.:
6 m/sec * 12 m/sec
3 grams + 4.7 sec
Specification in MENTAL
Specification of magnitudes
A quantity is specified by the expression quantity*unit. For example,
3*meter
12*second
12.5*(meter÷(sec^2))
These expressions make sense because:
The unit (simple or compound) is self-evaluating.
The quantity is a multiplicative factor of the unit.
Calculation with magnitudes
Expressed the magnitudes in the described way, it is possible to perform calculations with magnitudes, operating at the same time with quantities and with units. For this purpose, the following properties must be taken into account, where u and v represent units (simple or compound), and r1 and r2, quantities (real numbers):
Type of magnitudes
Operation
Property
Homogéneas
Sum
〈( (f1*u + f2*u) = (f1+f2)*u )〉
Subtract
〈( (f1*u − f2*u) = (f1−f2)*u )〉
Product
〈( f1*u * f2*u = (f1*f2)*(u^2) )〉
Division
〈( f1*u ÷ f2*u = (f1÷f2) )〉
Heterogeneous
Sum
(f1*u + f2*v) // self-evaluates
Resta
(f1*u − f2*v) // self-evaluates
Product
〈( f1*u * f2*v = (f1*f2)*(u*v) )〉
Division
〈( f1*u ÷ f2*v = (f1÷f2)*(u÷v) )〉
In the case of quotient between homogeneous quantities, we have a dimensionless (unitless) quantity.
Names can be assigned to compound units. For example, if we do
( erg =: ((cm^2)*gram)÷(sec^2) )
then the expression 123*ergio represents the expression.
123*(((cm^2)*gramo)÷(seg^2)))
Unit change
If you want to change the unit of a certain magnitude, it is sufficient to define the equivalence between the units. For example:
(x = 8*meter)
(meter = 100*cm)
x // is automatically evaluated as 800*cm
If you want to re-express the magnitude in meters, you have to define the inverse unit:
(cm = 0.01*meter)
x // evaluates again as 8*meter
Specification of quantities in functions
It is possible to specify magnitudes also in functions, both in the arguments and in the result. Examples:
If we have the function sine(r*radian), r must be a real number expressing an angle in radians. If we want to invoke the function with r in sexagesimal degrees, we would have to do:
(degree = (π÷180)*radian)
sine(r*degree)
If we have the function atan(r)*radian, and we want the result in degrees, we would have to do:
(radian = (180÷π)*degree)
atan(r)*radian // the result is an angle in degrees.
and we do, for example, 〈( Kilo*r = (10^3)*r )〉, we are specifying an automatic conversion for all types of units, as long as the prefix takes the form Kilo*:
Qualitative magnitudes are magnitudes that constitute a quality or a totality, such as green, high, rich, slow, slow, true, and so on. These magnitudes can have a factor between 0 and 1, which indicates the degree of that quality. For example: 0.3*high, 0.6*large, etc.
There can also be opposite qualitative magnitudes, related by complementary factors. For example:
The attribute high (and its opposite low) can be affected by a factor f (between 0 and 1) that expresses its degree of approximation to that attribute. For example, 0.7*high, 0.3*low, etc. The relationship between these two opposite concepts is:
In this case, the opposite attributes have factors complementary to 1, so they can be considered complementary attributes.
The logical values true (V) and false (F) can also be treated as complementary quantities. For example, 0.7*V indicates 70% truth, with V being the "unit" of truth. And 0.3*F indicates 30% falsehood. The "amount" of truth (or falsity) is a real number between 0 and 1, such that properties similar to the above are satisfied:
Magnitudes improve comprehension, as the semantic level is higher. Pure data (quantities) without units assume the minimal semantics, the one associated with numbers.
Calculations can be performed with different units in the arguments. Examples:
Magnitude can appear in any type of expression. For example,
(12*m 2*seg) (13 12 10)*(m^2) {a b}*(m¸seg)
Addendum
Units in programming languages
In general, programming languages do not include the possibility of specifying units associated with numerical values. One of the few languages that do support units is C/ATLAS [see Bibliography], but with limitations: there is only a predefined set of units and the combinations between them are restricted.
In any case, several proposals have been made to adapt various programming languages (Ada, Pascal, C++, Lisp, Standard ML, etc.) to contemplate units of measurement as data attributes [see Bibliography].
When a programming language does not contemplate units, their handling in functions and algorithms has to be done by the programmer, which is a potential source of errors. To avoid these errors, default units should not be assumed, i.e., they should be specified explicitly.
Karr and Loveman [1978] have proposed that units be incorporated into programming languages, but as reserved words, which is a limitation, a limitation that does not exist in MENTAL:
You can define as many units as you wish.
La expresión r*unidad integra cantidad y unidad.
Automatic conversion rules can be defined.
Calculation results may incorporate units.
In functions, arguments and results can be magnitudes.
International system of units
It is based on seven fundamental (or primitive) units: meter (length), second (time), kilogram (mass), ampere (intensity of electric current), degree Kelvin (temperature), mole (amount of substance) and candela (luminous intensity). The rest of the units are derivatives, such as, 1 Julio = 1 Kgr*m2/seg2 [Anderson, 1989].
Bibliography
Anderson, H.L. (ed.). Physicist´s Desk Reference. American Institute of Physics, 1989.
Bateson, Gregory. Number is different from Quantity. Internet.
Cunis, Roman. A Package for Handling Units of Measure in Lisp. Internet.
Gehani, N.H. Units of Measure as a Data Attribute. Computing Languages, vol. 2, no. 3, pp. 93−111, 1977.
Gehani, N.H. Databases and Units of Measure. IEEE Trans. Soft. Eng., June 1982, pp. 605−611.
Gehani, N.H. Ada´s Derived Types and Units of Measure. Software Practice and Experience, June 1985, pp. 555−569.
IEEE Standard C/ATLAS. IEEE Standar 716−1982.
Karr, M.; Loveman, D.B. Incorporation of Units into Programming Languages. Communications of the ACM, vol. 21, no. 5, pp. 385−391, May 1978.
Novak, Gordon S. (Jr.). Conversion of Units of Measurement. Internet, 1977.