I am having some difficulties when using UnitSimplify
in manipulating expressions for obtaining dimensionless quantities in Mathematica 12.0.0. Here is a minimal example showing the difficulty:
UnitSimplify[
Quantity[10, "Joules"^(-1)]
(Quantity[20, "Joules"] r^2 +
Quantity[30, "Gigapascals" ("Picometers")^(3/2)] Sqrt[d^2 Quantity[40, "Liters"] +
f^2 Quantity[50, "Liters"]])]
The UnitSimplify
appears to do nothing above. To solve this difficulty, I have worked out the unit conversion factor for turning "Gigapascals" ("Picometers")^(3/2)
into "Joules"^(1) "Liters"^(-1/2)
. Then I applied a rule.
% /. Quantity[x_, "Gigapascals" ("Picometers")^(3/2)] ->
UnitConvert[
Quantity[x, "Gigapascals" ("Picometers")^(3/2)],
"Joules"^(1) "Liters"^(-1/2)]
Now that I can see that the units cancel, I can just take the magnitudes and find the dimensionless expression.
My question is: can this replacement rule be made more general to avoid working out unit conversion factors every time I come up with a dimensionless expression?