I few days ago I solved a problem on a website called brilliant.org, I can not seem to find the problem there anymore but I still remember it:

Q: You go to a candy store to buy m&ms and twizzlers, 1 pack of m&ms is 1 dollar, and one pack of twizzlers is 0.5 dollars. If you buy a total of 10 packs worth 6 dollars in total, how many packs of m&ms did you buy?

The solution is simple, you form a system of linear equations where x is the number of m&ms and y is the number of twizzlers.

$x + y = 10$

$ x + \frac{y}{2} = 6$

Solving by subtracting the second equation from the first we eventually get x = 2, so we bought two packs if m&ms. However, from my physics classes I have learnt that you can not add or subtract two number having different units. I have tried multiple times to make the units match but with no success. For example, in the first equation x stands for the number of packets of m&ms and in the second x packets are being multiplied by 1 dollar per packet , so when we do x - x, we are subtracting dollars from packets? Also when we do 10 - 6, isn't it also packets - dollars? For this reason, subtracting the equations doesn't seem to make sense to me, so why are we still able to do so?

  • $\begingroup$ When you write the equation, it is the numbers whose relation is represented. In order words, they are just plain numbers, no units $\endgroup$
    – Shailesh
    Aug 30, 2015 at 18:05
  • $\begingroup$ so if these equations do not have units when do they have? Because if I remember correctly back when I took physics all the equations we dealt with had units, even if they where not visible we were implicitly meant to assume they were there or the equations would not make sense $\endgroup$
    – fYre
    Aug 30, 2015 at 18:12
  • $\begingroup$ "If you buy a total of 10 packs" ... you've just added apples and oranges right off the bat, or more precisely, Twizzlers and M&Ms. $\endgroup$
    – John Joy
    Aug 30, 2015 at 18:20

3 Answers 3


In the first equation, $x+y=10$, the unit is "packs": $x$ packs plus $y$ packs equals $10$ packs. However, you can divide each side by "packs" and you end up with the unit "packs/packs," which we would call the "empty unit", i.e. no unit. The second equation has the unit "dollars," but again we divide both sides by "dollars" and end up with pure numbers without units.

So the equations involve pure numbers: no units are involved.

Pure numbers, without units, also happen in physics, so it is not true that "all the equations ... had units." Many physics quantities are pure, such as coefficient of friction, mechanical advantage, and efficiency. So are sines, cosines, and tangents of angles. (There may be a dispute over the proper units for angles--radians or degrees--but everyone agrees that the trigonometric function values themselves have no units.) One physics equation that involves no unit is "the coefficient of static friction of rubber on dry concrete is ten times that of ice on ice."

  • $\begingroup$ I'm not exactly sure why the unit for x in first equation is packs and not packs of m&ms? $\endgroup$
    – fYre
    Aug 30, 2015 at 18:40
  • 1
    $\begingroup$ @fYre $$x_{packs} = \text{M&M}_{packs}$$ The units tell you what we are measuring, packs, the variable name serves to differentiate the packs of M&Ms from the packs of Twizzlers. You could replace $x$ and $y$ with $\text{M&M}$ and $\text{Twizzler}$ if you wanted and the effect would be the same. $\endgroup$
    – Slinky
    Aug 30, 2015 at 19:02

You can write your equations as \begin{align} x \text{ packets} + y \text{ packets} = 10 \text{ packets} \\ x \text{ packets} \cdot 1 \text{ dollars/packet} + y \text{ packets} \cdot 0.5 \text{ dollars/packet} = 6 \text{ dollars} \end{align} When you do so, you realize that $x$ and $y$ are unitless numbers, as you can see by dividing the top equation by the unit "packets").

Hence it's valid to apply operations like adding, subtracting, etc., to them.


When you subtract or add the equations, you have to change them to make sure that you can do so. The implications of this are that you can generally ignore the units or add them in afterwards.

I'll show you what I mean.

$$x_{packets} + y_{packets} = 10_{packets}$$ $$($1)x_{packets} + ($0.5)y_{packets} = $6_{packets}$$

If you were to state the units on the second equation, they'd be something like 'packet dollars', or cost for the given number of packets at the given price. The idea here is similar to a kilowatt-hour, it isn't just the kilowatts or the hours, it is the product between the two.

When you are subtracting the equations, you have to change at least one of them so that a variable cancels out, mostly through multiplication.


$$(-$1)(x_{packets} + y_{packets} = 10_{packets})$$ $$($1)x_{packets} + ($0.5)y_{packets} = $6_{packets}$$

Now you can distribute in the negative dollar, add the equations together and solve for $y$.

So the equations become

$$(-$1)x_{packets} + (-$1)y_{packets} = -$10_{packets}$$ $$($1)x_{packets} + ($0.5)y_{packets} = $6_{packets}$$

Add them together

$$(-$0.5)y_{packets} = -$4_{packets}$$


$$y_{packets} = \frac{-$4_{packets}}{-$0.5} = 8_{packets}$$

And there's your answer.

All this shows is that you don't really have to worry about the units in equations like this, what you're looking for is a point where all the numbers line up and both equations become true.

And as John Hughes and Rory Daulton said, the units can just be cancelled out from the beginning.

Just don't worry about them.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .