Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

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

I have a simply expression that I can see that I can express as a product.

-3.041109351939086` y^8.498317296251567` - 
 19.00693344961927` y^8.648317296251566` + 
 0.19006933449619273` y^9.498317296251567` + 
 x^4.676655975278822` (3.0411093519390855` y^3.8216613209727446` + 
    19.00693344961927` y^3.9716613209727445` - 
    0.19006933449619273` y^4.821661320972744`)

EDIT: (To explain what I mean by product)

The above expression is this:

$x^{4.67666} \left(-0.190069 y^{4.82166}+19.0069 y^{3.97166}+3.04111 y^{3.82166}\right)+0.190069 y^{9.49832}-19.0069 y^{8.64832}-3.04111 y^{8.49832}$

Eyeballing it I see that the term $ \left(-0.190069 y^{1}+19.0069 y^{0.15}+3.04111 y^{0}\right)$ is a common one and the above expression one can be written as:

$ \left(-0.190069 y^{1}+19.0069 y^{0.15}+3.04111 y^{0}\right) \left(x^{4.67666}y^{3.82166}-y^{8.49832}\right)$

This is one way to write things as a product. I can always take $y^{3.82166}$ out as well and write it as:

$ \left(-0.190069 y^{1}+19.0069 y^{0.15}+3.04111 y^{0}\right) \left(x^{4.67666}-y^{4.67666}\right)y^{3.82166}$

  1. Other than re-writing it by hand, is there a command that I can use to write this expression as a product of two or more other expressions?

  2. Is there something I can do in general? Something that takes common factors out where the factors can be large expressions that I am not aware of upfront?

The point is that I am trying to figure out the signs of various expressions, hence the need to write things as products.

Also, I am anticipating that the imprecise nature of numerical solving means that expressions that may be factors might not show up that way in MMA since different numbers are truncated differently. Still.... I'd appreciate tips even if they are conditional on the numbers being integers.

share|improve this question
Could you please give a specific criterion, or at least an example, of what it means to write such an expression as a "product"? Because it is not a polynomial, there seems no natural way to decompose it. In fact, we could take any expression $f(x,y)$ and any other expression $g(x,y)$ and write $f$ as the product $f(x,y)=g(x,y) h(x,y)$ where $h(x,y)=f(x,y)/g(x,y)$. – whuber Dec 15 '12 at 3:50
@whuber I just added the example of what I meant. I need to think about how this would translate into a desirable criterion. – Amatya Dec 15 '12 at 6:50
up vote 4 down vote accepted

Interesting question. Here's how I got from your initial expression to something close to your desired result.

First, Round all the reals to rationals:

ex = -3.041109351939086` y^8.498317296251567` - 
   19.00693344961927` y^8.648317296251566` + 
   0.19006933449619273` y^9.498317296251567` + 
   x^4.676655975278822` (3.0411093519390855` y^3.8216613209727446` + 
      19.00693344961927` y^3.9716613209727445` - 
      0.19006933449619273` y^4.821661320972744`);

ex /. r_Real :> Round[r, 10^-10]

$-\frac{30411093519 y^{84983172963/10000000000}}{10000000000}-\frac{5939666703 y^{86483172963/10000000000}}{312500000}+\frac{380138669 y^{94983172963/10000000000}}{2000000000}+x^{46766559753/10000000000} \left(\frac{30411093519 y^{3821661321/1000000000}}{10000000000}+\frac{5939666703 y^{3971661321/1000000000}}{312500000}-\frac{380138669 y^{4821661321/1000000000}}{2000000000}\right)$

I tried to Factor this but got an error. Simplify gave an interesting result though:


$\frac{1}{10000000000}y^{3821661321/1000000000} \left(x^{46766559753/10000000000} \left(30411093519+190069334496 y^{3/20}-1900693345 y\right)+y^{46766559753/10000000000} \left(-30411093519-190069334496 y^{3/20}+1900693345 y\right)\right)$

Notice how Simplify was unable to get any further, despite the obvious factorisation. The problem would appear to be the large fractional powers. So I convert any large fractional powers back to reals, leaving the $y^{3/20}$ term untouched.

% /. x_^Rational[n_, d_ /; d > 10^6] :> x^N[n/d]

$\frac{1}{10000000000}y^{3.82166} \left(x^{4.67666} \left(30411093519+190069334496 y^{3/20}-1900693345 y\right)+y^{4.67666} \left(-30411093519-190069334496 y^{3/20}+1900693345 y\right)\right)$

Now Factor is able to do the factorisation:


$-\frac{y^{3.82166} \left(-30411093519-190069334496 y^{3/20}+1900693345 y\right) \left(x^{4.67666}-y^{4.67666}\right)}{10000000000}$

Of course there is some loss of precision due to the inital rounding step, and you would need to do some more testing to find out if the same sequence of steps works on other expressions, but I thought this was at least food for thought and maybe something on which to base a more robust solution.

share|improve this answer
Wooods Thanks a lot for your answer. I'm sorry I didn't respond sooner. This has given me a lot to work with. I have a lot of such expressions that I want to be able to express in different forms to cancel stuff out or to determine signs. Thanks.. I will write more when I have more questions. Thx – Amatya Dec 26 '12 at 21:17
@Amatya, you're welcome. I must admit I expected (and hoped) that this question would get more attention. I feel like we're missing something - as you point out, the factorisation is fairly obvious when eyeballing the expression, so it seems surprising that we have to jump through hoops to get Mathematica to do it. – Simon Woods Dec 27 '12 at 21:35

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.