MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Reversing PowerExpand

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37532] RE: [mg37518] Reversing PowerExpand
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 3 Nov 2002 02:59:08 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Dave,

Here is a RootsTogether routine excerpted from the ExpressionManipulation
package at my web site. Ted Ersek helped program this routine.

RootsTogether::usage = "RootsTogether[expr] will put \
factors involving the same kind of root together under \
one root sign. Like PowerExpand it is not always a \
permissible operation. Mathematica automatically removes \ numeric factors
from root expressions.";

RootsTogether[expr_] :=
  Module[{numbertest, radicalexpand, togetherrules},
   numbertest = FreeQ[#1, Complex] &&  !NumericQ[#1] & ;
    radicalexpand = (a_^p_Integer)^q_Rational :>
      a^(p*q); togetherrules =
     {(n_.)*(a_)?numbertest^q_Rational*(b_)?numbertest^
         q_Rational :> n*(a*b)^q,
      (n_.)*(a_)?numbertest^p_Rational*(b_)?numbertest^
          q_Rational /; p + q == 0 && p > q :>
       n*(a/b)^p, (n_.)*(a_)?numbertest^(Rational[na_,
          r_])*(b_)?numbertest^(Rational[nb_, r_]) :>
       n*(a^na*b^nb)^(Rational[1, r])};
    expr //. radicalexpand //. togetherrules]

Sqrt[x y]
% // PowerExpand
% // RootsTogether

gives

Sqrt[x*y]
Sqrt[x]*Sqrt[y]
Sqrt[x*y]

The routine will also work on roots other than square and roots in the
denominator.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Dave Snead [mailto:dsnead6 at charter.net]
To: mathgroup at smc.vnet.net

I can use PowerExpand to go from

Sqrt[x y] to Sqrt[x] Sqrt[y]

How do I reverse this and go from

Sqrt[x] Sqrt[y] to Sqrt[x y]

Thanks in advance.
--Dave Snead






  • Prev by Date: RE: Newbie-type question: structured data types in Mathematica?
  • Next by Date: Re: Vector field with ImplicitPlot ?
  • Previous by thread: Reversing PowerExpand
  • Next by thread: Re: Reversing PowerExpand