Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm running code that produces a long combination of rational functions with free constants that need to be tuned such that the combination vanishes.

My current method is to put the combination over a single denominator with Together[], then look at the CoefficientArrays[] of the numerator and make sure all entries vanish. The trouble is, the step using Together[] is very time consuming, and seems in some cases to get stuck (basically, the process just runs the CPU with a fixed memory usage for hours, when normally Together has a pattern of rising and falling memory usage as it shrinks the expression it creates).

My assumption is that the problem with using Together in this context is that it doesn't just put everything over a single denominator, it also tries to factor out common terms. But I don't need it to factor out common terms, since a failure to factor something will just mean a few more redundant equations to solve. Is there anything like Together, that doesn't bother with trying to cancel things? Or an option to make Together give up after a certain (reasonable) amount of time?

Edit: To those suggesting just multiplying through by the product of the denominators, one issue is that not all of the objects are expressed as P/Q. So for example, say I have:

(1/(1-v)-v/(1-w))/((1-v)(1-u)) - (1-w)/(u v w(1-v))

I want this expressed as one object, P/Q, and I don't care about canceling common factors between P and Q. Is there a function that does that? I suppose I could just repeatedly multiply through by all denominators for each subexpression, but that seems inefficient.

share|improve this question
A simple example (with code) would really help us understand the problem. –  bill s Nov 19 '13 at 15:53
You could multiply through by the product of all denominators. –  Daniel Lichtblau Nov 19 '13 at 15:55
Also this might be of interest for your needs. –  Daniel Lichtblau Nov 19 '13 at 15:57
I've added an example. Your code looks helpful, though it doesn't really solve my "have to apply to each subexpression first" issue. –  Matt Nov 19 '13 at 17:33

1 Answer 1

There is a simple Combine function , which in essence is just:

Combine[x_] := 
 Module[{combinet1, combinet2}, 
  combinet2 = Together[ x /. Plus -> (
                If[ FreeQ[{##}, _^_?Negative] && 
                    FreeQ[{##}, Rational], 
                    combinet1[##], Plus[##] ] &) 
                  ] /. combinet1 -> Plus]

Then your expression gets simplified like this:

Mathematica graphics

share|improve this answer

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.