---
title: "QuantityVariable"
language: "en"
type: "Symbol"
summary: "QuantityVariable[var,  pq] represents a variable with the label var and the corresponding physical quantity  pq. QuantityVariable[pq] represents the unlabeled physical quantity  pq."
keywords: 
- DimensionalVariable
- Quantity
- FormulaVariable
canonical_url: "https://reference.wolfram.com/language/ref/QuantityVariable.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Units & Quantities"
    link: "https://reference.wolfram.com/language/guide/Units.en.md"
  - 
    title: "Formulas"
    link: "https://reference.wolfram.com/language/guide/Formulas.en.md"
  - 
    title: "Scientific Models"
    link: "https://reference.wolfram.com/language/guide/ScientificModels.en.md"
  - 
    title: "Scientific Data Analysis"
    link: "https://reference.wolfram.com/language/guide/ScientificDataAnalysis.en.md"
related_functions: 
  - 
    title: "QuantityVariableIdentifier"
    link: "https://reference.wolfram.com/language/ref/QuantityVariableIdentifier.en.md"
  - 
    title: "QuantityVariablePhysicalQuantity"
    link: "https://reference.wolfram.com/language/ref/QuantityVariablePhysicalQuantity.en.md"
  - 
    title: "QuantityVariableDimensions"
    link: "https://reference.wolfram.com/language/ref/QuantityVariableDimensions.en.md"
  - 
    title: "QuantityVariableCanonicalUnit"
    link: "https://reference.wolfram.com/language/ref/QuantityVariableCanonicalUnit.en.md"
  - 
    title: "FormulaData"
    link: "https://reference.wolfram.com/language/ref/FormulaData.en.md"
  - 
    title: "IndependentPhysicalQuantity"
    link: "https://reference.wolfram.com/language/ref/IndependentPhysicalQuantity.en.md"
---
# QuantityVariable

QuantityVariable[var, "pq"] represents a variable with the label var and the corresponding physical quantity "pq".

QuantityVariable["pq"] represents the unlabeled physical quantity "pq".

## Details

* Supported physical quantities include both physical and chemical quantities such as ``"Length"``, ``"ElectricCurrent"``, and ``"ChemicalPotential"``, as well as mathematical and financial quantities such as ``"Angle"`` and ``"Money"``.

* Combinations of physical quantities are also supported, as well as ``"PhysicalQuantity"`` entities.

* ``pq`` can also be specified using a list of ordered dimension pairs (such as returned by ``QuantityVariableDimensions``), indicating the magnitude of the ``pq`` in that dimension.

* ``Information`` of a ``QuantityVariable`` may include the following properties:

|                    |                                              |
| ------------------ | -------------------------------------------- |
| "Identifier"       | identifier associated with quantity variable |
| "PhysicalQuantity" | physical quantity                            |
| "UnitDimensions"   | physical dimensions                          |
| "CanonicalUnit"    | canonical units                              |

## Examples (12)

### Basic Examples (2)

A ``QuantityVariable`` represents a variable associated with a particular physical quantity:

```wl
In[1]:= QuantityVariable["V", "ElectricPotential"]

Out[1]= V
```

---

``QuantityVariable`` can be used to specify values in ``FormulaData`` :

```wl
In[1]:= FormulaData["KineticEnergy", {QuantityVariable["K", "Energy"] -> Quantity[10, "Joules"], QuantityVariable["m", "Mass"] -> Quantity[10, "Grams"]}]

Out[1]= v == Quantity[-20 Sqrt[5], ("Meters"/"Seconds")] || v == Quantity[20 Sqrt[5], ("Meters"/"Seconds")]
```

### Scope (2)

``QuantityVariable`` objects can be constructed using free-form input (ctrl+=):

```wl
In[1]:= \[FreeformPrompt]["electrical potential"]

Out[1]= ElectricPotential
```

---

Create a ``QuantityVariable`` using a combination of physical quantities:

```wl
In[1]:= QuantityVariable["x", "Mass" * "Distance"]

Out[1]= x
```

Use a list of unit dimensions to set a physical quantity instead:

```wl
In[2]:= QuantityVariable["y", {{"LengthUnit", 2}, {"MassUnit", -1}}]

Out[2]= y
```

### Properties & Relations (8)

``QuantityVariableIdentifier`` can be used to extract the symbol from a ``QuantityVariable`` :

```wl
In[1]:= var = QuantityVariable["I", "Current"]

Out[1]= I

In[2]:= QuantityVariableIdentifier[var]

Out[2]= "I"
```

The physical quantity can be recovered with ``QuantityVariablePhysicalQuantity`` :

```wl
In[3]:= QuantityVariablePhysicalQuantity[var]

Out[3]= "Current"
```

---

``FormulaData`` returns ``QuantityVariable`` objects:

```wl
In[1]:= InputForm[FormulaData["OhmsLaw"]]
```

Out[1]=
QuantityVariable["V", "ElectricPotential"] == 
 QuantityVariable["I", "ElectricCurrent"]\*QuantityVariable["R", 
   "ElectricResistance"]

---

The physical quantities used within ``QuantityVariable`` can be used to search for formulas using ``FormulaLookup`` :

```wl
In[1]:= FormulaLookup[All, 5, RequiredPhysicalQuantities -> {"Volume", "Mass", "Speed"}]

Out[1]= {{"MeanFreePath", "Volume", "Diameter"}, {"MeanFreePath", "Volume", "Radius"}}
```

---

Any symbol can be used with any physical quantity without restriction:

```wl
In[1]:= QuantityVariable["I", "ElectricPotential"]

Out[1]= I
```

---

``QuantityVariable`` can be used in symbolic results:

```wl
In[1]:= EntityValue[\[FreeformPrompt]["pendulum system"], "Lagrangian"]

Out[1]= Cos[θ[t]] g l m + (1/2) l^2 m Derivative[1][θ][t]^2

In[2]:= EntityValue[\[FreeformPrompt]["pendulum system"], "Lagrangian"]//InputForm
```

Out[2]//InputForm=
Cos[QuantityVariable["θ", "Angle"][QuantityVariable["t", "Time"]]]\*
  QuantityVariable["g", "GravitationalAcceleration"]\*QuantityVariable["l", "Length"]\*
  QuantityVariable["m", "Mass"] + (QuantityVariable["l", "Length"]^2\*QuantityVariable["m", "Mass"]\*
   Derivative[1][QuantityVariable["θ", "Angle"]][QuantityVariable["t", "Time"]]^2)/2

---

Use ``QuantityVariable`` in functions such as ``DSolve`` :

```wl
In[1]:= DSolve[{Derivative[1][x][t] == Quantity[5, ("Meters"/"Seconds")]}, x[t], t]

Out[1]= {{x[t] -> C[1] + (Quantity[5, "Meters"/"Seconds"]) t}}

In[2]:= DSolveValue[{Derivative[2][x][t] == Quantity[5, ("Meters"/"Seconds"^2)], x[Quantity[0, "Seconds"]] == Quantity[3, "Meters"], Derivative[1][x][Quantity[0, "Seconds"]] == Quantity[7, ("Meters"/"Seconds")]}, x[t], t]

Out[2]= Quantity[3, "Meters"] + (Quantity[7, ("Meters"/"Seconds")]) t + (Quantity[(5/2), ("Meters"/"Seconds"^2)]) t^2
```

---

``"PhysicalQuantity"`` entities can be used as arguments for ``QuantityVariable`` :

```wl
In[1]:= QuantityVariable["x", Entity["PhysicalQuantity", "Length"]]

Out[1]= x
```

---

Use the ``ResourceFunction`` ``"PhysicalQuantityLookup"`` to find physical quantities and quantity variables from units and quantities:

```wl
In[1]:= ResourceFunction["PhysicalQuantityLookup"]["Kilograms", "QuantityVariable"]

Out[1]= {B, m, Δ, μ, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, Subscript[m, 0], Subscript[M, J], m^ * , {}, Biomass, FabricMass, FoodMass, m, {}, {}, {}, {}, {}, {}, {}, {}, Subscript[m, a]}

In[2]:= ResourceFunction["PhysicalQuantityLookup"][Quantity[2, "Miles" / "Hours" ^ 2], "Entity"]

Out[2]= {Entity["PhysicalQuantity", "Acceleration"], Entity["PhysicalQuantity", "CentrifugalAcceleration"], Entity["PhysicalQuantity", "CentripetalAcceleration"], Entity["PhysicalQuantity", "CoriolisAcceleration"], Entity["PhysicalQuantity", "CoriolisDecel ... onalFieldStrength"], Entity["PhysicalQuantity", "SpecificForce"], Entity["PhysicalQuantity", "PiezoelectricAccelerometerStrainSensitivity"], Entity["PhysicalQuantity", "SoundParticleAcceleration"], Entity["PhysicalQuantity", "TransportationCost"]}
```

## See Also

* [`QuantityVariableIdentifier`](https://reference.wolfram.com/language/ref/QuantityVariableIdentifier.en.md)
* [`QuantityVariablePhysicalQuantity`](https://reference.wolfram.com/language/ref/QuantityVariablePhysicalQuantity.en.md)
* [`QuantityVariableDimensions`](https://reference.wolfram.com/language/ref/QuantityVariableDimensions.en.md)
* [`QuantityVariableCanonicalUnit`](https://reference.wolfram.com/language/ref/QuantityVariableCanonicalUnit.en.md)
* [`FormulaData`](https://reference.wolfram.com/language/ref/FormulaData.en.md)
* [`IndependentPhysicalQuantity`](https://reference.wolfram.com/language/ref/IndependentPhysicalQuantity.en.md)

## Related Guides

* [Units & Quantities](https://reference.wolfram.com/language/guide/Units.en.md)
* [`Formulas`](https://reference.wolfram.com/language/guide/Formulas.en.md)
* [Scientific Models](https://reference.wolfram.com/language/guide/ScientificModels.en.md)
* [Scientific Data Analysis](https://reference.wolfram.com/language/guide/ScientificDataAnalysis.en.md)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) \| [Updated in 2017 (11.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn112.en.md) ▪ [2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)