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 smc.vnet.net
  • Subject: [mg130435] Re: How can I force mathematica to collect a symbol from a
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Thu, 11 Apr 2013 04:10:48 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

Let's say I have a polynomial:
          a+b+c
Is there any way I can force mathematica to produce the following result:
          a*(1+b/a+c/a)

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.

Hi,

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:

Simplify[expr4]

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: http://home.comcast.net/~djmpark/Mathematica.html).  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.
IEE S.A.
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 iee.lu







  • 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