# How to simplify first several factors of an expression, without trying to simplify the rest?

I have a long expression of the form

-(1/(12 M (2 + M - M ζ^2 - η^2))) (-2 + M (-1 + ζ^2) + η^2)(some long expr)


The expression is a result of a Mathematica command. (Here's the expression itself, for the reference.) The long expression (some long expr) is a polynomial in ζ and η, and, if simplified, the whole expression would also be a (product of) polynomial(s) — unlike its form above, which is a ratio of polynomials.

The first two factors can be simplified by Simplify successfully, but, when applied to the full expression, it leaves them unchanged. I tried FullSimplify on the full expression, but I couldn't wait until it finishes.

I'd like to direct Mathematica to simplify the first two factors to 1/(12 M), without touching the rest, so that the result would be

1/(12 M)(some long expr)


How can I achieve this?

You can define a function for that long expression and specify that as an excluded form in Simplify.

someLongExp[x_] = Expand[(1 + x)^100, x]
Simplify[-(1/(12 M (2 + M - M ζ^2 - η^2))) (-2 + M (-1 + ζ^2) + η^2) someLongExp[x],
ExcludedForms -> {someLongExp[_]}]


Edit

As pointed out by @bbgodfrey, it does not work for all cases (for example, when someLongExp[x_] = 2 Expand[(1 + x)^100, x]). As suggested by @bbgodfrey, this can be resolved by using Hold and ReleaseHold as follows.

someLongExp[x_] = 2 Expand[(1 + x)^100, x] // Hold;
Simplify[-(1/(12 M (2 + M - M ζ^2 - η^2))) (-2 + M (-1 + ζ^2) + η^2) someLongExp[x],
ExcludedForms -> {someLongExp[_]}] // ReleaseHold


Another way is by using TimeConstraintto force Simplify to use only the basic simplification rules.

Quiet@Simplify[-(1/(12 M (2 + M - M ζ^2 - η^2))) (-2 + M (-1 + ζ^2) + η^2) someLongExp[x],
TimeConstraint -> 0.0001]

• This elegant solution works for the example given but not for 2 Expand[(1 + x)^100, x] and for some other instances. This problem can be circumvented by using Hold on the right side of the first line, and \\ ReleaseHold at the end of the second line of code. – bbgodfrey Mar 15 '17 at 23:10
• @bbgodfrey Thanks for pointing that out. – Anjan Kumar Mar 15 '17 at 23:47
• But what if the whole expression is the output of another command, not something you just enter/copy-paste? – Ruslan Mar 16 '17 at 5:47
• @Ruslan Can you clarify by giving an example. – Anjan Kumar Mar 16 '17 at 11:21
• @Ruslan I think by limiting the simplification time using TimeConstraint, we can force Simplify to use only the basic simplification rules. The above solution can be modified as follows. Quiet@Simplify[-(1/(12 M (2 + M - M ζ^2 - η^2))) (-2 + M (-1 + ζ^2) + η^2) someLongExp[x], TimeConstraint -> 0.0001] – Anjan Kumar Mar 16 '17 at 12:07