# Cancel out common factors in algebraic expressions that are equal to zero

I have the following original expression:

(100 c)/(e y) + (100 b x)/(e y) + (100 a x^2)/(e y) == 0

which, after factoring out the common terms looks like this intermediate expression:

(100 (c + b x + a x^2))/(e y) == 0

Since 100/(e y) is a common factor, and all of the variables are assumed to be positive numbers, I can cancel it out to obtain the target expression, ready for solving:

c + b x + a x^2 == 0

In summary, I need to be able to "cancel out" all common factors for any kind of algebraic expression, such as in the above example.

Failed Attempt:

Numerator[Factor[(100 a)/(e y) + (100 b x)/(e y) + (100 c x^2)/(e y)]]

gives 100 (a + b x + c x^2) == 0, which does not satisfy the goal of obtaining an expression without common factors.

• Have you already seen Cancel[]? You might also need to use Together[] as well. Jun 5, 2020 at 1:54
• Cancel[] unfortunately does not cancel any part of the common factor in the example I gave. Jun 5, 2020 at 2:00
• So, Cancel[Together[(100 c)/(e y) + (100 b x)/(e y) + (100 a x^2)/(e y)]] == 0 is unsatisfactory for you? Jun 5, 2020 at 2:04
• Together[] factors out the common terms, but Cance[] does not have the desired effect of canceling out the terms to get the target expression of c + b x + a x^2 == 0 Jun 5, 2020 at 2:27

You need to tell the simplification process your assumptions:

z = FullSimplify[(100 c)/(e y) + (100 b x)/(e y) + (100 a x^2)/(e y) == 0,
Assumptions -> {e > 0, y > 0}]

c + x (b + a x) == 0


Of course you really don't want to assume that all the variables are positive reals, because then the equation never holds. So we need to either make the assumptions about the variables (like above) or make the assumption about all the variables except the ones that are truly variable (in this case x):

eqn = (100 c)/(e y) + (100 b x)/(e y) + (100 a x^2)/(e y);
var = Variables[eqn];
varNoX = Select[var, # =!= x &];
Factor[FullSimplify[eqn == 0, Assumptions -> Thread[varNoX > 0]]]

c + b x + a x^2 == 0


var contains all the variables, and vars contains all but x, which are assumed to be positive real.

• Your expression works well, but requires me to know ahead of time which variables belong to the function. This needs to work for a generic expression where all the variables are positive Reals. Any ideas how to generalize the assumption? Jun 5, 2020 at 3:32
• You have variables a,b,c,e,y that you want to be one kind of thing (positive reals) and another variable x that you will allow to be negative or even complex. Mathematica can't read your mind and know which is which. Observe that if you truly insist that all variables are positive, then the answer is simply "False", that is, the equation can never equal zero. Jun 5, 2020 at 4:00
• Bill, you are right--all variables except a target one are positive reals. The "chosen" one is an non-zero variable. Jun 5, 2020 at 4:12
• I've added a way to easily make the assumption that all except x are positive real. Jun 5, 2020 at 4:14