Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to tell Mathematica to factor

$$ \frac{1}{1-x^2} $$

from a large expression?

For instance if the expression is A_1+A_2+A_3 and I want to factor 1/(1-x^2) from A_1+A_2 but leave A_3 alone.

share|improve this question
Please edit all relevant info, examples etc. into the question, comments are not well-suited for that purpose. – Yves Klett Jun 9 '14 at 18:00
If the expression is 1+2+3 then, in the absence of Hold or Unevaluated or the like, it will automatically evaluate to 6. – Daniel Lichtblau Jun 9 '14 at 18:04
@LoveLearning People are trying to help you here... please give a concrete example — i.e. actual terms for A1, A2 and A3. We cannot answer for hypothetical and general questions because the strategy will differ depending on what your terms are. I suggest looking at the link in Artes' first comment above. – R. M. Jun 9 '14 at 19:01
@Artes The problem is more general than the polynomial one, and the solution of such a problem is of enormous use in itself. I would upvote it. – Alexei Boulbitch Jun 10 '14 at 8:16
@Love Learning. This question has been one of the discussed during the Q&A session of the last Technology Conference. The outcome is that there is no such a function in the main body of Mma, but such a function is badly needed. I can point out to the package "Presentations" of David Park, where there is a function "FactorOut" designed exactly for such a purpose. You may have a look here: Its advantage with respect to the solution of J.W.Perry below, is that the parts are not held. – Alexei Boulbitch Jun 10 '14 at 8:22

Here is a very simple little function that takes two expressions k and p, and any function that accepts a single expression (like Expand, Together, Simplify,Apart,...). It then factors k from p and outputs a new expression $p=kq$. The parameter func_ operates on the form of $q$.

Here is the function:

sfactor[k_, p_, func_] := HoldForm[StandardForm[k]]*StandardForm[func@(p*1/k)]

The output is going to have unreleased hold forms in it thus limiting the usefulness of that output, but then again, I have no idea what you would want it for except to actually look at the factoring. Here are some examples:

Factor $x^2$ from $x^3+3x+1$:

sfactor[x^2, x^3 + 3 x + 1, Apart]


enter image description here

What it does to your abstract example:

sfactor[1/(1 - x^2), Subscript[a, 1] + Subscript[a, 2], Expand] + Subscript[a, 3]


enter image description here

And one more for giggles, here I know one of the binomial factors:

sfactor[x^2 + 3, 3 + 15 x + 22 x^2 + 11 x^3 + 7 x^4 + 2 x^5, Simplify]


enter image description here

Again, an expression involving unreleased hold forms would need to be fixed for further computations, but you know what it would simplify to in the end, the output always being $p$ expressed with the factor $k$.

share|improve this answer
OK.... But looks complicated. – Faq Jun 10 '14 at 8:45
@J. W. Perry I like it very much. I would, however, propose a slightly different expression based on your approach, but without Hold in the end: sFactor[expression_, factor_, f_: Simplify, g_: Identity] := Release[Hold[g[factor]]]*f[(expression/factor)];. Now the obtained expression may be further manipulated, if necessary. The penalty is that in some special cases it might not protect the result from automatic simplification. Then one of the functions f or g should be chosen different than the default ones. – Alexei Boulbitch Jun 10 '14 at 9:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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