7
$\begingroup$

Is there a straightforward way to write an inverse of UnitDimensions to get the SI unit from dimensions?

For example,

inverseUnitDimensions[{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]

should return "Newtons".

$\endgroup$
1
  • $\begingroup$ Slightly off-topic: Here's an automatic "unit simplifier" solution: mathematica.stackexchange.com/a/211950/26598: unitSimplify[Quantity[1, "Meters" "Kilograms"/"Seconds"^2], Join[SIbase, SIderived]] returns {Quantity[1, "Newtons"]} as desired. $\endgroup$
    – Roman
    Commented Jul 23 at 9:23

2 Answers 2

8
$\begingroup$

You can use QuantityVariableCanonicalUnit:

QuantityVariableCanonicalUnit[QuantityVariable[
  {{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]]
(* ("Kilograms" "Meters")/("Seconds")^2 *)

Now you need a combination of UnitSimplify and UnitConvert:

QuantityUnit[UnitConvert[UnitSimplify[Quantity[1, %]], "SI"]]
(* "Newtons" *)
$\endgroup$
1
  • $\begingroup$ Thanks. That's just what I hoped for. I wish Wolfram documentation would make better use of "See Also." The first time I saw QuantityVariableCanonicalUnit[] was in your answer. $\endgroup$
    – crabtree
    Commented Jul 22 at 17:34
1
$\begingroup$

Using answer from Domen:

In[16]
si[dimensions_]:=
 UnitSimplify[
  UnitConvert[
   QuantityVariableCanonicalUnit[
    QuantityVariable[dimensions]],
   "SI"]]

si[{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]
si[{{"ElectricCurrentUnit", 1}, {"TimeUnit", 1}}]

Out[17]= Quantity[1, "Newtons"]

Out[18]= Quantity[1, "Coulombs"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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