I'm running into what looks like an error.

<< PhysicalConstants`;
fieldGradient = Quantity[10,  "Teslas"/"Meters"] (* Tesla/meter *)
Energy = Quantity[100, "MegaElectronVolts"]
K = fieldGradient*SpeedOfLight*ElectronCharge/Energy (* m^-2 *)

K should have the units of meters^-2, but Mathematica insists on the output:

(Coulomb Meter (Quantity[4.8032*10^-12, ("Teslas")/("Megaelectronvolts" "Meters")]))/Second

Am I using the Units wrong here? This is my first try at using the Units package in Mathematica 9.

  • $\begingroup$ Please define SpeedOfLight and ElectronCharge such that the example is self-contained. $\endgroup$
    – C. E.
    Commented Dec 19, 2014 at 22:01
  • $\begingroup$ Done, sorry, I forgot the PhysicalConstants package. $\endgroup$
    – webb
    Commented Dec 19, 2014 at 22:03

1 Answer 1


In v10, the PhysicalConstants package isn't required.


"10.0 for Mac OS X x86 (64-bit) (December 4, 2014)"

Use UnitConvert to put all units into SI units

fieldGradient = UnitConvert[Quantity[10, "Tesla/Meter"]];

Energy = UnitConvert[Quantity[100, "MegaElectronVolts"]];

K = fieldGradient*

Quantity[29.97925, 1/("Meters")^2]


fieldGradient = Quantity[10, "Tesla/Meter"];

Energy = Quantity[100, "MegaElectronVolts"];

K = fieldGradient*
    Energy // UnitConvert

Quantity[29.97925, 1/("Meters")^2]

  • $\begingroup$ So it won't convert across unit systems otherwise? $\endgroup$
    – webb
    Commented Dec 19, 2014 at 22:23
  • $\begingroup$ I assume that if you give it mixed units that it doesn't try to guess what unit system you want and leaves the units as is. Since you stated that you expect the output in 1/meters^2 then SI is presumably what you what. That is the default for UnitConvert. However, you could use //UnitConvert[#,"Imperial"]& and get the output in 1/Inches^2. $\endgroup$
    – Bob Hanlon
    Commented Dec 20, 2014 at 21:40

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.