- See Also
-
Related Guides
- Financial Computation
- Units & Quantities
- Scientific Data Analysis
- Engineering Data
- Physics & Chemistry: Data and Computation
- Astronomical Computation & Data
- Maps & Cartography
- WDF (Wolfram Data Framework)
- Probability & Statistics with Quantities
- Scientific Models
- Database Connectivity
- Numbers with Uncertainty
- Angles and Polar Coordinates
- Knowledge Representation & Access
- Workflows
- Tech Notes
-
- See Also
-
Related Guides
- Financial Computation
- Units & Quantities
- Scientific Data Analysis
- Engineering Data
- Physics & Chemistry: Data and Computation
- Astronomical Computation & Data
- Maps & Cartography
- WDF (Wolfram Data Framework)
- Probability & Statistics with Quantities
- Scientific Models
- Database Connectivity
- Numbers with Uncertainty
- Angles and Polar Coordinates
- Knowledge Representation & Access
- Workflows
- Tech Notes
Quantity
Details
- In Quantity[m,u], the unit u can be given as a string, such as "Meters", or a product of powers of units, such as "Meters"/"Seconds"^2.
- Supported units include all those specified by NIST Special Publication 811.
- Quantity expresses temperatures using units such as "DegreesCelsius" and temperature differences using units such as "DegreesCelsiusDifference". Quantity arithmetic operations systematically distinguish this.
- Quantity operations systematically distinguish temperatures, expressed using units such as "DegreesCelsius", from temperature differences, expressed using units such as "DegreesCelsiusDifference".
- Quantity[unit] will produce a canonicalized Quantity with a magnitude of 1.
- Quantity expressions can be created by using the
free-form linguistics interface. - Quantity will automatically attempt to parse an unknown unit string to its canonical form.
- Quantity has attribute HoldRest and preserves the structure of unit.
- For purely numeric units, such as percents, Normal[expr] converts a Quantity object to an ordinary number.
- Information of a Quantity may include the following properties:
-
"Magnitude" quantity magnitude "Unit" unit associated with the quantity "UnitDimensions" physical dimensions of unit "SIBaseUnits" SI base units
Examples
open all close allBasic Examples (4)
A Quantity represents a value associated with a specific unit:
Quantity[8, "Meters"]Use
to enter quantities and units:
["30 kilograms"]Compound unit expressions can also be found using
:
["40 pascals/farad"]A unit can be a string or a product of strings:
Quantity[1, "Feet"]Quantity[1.84, ("Meters" * "Pascals") / "Farads"]Valid unit specifications include a number of physical constants:
Quantity[1, "SpeedOfLight"]["Newtonian gravitational constant"]3 ["magnetic constant"]Quantity will automatically attempt to interpret an unknown unit string:
Quantity[1, "foot"]Quantity[19, "fps"]%//InputFormScope (7)
Quantity expressions can be used in comparison functions:
["3 feet"] < ["1.1 meter"]Quantity[16, "Ounces"] == Quantity[1, "Pounds"]Select[Range[["10 feet"]], Quantity[1, "Meters"] < # < Quantity[2, "Meters"]&]Use MixedMagnitude and MixedUnit specifications to define a mixed Quantity:
Quantity[MixedMagnitude[{5, 10}],
MixedUnit[{"Feet", "Inches"}]]Quantity[MixedMagnitude[{4, 7, 30}],
MixedUnit[{"Days", "Hours", "Minutes"}]]Quantity expressions can be used in various list operations:
Range[["10 Feet"]]Table[i, {i, Quantity[3, "Ounces"], Quantity[1, "Pounds"]}]Table[i, {i, Quantity[5, "Seconds"], Quantity[1, "Minutes"], Quantity[4, "Seconds"]}]Ordering[{Quantity[3, "Feet"], Quantity[9, "Inches"], Quantity[1, "Meters"]}]Many numerical functions also operate on Quantity expressions:
Abs[["-3 amps"]]Round[Quantity[3.5, "Feet"]]Round[Quantity[3.6, "Feet"], Quantity[3, "Inches"]]Rationalize[Quantity[14.2, "Inches"]]Rationalize[Quantity[14.2, "Inches"], Quantity[1 / 10, "Meters"]]Rescale[Quantity[1.8, "Meters"], {Quantity[-10, "Meters"], Quantity[10, "Meters"]}]Integer functions also operate on Quantity expressions:
Divisible[["8 ft"], Quantity[2, "Inches"]]Mod[Quantity[8, "Feet"], Quantity[3, "Feet"]]Re[Quantity[9. + 3.I, "Feet"]]Im[Quantity[9. + 3.I, "Feet"]]Norm[Quantity[-2 + I, "Pounds"]]Normal will return the fundamental value for dimensionless Quantity expressions:
Normal[Quantity[10, "Percent"]]UnitDimensions["PartsPerMillion"]Normal[Quantity[8, "PartsPerMillion"]]N may be used to numericize Quantity expressions:
N[Quantity[3 / 8, "Feet"]]N will not change the units associated with a Quantity expression, including physical constants:
N[Quantity[1, "GravitationalConstant"], 20]UnitConvert can be used to find the SI value of physical constants:
UnitConvert[%]Applications (2)
Use FormulaData with Quantity objects to determine the escape velocity of the Earth and of the Sun:
FormulaData["EscapeVelocity", {"m" -> Quantity[1, "EarthMass"], "r" -> Quantity[1, "EarthMeanRadius"]}]FormulaData["EscapeVelocity", {"m" -> Quantity[1, "SolarMass"], "r" -> Quantity[1, "SolarRadius"]}]Use FormulaData with Quantity objects to visualize the spectral radiance of a black body at temperature 5000 kelvins as a function of wavelength:
equation = FormulaData[{"PlanckRadiationLaw", "Wavelength"},
{"T" -> Quantity[5000, "Kelvins"], "λ" -> Quantity[wl, "Micrometers"]}
][[2, 2]];Plot[equation, {wl, 0.1, 5}, AxesLabel -> {"Wavelength [μm]", "Spectral radiance [W SuperscriptBox[sr, -1]SuperscriptBox[m, -3]]"}]Properties & Relations (15)
A unit can be given as a string or product of strings:
Quantity[1, "Yards"]Quantity[1.7, "Newtons" * "Meters" / "Seconds"]Quantity[1.7, "Kilograms" * "Meters" ^ 2 / "Seconds" ^ 2]IndependentUnit specifications can also be used:
Quantity[7, IndependentUnit["myUnit"]]Quantity[3, IndependentUnit["myUnit1"] / IndependentUnit["myUnit2"] ^ 2]Units accept prefixes that are used to form decimal multiples and submultiples of units:
Quantity[1.7, "Decigrams"]Quantity[3.9, "Megaparsecs"]In its one-argument form, Quantity automatically sets the magnitude to 1:
Quantity["Candelas"]Quantity["Moles"]The first argument of Quantity can also be a Quantity object, in which case units are multiplied:
Quantity[Quantity[4, "Meters"], "Seconds" ^ (-1)]Quantity[Quantity[4, "Radians"], IndependentUnit["myUnit"]]Additions of Quantity objects with compatible units will heuristically determine the result units:
qa = Quantity[1, "Teslas"];
qb = Quantity[100, "Gauss"];
CompatibleUnitQ[qa, qb]qa + qbProducts of Quantity objects with compatible units will heuristically determine the result units:
qa = Quantity[1, "Kilometers"];
qb = Quantity[3000, "Meters"];
CompatibleUnitQ[qa, qb]qa * qbSubtraction of temperatures in non-absolute scales like Celsius or Fahrenheit produces temperature differences:
temp1 = Quantity[20, "DegreesCelsius"];
temp2 = Quantity[15, "DegreesCelsius"];diff = temp1 - temp2diff//InputFormAddition of a temperature and a temperature difference gives another temperature:
temp2 + diff%//InputFormOperations involving products and divisions of temperatures may convert automatically to kelvins:
temp = Quantity[0, "DegreesFahrenheit"]1 / tempThis result is equivalent to converting the temperature in advance:
1 / UnitConvert[temp, "Kelvins"]Quantity threads its unit specification over lists:
Quantity[{1, 2, 3, {4, 5, {6}}}, "Hertz"]Canonical unit strings are always plural. Unit descriptions will accurately reflect the singular form of a unit:
Quantity[1, "Foot"]%//InputFormQuantity[1, "Foot"]//ToStringSince Quantity is HoldRest, it can accept multiple unit strings of the same dimension:
Quantity[3.5, "Feet" / "Meters"]Quantity[12, "Meters" / "Meters"]When quantities are multiplied, the resulting unit is not automatically simplified:
qa = Quantity[1, "Newtons"];
qb = Quantity[10, "Meters"];
qa * qbUse UnitSimplify to get a simpler form of the unit:
UnitSimplify[%]Use UnitConvert to normalize mixed Quantity expressions to non-mixed Quantity expressions:
q = Quantity[MixedMagnitude[{6, 3, 17, 45}], MixedUnit[{"Weeks", "Days", "Hours", "Minutes"}]]UnitConvert[q]UnitConvert[q, "Minutes"]Use QuantityArray to describe rectangular arrays of Quantity objects of common units:
qa = QuantityArray[{{1, 2}, {3, 4}, {5, 6}}, {"Meters", "Meters" / "Seconds"}]Normal converts the structured array into an equivalent normal array of Quantity objects:
Normal[qa]% == qaPossible Issues (2)
Quantity automatically attempts to interpret unrecognized unit strings as canonical units:
Quantity[1, "ft"]Quantity[1, "s"]Expressions composed of unrecognized unit strings cannot be interpreted in this way:
Quantity[1, "ft" / "s"]Instead, the unit should be specified as a single string:
Quantity[1, "ft/s"]Some units contain Interval expressions, which can result in comparisons returning unevaluated:
UnitConvert[Quantity[1, "AcademicTrimesters"], "Days"]Quantity[10, "Weeks"] > Quantity[1, "AcademicTrimesters"]Quantity[1, "AcademicTrimesters"] / Quantity[10, "Weeks"]See Also
QuantityArray QuantityUnit QuantityMagnitude UnitConvert CompatibleUnitQ QuantityQ MixedMagnitude MixedUnit QuantityDistribution EntityCopies QuantityVariable QuantityForm Around ChemicalInstance RulerUnits
Entity Types: PhysicalQuantity
Interpreter Types: Quantity
Menu Items: Inline Free-form Input
Tech Notes
Related Guides
-
▪
- Financial Computation ▪
- Units & Quantities ▪
- Scientific Data Analysis ▪
- Engineering Data ▪
- Physics & Chemistry: Data and Computation ▪
- Astronomical Computation & Data ▪
- Maps & Cartography ▪
- WDF (Wolfram Data Framework) ▪
- Probability & Statistics with Quantities ▪
- Scientific Models ▪
- Database Connectivity ▪
- Numbers with Uncertainty ▪
- Angles and Polar Coordinates ▪
- Knowledge Representation & Access
Related Workflows
- Calculate with Units ▪
- Enter Quantities with Units
Related Links
History
Introduced in 2012 (9.0) | Updated in 2014 (10.0) ▪ 2019 (12.0) ▪ 2022 (13.2)
Text
Wolfram Research (2012), Quantity, Wolfram Language function, https://reference.wolfram.com/language/ref/Quantity.html (updated 2022).
CMS
Wolfram Language. 2012. "Quantity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/Quantity.html.
APA
Wolfram Language. (2012). Quantity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Quantity.html
BibTeX
@misc{reference.wolfram_2026_quantity, author="Wolfram Research", title="{Quantity}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Quantity.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_quantity, organization={Wolfram Research}, title={Quantity}, year={2022}, url={https://reference.wolfram.com/language/ref/Quantity.html}, note=[Accessed: 13-June-2026]}