MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How can I force mathematica to collect a symbol from a

  • To: mathgroup at
  • Subject: [mg130435] Re: How can I force mathematica to collect a symbol from a
  • From: Alexei Boulbitch <Alexei.Boulbitch at>
  • Date: Thu, 11 Apr 2013 04:10:48 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

Let's say I have a polynomial:
Is there any way I can force mathematica to produce the following result:

I think such transformation of polynomials should be very common; however, 
I have been trying all day and still can not get mathematica to do so automatically.


It is my personal opinion, that one of few real drawbacks Mathematica has, is that the canonical Mathematica program has no function to make a factor of a customer's choice out of the parentheses. As well as few other functions of such a sort, to enable one to  customize the forms of analytical expressions. I impatiently wait for such additional functions for already more than 10 years and strongly hope that the developers will one day take this opinion into account, soon, rather than late.

However, here is one way to do what you need:

This is your expression:

expr1 = a + b + c;

Now let us substitute b -> x*a and c -> y*a and take a out of the parentheses:

expr2 = a + b + c /. {b -> x*a, c -> y*a} // Factor
a (1 + x + y)

Now let us substitute back. Here instead of the substitution x->b/a and y->c/a one should, however, put x -> HoldForm[b/a], y -> HoldForm[c/a] in order to prevent Mathematica simplifying the result on the spot:

expr3 = expr2 /. {x -> HoldForm[b/a], y -> HoldForm[c/a]}

a (1 + b/a + c/a)

If the expression in this form is your final aim, that's it. In this case you might also use Defer in the place of the HoldForm.

If, however, you are going to use this expression for further analytical operations, you might need the parts b/a and c/a not to be held further. This can be achieved by application of ReleaseHold to it:  

expr4 = expr3 // ReleaseHold

a (1 + b/a + c/a)

Note that it may be done also on a later step of your calculations, if needed.
To check that ReleaseHold indeed makes its parts free from being held, let us apply Simplify to the result and see, what happens:


a + b + c

That's it, therefore.

There is, however, another, much better way for doing such things.

There is a package written by David Park entitled "Presentations" (you may have a look at it here:  This package contains a part called Manipulations. The latter part contains a function FactorOut that in one line does the job you asked for. In addition Manipulations part has several other functions that enable one to transform analytical expressions and their parts very much the same way one is accustomed to do it on the paper.

I personally think that it is a must to have this package, I use it to reinforce Mathematica on the everyday basis and strongly recommend it to everyone interested.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at

  • Prev by Date: Re: Can I join please?
  • Next by Date: Re: Timing puzzle
  • Previous by thread: Re: Mathematica can't solve this equations and stuck my PC
  • Next by thread: Arranging disks (or any object for that matter) be arranged in a