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.

  • $\begingroup$ Have you already seen Cancel[]? You might also need to use Together[] as well. $\endgroup$ – J. M.'s ennui Jun 5 '20 at 1:54
  • $\begingroup$ Cancel[] unfortunately does not cancel any part of the common factor in the example I gave. $\endgroup$ – felimz Jun 5 '20 at 2:00
  • $\begingroup$ So, Cancel[Together[(100 c)/(e y) + (100 b x)/(e y) + (100 a x^2)/(e y)]] == 0 is unsatisfactory for you? $\endgroup$ – J. M.'s ennui Jun 5 '20 at 2:04
  • $\begingroup$ 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 $\endgroup$ – felimz Jun 5 '20 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.

  • $\begingroup$ 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? $\endgroup$ – felimz Jun 5 '20 at 3:32
  • $\begingroup$ 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. $\endgroup$ – bill s Jun 5 '20 at 4:00
  • $\begingroup$ Bill, you are right--all variables except a target one are positive reals. The "chosen" one is an non-zero variable. $\endgroup$ – felimz Jun 5 '20 at 4:12
  • $\begingroup$ I've added a way to easily make the assumption that all except x are positive real. $\endgroup$ – bill s Jun 5 '20 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.