I don’t really see this as a problem. It seems reasonable to me as the most “free from assumptions” answer Mathematica could give. You seem to be making an assumption about what is “obvious”, but your assumption leads to equally nonsense situations. For example, what should 2*tempCelsius be? Should it be 360 C or 633.15 C? We could, I suppose, simply declare that all arithmetic with Celsius quanitities is nonsense, but then you shouldn’t be computing tempCelsius/tempKelvins in the first place. Or, to put it another way, what should we expect the expression tempCelsius/tempKelvins to mean? What are the semantics of that? It’s clear what your specific assumption is, but how can you justify that as some absolute rule that must always pertain?
For example, what should 2*tempCelsius be? Should it be 360 C or 633.15 C?
Yes, thats a good point. I would say it should be (2*180) °C - because I guess nobody expects a physical interpretation of “°C” here. And the unit of the result is simply the product of “1” and “°C”.
But in my example the units “°C” and “K” had simply canceled out - and this cannot be! In this case I would at least expect
a clear rule in the documentation saying e.g. that everything is converted into SI-units before operations (or cancelations!) are done
or those expressions simply stay unevalueated
I mean if I work e.g. with the very frequent expression k_B T and using units, I get:
And this is just a (dangerous!) nonsense! Why should anyone bother using units if those things are not working reliably? If I always first have to make sure that the units of all values are consistent, I do not need units at all!
Again, I see no problem here. You haven’t provided any context that would tell us what you expect kB Quantity[0., "DegreesCelsius"] to mean. Maybe we were looking at something that involved the difference of two temperatures, and when the two temperatures are the same, I would absolutely expect the result to be Quantity[0., “Joules”]`.
As for making sure that all values are consistent, well, we’re in a garbage-in-garbage-out situation here. The responsibility is totally on the human for specifying semantically meaningful inputs and for carefully interpreting the outputs. It’s not the computer’s job to tell you when you’re being nonsensical.
I could just as easily be exasperated by the fact that Mathematica reduces Sqrt[Quantity[-1, Power["Meters", 2]]] to Quantity[Complex[0, 1], "Meters"]. It is dangerous and unhelpful for Mathematica to tell me that the side length of my square is imaginary. If I have to make sure that my inputs make sense, then I don’t need units at all!
We can argue about personal preferences for what the language should do in the cases you’ve provided, but I’m not sure that’s a proper use of this forum. I think folks here would be happy to provide some heuristics or best practices for working with Quantity, if that’s what you want. Or if you need help setting up a model that uses Quantity, I’m sure someone here has the expertise. Or if you’d like to know how to write Mathematica code that does the checks that you want, we could show you how to do that.
interesting - good catch! But I guess this result is correct:
When the unit (here. "DegreesCelsius") has an arbitrary choice of zero, the outer sign must remain outside of Quantity[]. With "Kelvins" (no arbitrary choice of zero) this is different: