I've been playing a lot with new Mathematica 9 units support. It is very useful and so on...

But I've gone into one trouble. Initially I had a problem with plotting functions with some units.

The detailed story is

here.

In short:

Plot[Evaluate@UnitConvert[e Quantity[0.001, "Meters"^3], "L"], {e, 0, 1}]

doesn't work.

But these two variants work well:

Plot[Evaluate@UnitConvert[Quantity[0.001 e, "Meters"^3], "L"], {e, 0, 1}]

Plot[Evaluate@UnitConvert[Quantity[e, "m/m"] Quantity[0.001, "Meters"^3], "L"], {e, 0, 1}]

(By the way, does anybody know if Plot officially support units? In documentation and tutorials there are List*Plot functions everywhere, but nothing is said about Plot. Empirical investigation shows that "it supports, but not very much".)

The behavior of Plot function is interesting, but it isn't the most.

The most interesting thing is the fact that Mathematica lacks support of dimensionless symbolical expressions. Everything that is not numerical is "of unknown dimension".

I'll try to illustrate.

Numbers are dimensionless

In[]:= QuantityUnit[1]

Out[]= "DimensionlessUnit"

Meters are meters

In[]:= QuantityUnit[Quantity[1, "m"]]

Out[]= "Meters"

Unknown values are unknown

In[]:= Clear[a]

In[]:= QuantityUnit[a]

Out[]= QuantityUnit[a]

And everything seems OK so far.

But let's try to make something more dimensionless

In[]:= QuantityUnit[Quantity[1, "m"]/Quantity[1, "m"]]

Out[]= "DimensionlessUnit"

OK!

In[]:= QuantityUnit[Quantity[a, "m"]/Quantity[1, "m"]]

Out[]= QuantityUnit[a]

Oops. This should be a dimensionless "a"! But it's not dimensionless now, It's of unknown dimension.

Trying to force

In[]:= QuantityUnit@Quantity[a, "DimensionlessUnit"]

Out[]= QuantityUnit[a]

Failure again. "Quantity" was evaluated, but it was rendered to nothing.

This may seem correct from some point of view, but it is not.

This weak distinguishing leads to "strange" problems, like with plot, as it was shown earlier.

Stronger distinguishing would make dimensional analysis much more strict. No more problems with guessing if some value is really dimensionless, or I've just forgot to substitute some variable...

And more.

For dessert is the really ugly thing, that arises from the same origin:

In[]:= Quantity[Quantity[1, "m"], "m"]

Out[]= Quantity[1, ("Meters")^2]"

In real life... According to physics... According to common sense! "one meter of meters" is nonsense. This should rise an error. No way it can be a square meter. It's impossible.

I always held in high respect the Wolfram stuff for their ability to make complex things simple without making them incorrect. But it seems like sometimes they make mistakes too. Or may be there is a good reason for this behavior? (except "it was easier to implement it this way")

I think that adding a strict distinction between dimensionless values and values with unknown dimension will make Mathematica more strict, logical, correct and robust. And what do you think?