From: dantimatter on

Hello Community of Mathematica Users,

My collaborators and I are having a nasty problem that I'm hoping you
might be able to help us move beyond:

After spending quite a few hours Solve[]-ing an equation, Mathematica
returns an extremely large solution where all the terms contain
complicated denominators and square roots. We've set the solution
equal to zero and would like to now simplify it by getting rid of all
the denominators (e.g., by multiplying through by all of them) and the
square roots (e.g., by multiplying by their conjugates). Is there a
good way to do this? Mathematica seems to get hung up when we try to
use Together[], Collect[], Simplify[], etc. Is there another function
that would be better to use? Perhaps there's some other way around
this problem? Any suggestions you have would be much appreciated.

Many thanks,
Dan

From: David Park on
Dan,

"Huge" seems daunting and without knowing more about your expression I'm not
certain how much progress can be made. So I tentatively offer the following.

In the Presentations package I have developed a number of routines that aid
in manipulating and simplifying expressions. The various Mathematica
commands are useful, but often they do too much, or too little, or are
difficult to precisely control. Some of the extra "Manipulations" commands
in Presentations are:

CompleteTheSquare
FactoOut - any factor, even if it's not in the expression.
AddZero - creating a new expression by adding and subtracting the same
subexpression.
MultiplyByOne - Multiply and operate on Numerator and Denominator by the
same factor.
LinearBreakout - breakout function patterns on operand patterns
PushOnto - push arguments onto selected function patterns. (Much better than
Through.)
CreateSubexpression - protect subexpressions with a tag for selective
manipulation.
ReleaseSubexpressions
OperateSubexpression
MapLevelParts - Map a function to a subset of level parts, for example
selected terms in a larger Plus expression. The function operates on the
complete group of selected terms and not on individual terms.
MapLevelPatterns - same thing except that the parts are selected by a
pattern and not by position.
EvaluateAt - Evaluate a part of a held or ordinary expression.
EvaluateAtPattern - same thing but by pattern.

Two useful techniques for manipulating expressions are to:

1) Shield portions of the expression so Mathematica will treat them as a
unit and not break them apart. This will often make commands like Simplify
work better. You could shield with Hold or HoldForm, and in a more
controlled manner with CreateSubexpression. Another method to shield might
be to replace the expression by a single symbol, and then later do the
reverse replacement.

2) Operate on selected portions of the expression using MapAt, ReplacePart,
MapLevelParts, MapLevelPatterns, EvaluateAt, EvaluateAtPattern.

Using these methods either alone or combined with the higher level
Mathematica operations such as Simplify, Together and Apart can be very
effective. You should also consider the use of Rules.

The MultiplyByOne command might simplify your denominators by using the
complex conjugate. (You could probably implement this yourself) If different
terms had different denominators you could probably use MapLevelPatterns to
pick out the subgroups of common terms. You could use FactorOut to get a
common denominator out of a group of terms.

Here is a sample case:

Needs["Presentations`Master`"]

expr = k1/(a1 + I b1) + k2/(a2 + I b2);
(# /. term : k_/(a_ + b_ I) :> MultiplyByOne[a - b I][term]) & /@ expr
% // FactorOut[1/((a1^2 + b1^2) (a2^2 + b2^2)), Factor]

giving


((a1 - I b1) k1)/(a1^2 + b1^2) + ((a2 - I b2) k2)/(a2^2 + b2^2)

((a1 - I b1) (a2 - I b2) (a2 k1 + I b2 k1 + a1 k2 + I b1 k2))/((a1^2 +
b1^2) (a2^2 + b2^2))



David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/



From: dantimatter [mailto:google(a)dantimatter.com]

Hello Community of Mathematica Users,

My collaborators and I are having a nasty problem that I'm hoping you
might be able to help us move beyond:

After spending quite a few hours Solve[]-ing an equation, Mathematica
returns an extremely large solution where all the terms contain
complicated denominators and square roots. We've set the solution
equal to zero and would like to now simplify it by getting rid of all
the denominators (e.g., by multiplying through by all of them) and the
square roots (e.g., by multiplying by their conjugates). Is there a
good way to do this? Mathematica seems to get hung up when we try to
use Together[], Collect[], Simplify[], etc. Is there another function
that would be better to use? Perhaps there's some other way around
this problem? Any suggestions you have would be much appreciated.

Many thanks,
Dan