May I treat units (e.g. joules, grams, etc.) in equations as variables?

Suppose I have two units, Tonks, $T$, and Borks, $B$, as well as the equation $\frac{50T}{20B}=x$. May I manipulate the equation as though $T$ and $B$ were the kinds of symbols that we learned to manipulate in math class? For example:


\begin{align}
\frac{50T}{20B}&=x\\
50T&=20Bx\\
\frac{50T}{20}&=Bx\\
\end{align}




Yes, you may. It is quite common to convert units into each other. The simplest conversion might be the prefixing of units, e.g. 
$$\mathrm{\frac{km}{m}}=1000 \Longleftrightarrow \mathrm{1~km = 1000~m}.$$


Another example is the interconversion of units of energy. In some parts of chemistry, it is still quite common to use calories, in others Joule, as a SI unit, has taken its place.
$$\mathrm{\frac{cal}{J}}=4.184 \Longleftrightarrow \mathrm{1~cal = 4.184~J}.$$


In principle, all units are defined to be constants, special numbers in a wider sense. You can treat them as such.


 41

Treating units as if they were algebra is called “[dimensional analysis](http://www.chem.tamu.edu/class/fyp/mathrev/mr-da.html)”.


One example given in that article is the question of how many seconds are there in two years.


$$2\ \mathrm{yr} \times 365\ \mathrm{day}\ \mathrm{yr}^{-1} \times 24\ \mathrm{hr}\ \mathrm{day}^{-1} \times 60\ \mathrm{min}\ \mathrm{hr}^{-1} \times 60\ \mathrm{s}\ \mathrm{min}^{-1} = 63072000\ \mathrm{s} $$


Another example question is,



> 
> How many atoms of hydrogen can be found in 45 g of ammonia, $\ce{NH3}$?
> 
> 
> 


This is how I would approach this:


$$45\ \mathrm{g}\ \ce{NH3}\ /\ 17\ \mathrm{g}\ \mathrm{mol}^{-1} \approx 2.647\ \ce{NH3}\ \mathrm{mol}$$
$$2.647\ \ce{NH3}\ \mathrm{mol}\ \times\ 6.02 \times 10^{23}\ \mathrm{molecules}\ \mathrm{mol}^{-1} \approx 1.594 \times 10^{24}\ \ce{NH3}\ \mathrm{molecules}$$
$$1.594 \times 10^{24}\ \ce{NH3}\ \mathrm{molecules} \times 3\ \mathrm{(H\ atoms)}\ \mathrm{(\ce{NH3}\ molecules)}^{-1} \approx 4.781 \times 10^{24}\ \ce{H}\ \mathrm{atoms}$$


The article works this out differently, as a single step. I myself find the multi-step approach easier to follow, but everyone’s different. The article renders this as,



> 
> $$45\ \mathrm{g}\ \ce{NH3} \times \frac{1\ \mathrm{mol}\ \ce{NH3}}{17\ \mathrm{g}\ \ce{NH3}} \times \frac{6.02 \times 10^{23}\ \mathrm{molecules}\ \ce{NH3}}{1\ \mathrm{mol}\ \ce{NH3}} \times \frac{3\ \mathrm{atoms}\ \ce{H}}{1\ \mathrm{molecule}\ \ce{NH3}}$$
> 
> 
> $$ = 4.8 \times 10^{24}\ \mathrm{atoms}\ \ce{H}$$
> 
> 
> (to 2 significant figures)
> 
> 
> 


If the units cancel out correctly, that is further indication that you have the right formula. (And if they *don’t* cancel out correctly, that is a certain indication that you don’t have the right formula.)


 28

Not only may you, but you absolutely should. As a physics professor, watching students toss away the information contained in units is incredibly frustrating. Typically students drop the units, "do the math," and then put back on whatever final units they think should be there (if they bother with the last step at all). This leads to a shockingly large number of mistakes (even multi-million dollar ones: <http://www.cnn.com/TECH/space/9909/30/mars.metric/>)


Whenever you write a physical value you should write both the number and the unit and "do the math" on **both**, exactly as you propose. If the units don't work out to a unit that you expect then you know that you've done something wrong.


 27

You not only can, but also must treat symbols for units by the ordinary rules of algebra, since unit symbols are mathematical entities and not abbreviations.


The *value* of a *quantity* is expressed as the product of a number and a *unit*. That number is called the *numerical value* of the quantity expressed in this unit.


This relation may be expressed in the form


$$Q = \left\{ Q \right\} \cdot \left[ Q \right]$$


where $Q$ is the symbol for the quantity, $\left[ Q \right]$ is the symbol for the unit, and $\left\{ Q \right\}$ is the symbol for the numerical value of the quantity $Q$ expressed in the unit $\left[ Q \right]$.


For example, the mass of a sample is


$$m = 100\ \mathrm g$$


Here, $m$ is the symbol for the quantity mass, $\mathrm g$ is the symbol for the unit gram (a unit of mass), and $100$ is the numerical value of the mass expressed in grams. Thus, the value of the mass is $100\ \mathrm g$.


It is important to distinguish between the quantity $Q$ itself and the numerical value $\left\{ Q \right\}$ of the quantity expressed in a particular unit $\left[ Q \right]$. The value of a particular quantity $Q$ is independent of the choice of unit $\left[ Q \right]$, although the numerical value $\left\{ Q \right\}$ will be different for different units.


For example, changing the unit for the mass in the previous example from the gram to the kilogram, which is $10^3$ times the gram, leads to a numerical value which is $10^{-3}$ the numerical value of the mass expressed in grams, whereas the value of the mass stays the same.


$$m = 100\ \mathrm g = 0.100\ \mathrm{kg}$$


Since symbols for units are mathematical entities, both the numerical value and the unit may be treated by the ordinary rules of algebra. For example, the equation $m = 100\ \mathrm g$ may equally be written 
$$m/\mathrm g = 100$$


It is often convenient to label the axes of a graph in this way, so that the tick marks are labelled only with numbers. The quotient of a quantity and a unit may also be used in this way for the heading of a column in a table, so that the entries in the table are all simply numbers.


Performing the mathematical operations of quantities is called *quantity calculus*. Quantities are multiplied and divided by one another according to the rules of algebra, resulting in new quantities.


The quotient of two quantities, $Q\_1$ and $Q\_2$, satisfies the relation
$$\begin{align}
\frac{Q\_1}{Q\_2} &= \frac{ \left\{ Q\_1 \right\} \cdot \left[ Q\_1 \right] }{ \left\{ Q\_2 \right\} \cdot \left[ Q\_2 \right] } \\[6pt]
&= \frac{ \left\{ Q\_1 \right\} }{ \left\{ Q\_2 \right\} } \cdot \frac{ \left[ Q\_1 \right] }{ \left[ Q\_2 \right] }
\end{align}$$
Thus, the quotient $\left\{ Q\_1 \right\}/\left\{ Q\_2 \right\}$ is the numerical value $\left\{ Q\_1/Q\_2 \right\}$ of the quantity $Q\_1/Q\_2$, and the quotient $\left[ Q\_1 \right]/\left[ Q\_2 \right]$ is the unit $\left[ Q\_1/Q\_2 \right]$ of the quantity $Q\_1/Q\_2$.


For example, assuming a volume of $V = 0.127\ \mathrm{l}$, the density $\rho$ of the above-mentioned sample is
$$\begin{align}
\rho &= \frac{m}{V} \\[6pt]
&= \frac{ 0.100\ \mathrm{kg} }{ 0.127\ \mathrm{l} } \\[6pt]
&= \frac{ 0.100 }{ 0.127 } \cdot \frac{ \mathrm{kg} }{ \mathrm{l} } \\[6pt]
&= 0.79\ \mathrm{kg/l}
\end{align}$$


Similarly, the product of two quantities, $Q\_1$ and $Q\_2$, satisfies the relation
$$\begin{align}
Q\_1 \cdot Q\_2 &= \left( \left\{ Q\_1 \right\} \cdot \left[ Q\_1 \right] \right) \cdot \left( \left\{ Q\_2 \right\} \cdot \left[ Q\_2 \right] \right) \\[6pt]
&= \left\{ Q\_1 \right\}\left\{ Q\_2 \right\} \cdot \left[ Q\_1 \right] \left[ Q\_2 \right]
\end{align}$$


Thus, the product $\left\{ Q\_1 \right\}\left\{ Q\_2 \right\}$ is the numerical value $\left\{ Q\_1Q\_2 \right\}$ of the quantity $Q\_1Q\_2$, and the product $\left[ Q\_1 \right]\left[ Q\_2 \right]$ is the unit $\left[ Q\_1Q\_2 \right]$ of the quantity $Q\_1Q\_2$.


For example, considering the standard acceleration of free fall $g\_\mathrm n = 9.80665\ \mathrm{m/s^2}$, the weight $F\_\mathrm g$ of the above-mentioned sample is
$$\begin{align}
F\_\mathrm g &= m \cdot g\_\mathrm n \\[6pt]
&= 0.100\ \mathrm{kg} \times 9.80665\ \frac{\mathrm m}{\mathrm{s^2}} \\[6pt]
&= 0.100 \times 9.80665 \times \mathrm{kg} \cdot \frac{\mathrm m}{\mathrm{s^2}} \\[6pt]
&= 0.98\ \frac{\mathrm {kg\ m}}{\mathrm{s^2}} \\[6pt]
&= 0.98\ \mathrm{N}
\end{align}$$


In forming products and quotients of unit symbols, the normal rules of algebraic multiplication or division apply.


For example, the expansion work $W$ at constant pressure $p = 100\,000\ \mathrm{Pa} = 100\,000\ \mathrm{kg\ m^{-1}\ s^{-2}}$ associated with a volume change of $\Delta V = 0.5\ \mathrm{m^3}$ is


$$\begin{align}
W &= p \cdot \Delta V \\[6pt]
&= 100\,000\ \frac{\mathrm{kg}}{\mathrm{m\ s^{2}}} \times 0.5\ \mathrm{m^3}\\[6pt]
&= 50\,000\ \frac{\mathrm{kg}}{\mathrm{m\ s^{2}}}\cdot\mathrm{m^3}\\[6pt]
&= 50\,000\ \frac{\mathrm{kg\ m^2}}{\mathrm{s^{2}}}\\[6pt]
&= 50\,000\ \mathrm J
\end{align}$$


Two or more quantities cannot be added or subtracted unless they belong to the same kind. The expression shall be written as the sum or difference of expressions for the quantities
$$l=12\ \mathrm m-7\ \mathrm m$$
or parentheses shall be used to combine the numerical values, placing the common unit symbol after the complete numerical value
$$l=\left(12-7\right)\ \mathrm m$$
but it is not permissible to write
$$l=12-7\ \mathrm m\quad\color{red}{\small\text{(wrong!)}}$$
For the same reason, quantities on each side of an equal sign in an equation must be of the same kind
$$\begin{align}
m\_\text{total} &= m\_1+m\_2 \\
1.8\ \mathrm{kg} &= 1.5\ \mathrm{kg}+0.3\ \mathrm{kg}
\end{align}$$
However, quantities of the same kind do not necessarily have the same unit.
$$250\ \mathrm g = 0.250\ \mathrm{kg}$$
$$10\ \mathrm{m/s} = 36\ \mathrm{km/h}$$
Anyway, quantities on each side of an equal sign in an equation must not be of different kinds.


$$1\ \mathrm{mol} = 22.414\ \mathrm l\quad\color{red}{\small\text{(wrong!)}}$$ 


 18


> 
> May I manipulate the equation as though $T$ and $B$ were the kinds of symbols that we learned to manipulate in math class?
> 
> 
> 


Yes, you can and *should* (that is, never leave out the units when you plug values into an equation: a quantity is always the product of a numerical value and a unit, and leaving out units is [asking for disaster](http://mars.jpl.nasa.gov/msp98/news/mco990930.html)). The set of rules that govern the algebraic manipulation of quantities is known as *quantity calculus*.


Among the several references that can be found about quantity calculus and quantity equations (others can be found in [this answer](https://academia.stackexchange.com/a/28918/20058) on Academia.SE), I suggest you in particular [this guide, §7.11](http://physics.nist.gov/Pubs/SP811/sec07.html#7.11), and the following paper, which is geared toward chemists:


1. M J ten Hoor, "Quantity calculus for chemists", Chemistry in action n. 57, 1999. [Online](http://www.cerg.ul.ie/Chemistry%20in%20Action/Issue%2057.pdf)


However, units are not variables (we strongly believe that units should be immutable quantities: whether they are actually so is a matter of scientific investigation), and to highlight this fact it is recommended to use an upright typeface to typeset the units, instead of the italic typeface reserved to variable quantities. So your quantity equations would be better written as


$$\frac{50\,\mathrm{T}}{20\,\mathrm{B}} = x.$$


 12

Absolutely!
-----------


Having taught physics and planetary science for years now, this is how I've seen unit conversion taught most effectively. 


### Example


Suppose we wish to convert 423 feet to kilometers, where we know $3280.4 \; \text{ft} = 1 \; \text{km}$, or $\frac{1 \; \text{km} }{3280.4 \; \text{ft}} =1$:


$$\require{cancel} 423 \; \text{ft} = \left( 423 \; \text{ft} \right) \times 1 = \left( 423 \; \text{ft} \right) \times \left( \frac{1 \; \text{km} }{3280.4 \; \text{ft}} \right) = \frac{423 \; \text{ft} \; \text{km}}{3280.4 \; \text{ft}} = \frac{423}{3280.4} \frac{\cancel{\text{ft}} \; \text{km}}{\cancel{\text{ft}}} \approx 0.129 \; \text{km} $$


### There are a few catches, however...


**First, radians are a pseudo-unit.** Angular frequency ($\omega$) and regular frequency ($f$) are two closely related quantities: $\omega=2\pi f$, but they have different units. The units of angular frequency are radians per unit time (e.g. rad/sec), whereas the units of regular frequency are "per unit time" (e.g. [cycles, counts, etc.]/sec or Hz). Many scientists disregard radians as a unit and give angular and regular frequency the same units. This is acceptable, but you should be aware of the context, as an angular frequency of 20 Hz is not the same as an ordinary frequency of 20 Hz. 


**Second, some (particularly chemists) have an unfortunate tendency to be pretty loose with units in some situations**—especially when it comes to calculating equilibrium constants and dimensional laws. For example, it is not permitted for the argument of a natural logarithm or exponential to have units. Many people calculate $\ln(P) = ...$ (as for the Clausius-Clapeyron equation), while it *ought* to be something like $\ln(\frac{P}{P\_0}) = ...$, where $P\_0$ is a standard pressure scale used to scale all pressures in an equation. In most cases, this scale factor cancels out in the equation, but if you are keeping track of units, this is essential. Because this factor cancels out, calculations can usually be done correctly without thinking about it, and many chemists simply choose to ignore it or are even unaware of it (including some professors I've known!). Some old textbooks still do this, too, so this sloppiness is prevalent. **The bottom line is that understanding the context is important!**


**Third, this effectively only works for units that are directly proportional to each other.** One example of this not working is when converting between degrees Fahrenheit and degrees Celsius and Kelvins. The units can (and *should*) still be treated as variables, but because these unit systems are not directly proportional to each other, special care must be taken with them. The conversion formulae must be used.


 12