Re: Dimensional analysis with fundeps (some physics comments)

[[MOVED FROM haskell TO haskell-cafe]] Nothing to do with Haskell. Pure computer scientists, not interested in physics might not find anything in this posting. Tom Pledger wrote: //about dimensions, units...//
If you clearly make the type system deal with dimensions rather than units, there's no problem with plugging in multiple unit systems. You just have to pick a scale for the representation.
newtype Dimensioned mass length time rep = Dimensioned rep
type Mass rep = Dimensioned One Zero Zero rep
kg, lb :: Num a => Mass a kg = dm 1 lb = dm 0.4535924
Angles are dimensionless. (Think of the Taylor series for trig functions.)
radian, degree :: Unit radian = dm 1 degree = dm (pi/180)
The distinction between dimensions and units may seem for some of you utterly trivial. Mass is a mass, kg -> lb, etc. are just conversion factors. Angles are dimensionless. It was not so trivial for the authors of SI, and for some speculative physicists, who are not all dead yet. The problem is: what is a *fundamental*, *universal* constant? You see, those constants establish our unit systems! Many, really many among my friends don't hesitate to work in a frame where the speed of light is equal to 1. Yes, ONE, dimensionless. Then, passing from length to time is just a unit conversion, and all velocities are dimensionless. (Like, say, steradians in SI?...) Who needs candelas? Who needs Amperes What is the dimension of a mole? (In SI it is an independent unit) Who needs Kelvins? Everybody (within a particular mafia I happen to know) knows very well that the temperature is/should be measured in energy units, i.e., the Boltzmann constant k is equal to 1, dimensionless. Now, even if you won't (probably) find people who would claim that the status of k or c is the same as PI/180, the question "what is a unit" has no unambiguous and non-conventional answer. You may put the universal gravitational constant to 1. Or simply put to 1 the Plankeon mass, and get rid of all the mass "dimensional units". == And if you leave the world of classical physics, and start to analyze the structure of quantum theories you may get some nasty surprises. //Now I have to trivialize a bit// (First, most people who do some calculations in QM put the Planck constant equal to 1, so the energy is inverse time...) Some quantities which should - for geometric reasons - have fixed dimensions, such as the "force" of a field respecting Laplace equation: ~1/r^2 (Newton, Coulomb), get what is called the "anomalous dimension", instead of 2 one has to play with r^(2+x), with x fractional (some people, I suppose that Andrew Kennedy is one of them, don't like such things...). Now, if something which should be - classically - dimensionless, say p^0 acquires this anomaloud dimension p^x, then the only computationally sane way of dealing with it is to introduce a new "universal" (?) dimensional constant q, such that the expression above may be written as (p/q)^x in appropriate units of p and q. Then, no x may do any harm. This phenomenon, the "dimensional transmutation" suggests that it is not clear which is the set of universal dimensional quantities in quantum world. == I like all papers about dimensions, and it is very refreshing to see how people squeeze them into the type systems. (Or play with geometrical "navigation" in a dimensional world: http://mail.collegestudent.com/gda01/GDA01.HTM http://physics.nist.gov/cuu/Units/SIdiagram.html ) I believe, however, that one should not forget that all that is *conventional*. Jerzy Karczmarczuk Caen, France

On 10-Apr-2001, Jerzy Karczmarczuk
Tom Pledger wrote: //about dimensions, units...//
If you clearly make the type system deal with dimensions rather than units, there's no problem with plugging in multiple unit systems. You just have to pick a scale for the representation.
newtype Dimensioned mass length time rep = Dimensioned rep
type Mass rep = Dimensioned One Zero Zero rep
kg, lb :: Num a => Mass a kg = dm 1 lb = dm 0.4535924
Angles are dimensionless. (Think of the Taylor series for trig functions.)
radian, degree :: Unit radian = dm 1 degree = dm (pi/180)
The distinction between dimensions and units may seem for some of you utterly trivial. Mass is a mass, kg -> lb, etc. are just conversion factors. Angles are dimensionless.
It was not so trivial for the authors of SI, and for some speculative physicists, who are not all dead yet. The problem is: what is a *fundamental*, *universal* constant?
You see, those constants establish our unit systems!
Many, really many among my friends don't hesitate to work in a frame where the speed of light is equal to 1. Yes, ONE, dimensionless. Then, passing from length to time is just a unit conversion, and all velocities are dimensionless. ... one should not forget that all that is *conventional*.
Right. So, from a programming perspective, the question is this:
which conventions are most useful?
If we treat angles as dimensionless, then the type system won't give us much
help in detecting errors when we have e.g. confused radians with degrees.
But this kind of error is a common programming error -- for example,
we (the Mercury team) made that mistake while writing our ICFP competition
entry this year, and from discussion with the Haskell team that came 3rd,
I think they did too, IIRC.
So from a programming perspective, I think it may be a good idea to
treat angles as a separate dimension. Note that you can still express
things like Taylor series expansions easily enough, you just have to
divide by the appropriate unit first.
Actually in the system proposed in this thread, I suppose the type system
does give you some help in detecting or avoiding those kinds of errors,
even if angles are not a separate unit, because in this system ordinary
numbers are not the same as dimensionless units, and so you have to insert
an explicit conversion to convert between numbers and dimensionless units,
and that gives you the opportunity to consider whether the right expression
to convert `angle' from a number to a Unit is `toUnit angle', `angle * radian',
or `angle * degree'. Still, the need to insert explicit `toUnits' is
annoying, and it would be nice to have a system where every number was
already a dimensionless unit. In that case, the argument for making
angles a separate dimension would be stronger.
--
Fergus Henderson
participants (2)
-
Fergus Henderson
-
Jerzy Karczmarczuk