Remove multiplicative constant A in equation A*f(x)=0

I would like to find x in the equation A*f(x)=0 for A>0. Since A is a very large expression, I would save time by solving f(x)=0 instead. Is there a way to let Mathematica "cancel out A" (even if it is an expression that not explicitly specified)?

Note that FullSimplify does not do this job correctly (and certainly not fast enough)

Example:

Solve[(Q (-1 + A + Sqrt[x]))/B == 0]


I would like to obtain the expression (without manual inspection):

A + Sqrt[x] == 1

• you can use Replace to eliminate A, like Replace[A[y] f[x], A[y] f[x] -> f[x]] – Sumit Aug 24 '16 at 13:06
• Thanks, but the issue is that A is big, unknown expression. The replacement rule would therefore not work... – Breugem Aug 24 '16 at 13:15
• A few example expressions will be helpful. – Szabolcs Aug 24 '16 at 13:17
• What about a + b + b x == 0? Do you expect this to be transformed to a/b + 1 + x == 0? My point is that it is not clear when a factor should be divided out. In your example Q and B disappear completely, so it is a very specific case. What are your criteria for deciding what to divide out? I'm just trying to make the question more objective and concrete. – Szabolcs Aug 24 '16 at 14:16
• Thanks for your comment. Key importance to me is to generate an equation that can simply be executed as fast as possible. – Breugem Aug 24 '16 at 14:35

Here is one method:

Select[((Q (-1 + A + Sqrt[x]))/B == 0)[[1]], Not[FreeQ[#, x]] &] == 0

(* -1 + A + Sqrt[x] == 0 *)


Then you could put the output into Solve.

Or, more generally:

SetAttributes[extractfx, HoldAll];
extractfx[eq_, sym_Symbol] := Select[eq[[1]], Not[FreeQ[#, sym]] &] == 0;


which yields:

extractfx[(Q (-1 + A + Sqrt[x]))/B == 0, x]

(* -1 + A + Sqrt[x] == 0 *)


Note that the above code works only when the LHS has some multiplication at the outmost level and contains your variable, and the RHS is 0.

You can use the optional parameter of Simplify or FullSimplify to specify assumptions. $A f(x)=0$ only simplifies to $f(x)=0$ when $A\ne0$, so we can just use that assumption:

Simplify[A*f[x]==0,A!=0]


And of course you can specify a list of assumptions as well:

Simplify[(Q (-1 + A + Sqrt[x]))/B == 0, {Q!=0, B!=0}]


See the full documentation for Simplify.

• That does not prevent the evaluation of A. – JungHwan Min Aug 24 '16 at 14:00