Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2011

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

Search the Archive

Re: Grouping terms under the radical

  • To: mathgroup at
  • Subject: [mg120106] Re: Grouping terms under the radical
  • From: Bob Hanlon <hanlonr at>
  • Date: Fri, 8 Jul 2011 04:54:50 -0400 (EDT)
  • Reply-to: hanlonr at

You could use $Post to apply the substitution to all output; however, ReleaseHold would not work without first clearing $Post  since the substitution would be automatically reapplied to the output of the ReleaseHold.

mySqrt = # /. Sqrt[x_]*Sqrt[y_] -> HoldForm[Sqrt[x*y]] &;

$Post = mySqrt;

expr = Sqrt[2 n]


$Post =.

expr // ReleaseHold


Perhaps easier to just apply mySqrt as required.

expr // mySqrt


Bob Hanlon

---- Paul von Hippel <paulvonhippel at> wrote: 

Thanks for this solution! But what if the expression Sqrt[2*n] is not something that I've input, but part of an expression in Mathematica's output. The output shows 2 and n under separate radicals. How can I tell the software I prefer to see terms combined under a common radical?

--- On Thu, 7/7/11, Bob Hanlon <hanlonr at> wrote:

From: Bob Hanlon <hanlonr at>
Subject: [mg120106] Re: Grouping terms under the radical
To: "paulvonhippel at yahoo" <paulvonhippel at>, mathgroup at
Date: Thursday, July 7, 2011, 7:25 AM

expr = Sqrt[2*n]


expr /. Sqrt[x_] Sqrt[y_] -> HoldForm[Sqrt[x*y]]


% // ReleaseHold


Bob Hanlon

---- paulvonhippel at yahoo <paulvonhippel at> wrote: 

This must be a classic question. When I input
 Sqrt[(2 n)]
Mathematica displays the output as Sqrt[2] Sqrt[n] -- i.e., both 2 and
n are under their own radical. The display of output doesn't change if
I impose the assumption that n > 0.

This is fine from a mathematical point of view, but it looks
unconventional when pasted into a paper. It seems to me most authors
would keep the 2 and the n under a common radical -- how can I get
Mathematica to do the same?


  • Prev by Date: Re: How to write a "proper" math document
  • Next by Date: Re: Contour ColorFunction in a ParametricPlot
  • Previous by thread: Re: Grouping terms under the radical
  • Next by thread: Re: Grouping terms under the radical