Why doesn't Mathematica divide out the Kelvins?

I thought I understood Mathematica V9 units. However, I can't get these numbers to plot, or even to come out to a nice clean unit of mass (say grams). The Kelvin's always stick around: even though they should cancel.

Note that the UnitConvert with "gram" does work at all... But "Convert to SI unit" seems to get me close with "kg K^(3/2)/K^(3/2)". Same for UnitSimplify ... Why doesn't Mathematica divide out the Kelvins? Is this somehting to do with the Kelvin vs KelvinDifference unit thing? I can't seem to find the right way to do this. I just want to plot grams...

This is the Jean's mass eqn from Astrophysics.. I would have included a picture of the notebook, but this thing won't let me link/embed pictures.

• I've figured out that if I use an 'Evaluate' on my equation (that has units of kg K^3/2 / K^3/2) that it will plot. I don't understand what the evaluate does in this context? Aug 20 '13 at 1:26
• ContourPlot[ Evaluate[[ScriptCapitalM][Quantity[t, "Kelvin"], Quantity[10^-27, "g"], Quantity[p, "g"]/Quantity["cm"]^3]], {t, 1., 100}, {p, 10^-2, 10}, LabelStyle -> {FontFamily -> "Helvetica", FontSize -> 15}, FrameLabel -> {"Temp", "[Rho]"}, PlotLegends -> "Expressions"] Aug 20 '13 at 1:27
• @belisarius, You are generally right, but he was though, indeed, Lord, but, nevertheless, Kelvin. And that is the great difference. Aug 20 '13 at 8:29
• It would be nice to have code we can copy, paste, and test. Aug 21 '13 at 12:18

It looks like a typo.

Reffering to the code you showed in comments, you are calculating mass for given parameters, one of them is temperature:

M[ Quantity[100, "Kelvin"], ...

but in fact it is not what you thought:

Quantity[100, "Kelvin"] // QuantityUnit
"KelvinsDifference"

so the resulting value is correct:

value kg K^(3/2)/K^(3/2)

only K!=K :) and it is:

((("KelvinsDifference")^(3/2) "Kilograms")/(("Kelvins")^(3/2)))

summary:

With

M[ Quantity[100, "Kelvins"], ...

everything is going to be ok.

• That was EXACTLY the issue. I prob would have never found it on my own too... Thx, Aug 21 '13 at 20:34
• @earnric I'm glad it helped :) If something does not work try FullFrom try Crtl+Shift+E to know whats inside. Good luck :)
– Kuba
Aug 21 '13 at 20:38
• Why "Kelvins" doesn't work?: FullForm[Quantity[1, "Faraday/Kelvins"]*Quantity[1, "Kelvins"]] FullForm[Quantity[1, "m/Kelvins"]*Quantity[1, "Kelvins"]] FullForm[Quantity[1, "m 1/Kelvins"]*Quantity[1, "Kelvins"]] Dec 16 '15 at 9:56
• @Andrestand because it is not supposed to work. Use Kelvin or KelvinsDifference. Kelvins sometimes will be translated, sometimes not, who knows.
– Kuba
Dec 16 '15 at 10:02
• @Andrestand my summary is not ok! I will fix that, thanks for pointing that out.
– Kuba
Dec 16 '15 at 15:55

It works for me. That is your expression I copied from your question:

kg K^(3/2)/K^(3/2)

(*   kg *)

However, if it does not, or it does not work in a more complex expression, it may be for one of two reasons. 1. the Latin K is reserved in Mathematica:

?K
K is a default generic name for a summation index in a symbolic sum.

2. In some cases, you get it, if your units are defined as positive.

The work around: 1. Just not to get into any conflict you might like to use the Greek capital kappa Esc+K+Esc instead of the Latin K. Its appearance is almost indistinguishable of the Latin K. I, personally, simply type grad instead of K.

1. You may apply Simplify to the expression with the following assumption:

assumption = {kg > 0, [CapitalKappa] > 0};

Simplify[kg \[CapitalKappa]^(3/2)/\[CapitalKappa]^(3/2), assumption]
(* kg *)

It is even more convenient to define it once for the whole session and use then as follows:

\$Assumptions = {kg > 0, \[CapitalKappa] > 0};
kg \[CapitalKappa]^(3/2)/\[CapitalKappa]^(3/2) // Simplify

(* kg *)
• I actually didn't type the "K" (for Kelvin) in... I used it as part of a Quantity statement: Quantity[100, "Kelvin"]. I then formed that into a larger equation in which all the units SHOULD cancel out except for a unit of mass (kg or g). HOWEVER, Even when I use UnitConvert or UnitSimplify I end up with mass times K^(3/2) / K^(3/2). VERY FRUSTRAITING. Why don't the kelvins just cancel out? @AlexeiBoulbitch Aug 20 '13 at 22:43
• Here's a picture of the notebook: PNG of notebook Aug 20 '13 at 23:14
• @earnric Yes, that is what I suspected. But then, do it! It will be much easier, and it works. Aug 21 '13 at 7:08
• Actually it was a unit specification errors! I used "Kelvin" instead of "Kelvins" ... That made the units divide out as expected. Note that "Kelvin" translates to "KelvinDifference" !!! Who would think to check that! Aug 21 '13 at 20:36