Quantity

Quantity[magnitude,unit]

represents a quantity with size magnitude and unit specified by unit.

Quantity[unit]

assumes the magnitude of the specified unit to be 1.

Details

  • Quantity has attribute HoldRest and preserves the structure of unit.
  • The specified unit should be a string or operation of strings representing the Quantity expression's unit value.
  • 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.
  • Supported units include all those specified by NIST Special Publication 811.
  • 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 allclose all

Basic Examples  (4)

A Quantity represents a value associated with a specific unit:

Use to enter quantities and units:

Compound unit expressions can also be found using :

A unit can be a string or a product of strings:

Valid unit specifications include a number of physical constants:

Quantity will automatically attempt to interpret an unknown unit string:

Scope  (7)

Quantity expressions can be used in comparison functions:

Use MixedMagnitude and MixedUnit specifications to define a mixed Quantity:

Quantity expressions can be used in various list operations:

Many numerical functions also operate on Quantity expressions:

Integer functions also operate on Quantity expressions:

Normal will return the fundamental value for dimensionless Quantity expressions:

N may be used to numericize Quantity expressions:

N will not change the units associated with a Quantity expression, including physical constants:

UnitConvert can be used to find the SI value of physical constants:

Applications  (2)

Use FormulaData with Quantity objects to determine the escape velocity of the Earth and of the Sun:

Use FormulaData with Quantity objects to visualize the spectral radiance of a black body at temperature 5000 kelvins as a function of wavelength:

Properties & Relations  (12)

A unit can be given as a string or product of strings:

IndependentUnit specifications can also be used:

Units accept prefixes that are used to form decimal multiples and submultiples of units:

In its one-argument form, Quantity automatically sets the magnitude to 1:

The first argument of Quantity can also be a Quantity object, in which case units are multiplied:

Additions of Quantity objects with compatible units will heuristically determine the result units:

Products of Quantity objects with compatible units will heuristically determine the result units:

Quantity threads its unit specification over lists:

Canonical unit strings are always plural. Unit descriptions will accurately reflect the singular form of a unit:

Since Quantity is HoldRest, it can accept multiple unit strings of the same dimension:

When quantities are multiplied, the resulting unit is not automatically simplified:

Use UnitSimplify to get a simpler form of the unit:

Use UnitConvert to normalize mixed Quantity expressions to non-mixed Quantity expressions:

Possible Issues  (2)

Quantity automatically attempts to interpret unrecognized unit strings as canonical units:

Expressions composed of unrecognized unit strings cannot be interpreted in this way:

Instead, the unit should be specified as a single string:

Some units contain Interval expressions, which can result in comparisons returning unevaluated:

Wolfram Research (2012), Quantity, Wolfram Language function, https://reference.wolfram.com/language/ref/Quantity.html (updated 2019).

Text

Wolfram Research (2012), Quantity, Wolfram Language function, https://reference.wolfram.com/language/ref/Quantity.html (updated 2019).

BibTeX

@misc{reference.wolfram_2021_quantity, author="Wolfram Research", title="{Quantity}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/Quantity.html}", note=[Accessed: 31-July-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_quantity, organization={Wolfram Research}, title={Quantity}, year={2019}, url={https://reference.wolfram.com/language/ref/Quantity.html}, note=[Accessed: 31-July-2021 ]}

CMS

Wolfram Language. 2012. "Quantity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. 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