8
$\begingroup$

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.

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

1 Answer 1

8
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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