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 ...

[PNG of math notebook with problem](https://dl.dropboxusercontent.com/u/5614270/Eqn.png)

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.

  • $\begingroup$ 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? $\endgroup$
    – earnric
    Aug 20 '13 at 1:26
  • $\begingroup$ 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"] $\endgroup$
    – earnric
    Aug 20 '13 at 1:27
  • $\begingroup$ @belisarius, You are generally right, but he was though, indeed, Lord, but, nevertheless, Kelvin. And that is the great difference. $\endgroup$ Aug 20 '13 at 8:29
  • $\begingroup$ It would be nice to have code we can copy, paste, and test. $\endgroup$
    – Michael E2
    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

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))) 



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

everything is going to be ok.

  • $\begingroup$ That was EXACTLY the issue. I prob would have never found it on my own too... Thx, $\endgroup$
    – earnric
    Aug 21 '13 at 20:34
  • $\begingroup$ @earnric I'm glad it helped :) If something does not work try FullFrom try Crtl+Shift+E to know whats inside. Good luck :) $\endgroup$
    – Kuba
    Aug 21 '13 at 20:38
  • $\begingroup$ 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"]] $\endgroup$
    – Andrestand
    Dec 16 '15 at 9:56
  • $\begingroup$ @Andrestand because it is not supposed to work. Use Kelvin or KelvinsDifference. Kelvins sometimes will be translated, sometimes not, who knows. $\endgroup$
    – Kuba
    Dec 16 '15 at 10:02
  • 1
    $\begingroup$ @Andrestand my summary is not ok! I will fix that, thanks for pointing that out. $\endgroup$
    – 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 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 *)
  • $\begingroup$ 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 $\endgroup$
    – earnric
    Aug 20 '13 at 22:43
  • $\begingroup$ Here's a picture of the notebook: PNG of notebook $\endgroup$
    – earnric
    Aug 20 '13 at 23:14
  • $\begingroup$ @earnric Yes, that is what I suspected. But then, do it! It will be much easier, and it works. $\endgroup$ Aug 21 '13 at 7:08
  • 1
    $\begingroup$ 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! $\endgroup$
    – earnric
    Aug 21 '13 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.