4
Simplifying Square Ro ots of
Square Ro ots by Denesting
David J. Je rey Alb ert D. Rich
The UniversityofWestern Ontario Soft Warehouse, Inc.
Abstract: We discuss why it is imp ortant to try to simplify the square
ro ot of an expression containing other square ro ots, and we give rules for
doing this when it is p ossible. The square ro ot of an expression containing
nth ro ots is also considered brie y. This article, in addition to treating a
sp eci c mathematical topic, shows some of the steps that develop ers must
take when writing computer algebra systems.
4.1 Intro duction
p p
3
1
2 and 5 are called surds [Chrystal64, Hall88]. The more general Numb ers suchas
terms radical and algebraic number are also used, but surd is the most sp eci c. It is
2
avenerable term that has b een revived for use in computer systems . Given p ositive
n
integers n and k , the unique p ositive real ro ot of the equation x = k will b e denoted
p
n
k and called a surd. Most b o oks [Chrystal64, Hall88]allow k to b e a p ositive rational
numb er, and there is no great di erence in principle if we accept that generalization;
in this article, however, all the examples use integers. Another p ointofvariation is
p p
8or2 2; here we the treatment of p erfect-p ower factors, i.e., whether one writes
use whichever form is more convenient.
The term radical may b e familiar to some readers from the common phrase `solvable
in terms of radicals', which is used whenever a textb o ok discusses the ro ots of a
p olynomial [Dickson26]. A p olynomial equation is solvable by radicals if `. . . its ro ots
can b e found by rational op erations and extractions of a ro ot. . . ' [Dickson26]. Thus
p
p
a quantity suchas 1+ 2 is a radical, but not a surd. Polynomials of degree less
1
Please do not tell us jokes ab out these numb ers b eing ab surd. Wehave heard them all b efore.
p
2
The term surd is used byT X as the name for the symbol ; Maple has a function called
E
surd that is similar to the nth ro ot de ned here; like all go o d mathematical terms, the
precise de nition dep ends up on the context. In general, a mathematical term that do es not
have several con icting de nitions is not imp ortant enough to b e worth learning.
From Computer Algebra Systems: A Practical Guide, M.J. Wester, Ed., Wiley 1999.
62 COMPUTER ALGEBRA SYSTEMS: A PRACTICAL GUIDE
than or equal to 4 are always solvable by radicals, and higher-degree p olynomials are
sometimes solvable by radicals. An algebraic number is a ro ot of some p olynomial
with integer co ecients, and in general will not b e expressible as a radical, although
all radicals are sp ecial cases of algebraic numb ers. The p ositive real solution of the
n
equation x = r , where r is a p ositive radical, will here b e called the nth ro ot of r , and
will itself b e a radical. The other familiar name for these typ es of numb ers is (1=n)th
power, but this term will not b e used b ecause fractional p owers are regarded bymany
3
p eople as multivalued functions , and wewanttowork with uniquely de ned (and
named) quantities.
Our attention in this article is directed to radicals consisting of the square ro ot of an
p
p p
expression containing surds, for example 2+ 3 . Such expressions are often called
nestedradicals, although one could argue that strictly the word nested is redundant.
Such expressions can sometimes b e simpli ed, but the rules for such simpli cations
are not discussed in standard b o oks. Here are some examples of simpli cations. The
rst example shows that two square ro ots can sometimes b e reduced to one:
q
p p
3+2 2=1+ 2 : (4.1)
Sometimes the numb er of square ro ot op erations remains unchanged, but p eople prefer
the format of the new expression:
q
p p p
5+2 6= 2+ 3 : (4.2)
This rearrangement of the square-ro ot op erations is usually called denesting. Here are
some more examples of square-ro ot denesting.
q
p p p p
4 4
5 3+ 6 2 = 27 + 12 ; (4.3)
q
p p p p p p
12 + 2 6+ 2 14 + 2 21 = 2+ 3+ 7 : (4.4)
We do not restrict ourselves to taking the square ro ot only of other square ro ots:
q
p p p
3 3 3
9+ 6 3+9 = 3+ 3 ; (4.5)
q
p p
p p p
3 3
3 3 3
1
5 4 = : (4.6) 2+ 20 25
3
4.2 Why denest square ro ots?
Discovering the relations given in the examples ab oveisaninteresting mathematical
challenge, but why should a computer algebra system (CAS) devote computing
resources to denesting problems? The rst reason is simplicity. Users of CAS, likeall
mathematicians, prefer to see their results expressed in `simplest' form. Most p eople
would regard the right-hand sides of our examples ab ove as b eing `simpler' than the
left-hand sides, although there mightbesomewhowould disagree. For example, in
3
The question \Are fractional p owers multivalued?" is a standard basis for table assignments
at conference banquets.
From Computer Algebra Systems: A Practical Guide, M.J. Wester, Ed., Wiley 1999.
SIMPLIFYING SQUARE ROOTS OF SQUARE ROOTS BY DENESTING 63
[Landau92b], reasons are given for preferring the left-hand side of (4.2). However, we
4
assume that in general users would want denesting to b e discovered .
Another reason for denesting is reliable simpli cation.For b oth p eople and
computers, there is a danger that the result of a mathematical simpli cation will
dep end up on the order in which rules are applied. For example, the simpli cation
q
p
2
of (1 2) can pro ceed twoways. The rst way is called `top-down' bythose
who think of the expression as a tree, and `outside to middle' by those who lo ok
p
2
x = jxj at the printed form. Following this pro cedure, one applies rst the rule
q
p p
2
for any real x, and obtains (1 2) = 2 1. The other way is `b ottom-up' or
p
p
`middle outwards', in which one expands the square and obtains 3 2 2. Without
denesting, the simpli cation will not pro ceed any further. Thus two p eople using the
same CAS to solve the same problem could arrive at apparently di erent answers, and
5
this is what we wish to avoid .
A nal reason is a small improvement in the accuracy of the numerical evaluation
of some radical expressions. For example, the quantity
q
p
199999 600 111110 0:00158
approximates to zero if 10 decimal digits of precision are used, and only at 15 digits
p p
10 3 11111 is the expression found to b e nonzero; in contrast, the equivalent 100
approximates to 0:00158 using just 7 digits of precision.
4.3 Where do nested radicals arise?
Older algebra textb o oks contain explicit problems on nested radicals, for example,
the b o oks by Chrystal [Chrystal64] and Hall & Knight [Hall88], which are b oth 19th
century b o oks (the 1964 date on the Chrystal citation is not indicative of the age of
the b o ok, whose rst edition was published in 1886). Clearly, users could challenge
a computer system with problems from such b o oks, but there are other sources of
problems. Even if users do not delib erately p ose denesting problems, the problems
they do p ose can generate subproblems that contain nested radicals.
Many problems in mathematics have solutions expressed as standard formulae.
For example, all students learn quite early in their studies the formula for solving
a quadratic equation; not surprisingly, it is programmed into most CAS. Consider
what happ ens when that formula is used for the problem
p
2
x +6x 4 5= 0 :
The standard formula gives
q
p
9+4 5 ; x = 3
4
Long after ordinary text was set mechanically, mathematical equations were still set by
hand. Long horizontal lines, as in large fractions or large ro ots, were troublesome for the
comp ositors, and authors of mathematicswere encouraged to prefer forms that reduced
the need for such lines. Perhaps nowthatwehaveT X to set these expressions easily,our
E
mathematical tastes with resp ect to simplicity will change also.
5
Not to mention all the phone calls to technical supp ort.
From Computer Algebra Systems: A Practical Guide, M.J. Wester, Ed., Wiley 1999.
64 COMPUTER ALGEBRA SYSTEMS: A PRACTICAL GUIDE
p p
but in fact the quadratic can b e factored as (x +1 5)(x +5+ 5). Therefore the
general formula is correct, but do es not directly give the simplest result in this sp ecial
case. The problem is an interesting one to try on humans, as well as computer systems.
2
Now consider the formula, valid for real a; b with b>a ,
Z
2x + a 1 1
p p
arctan : (4.7) dx =
2
2 2
4x +4ax + b
2 b a b a
p
If we substitute a =2 and b = 7+2 2, we nd that (4.7) b ecomes
Z
1 1 2x +2
p p p
dx = arctan :
p p
2
4x +8x + 7+2 2
2 3+2 2 3+ 2 2
As example (4.1) shows, however, the nested radicals on the right-hand side can b e
p
2
b a must remain simpli ed. Of course, for most values of a and b, the term
unsimpli ed.
4.4 Developing algorithms
In the next section, we shall give algorithms for simplifying nested radicals, but it is
worthwhile rst to make a few general comments. Every description of an algorithm
should sp ecify the class of problems to which it applies, which in turn requires that we
decide which problems we are going to tackle. As a rule of thumb, the more general
our class of problems, the larger and slower our algorithm is likely to b e. In general,
system develop ers identify the most frequently o ccurring cases and concentrate rst
on them.
The simpli cation of radicals has b een the sub ject of several recentstudies
[Landau92b, Landau92a, Zipp el85], but these studies havetaken general approaches
to the problem, with the algorithms they derive b eing corresp ondingly lengthy.Here
we consider algorithms of restricted applicability, handling only commonly o ccurring
cases, and gain brevity at the price of generality. Sp eci cally, the algorithms given
here do not address example (4.6) ab ove.
A second comp onent in the sp eci cation of an algorithm is the form the answer will
take. In this context, we observe that approximating a nested radical as a decimal
fraction is certainly a typ e of simpli cation, but not one in whichwe are interested.
The p ossibility that di erent mathematicians will de ne simpli cation di erently was
p ointed out ab ove, and that will certainly in uence the form in which a simpli cation
is sought. Here we shall takeitthatwe aim to reduce the level of nesting, that we
require exact results and that the result will also b e expressed as a radical.
4.5 The algorithms
We b egin with a short treatment of a simple case, and then pro ceed to the main case,
which requires a longer study.
From Computer Algebra Systems: A Practical Guide, M.J. Wester, Ed., Wiley 1999.
SIMPLIFYING SQUARE ROOTS OF SQUARE ROOTS BY DENESTING 65
4.5.1 Squareroot of a three-term sum
Equation (4.5) can b e generalized to the pattern
p
2 2
a 2ab + b = ja bj ; (4.8)
where either a or b is a surd other than a square ro ot (i.e., so that the corresp onding
squared term is still a surd). The obvious starting p oint for detecting this pattern is
the fact that there are 3 terms under the square ro ot, although it must b e realised
that, in general, we shall not know the order in which the terms app ear. For example,
p
p p p
3 3 3
4+ 81 + 4 9= 2+ 9 , the rst term under the square in the case of the problem
p
p p p p
3 3 3 3
2
ro ot corresp onds to a .However, in the similar lo oking 6+ 81 + 9= 3+ 9,
the rst term corresp onds to 2ab.
p
So the question is: given X + Y + Z , do there exist a and b such that X , Y ,
2 2
Z corresp ond in some order to a , b and 2ab?We can supp ose that the problem
has b een formulated in suchaway that we know that X + Y + Z>0. One might
think of analysing the structure of the 3 terms, but this could b e a lengthy op eration
2 2
for a CAS. A quicker way to pro ceed is to notice that if X = a and Y = b ,then
2 2 2 2 2
4XY =4a b =(2ab) = Z . So the system can test 4XY Z for zero, and then
p p
return X +sgnZ Y . The signum function takes care of the p ossibility, and the
absolute-value signs take care of the p ossibility that Y>X. In the same way,wecan
2 2
test 4XZ Y and 4YZ X . Some nal things to notice ab out this pro cedure are
the simplicity of the failure condition | we give up if all test quantities are nonzero
| and the fact that there is no obvious path to generalize it to encompass a wider
class of problems.
4.5.2 Squareroot of squareroots
Examples (4.1)|(4.3) show that an imp ortant pattern to consider is
p p
p
X + Y = A + B: (4.9)
We need to nd A; B in terms of X; Y , and we need the circumstances in whichthe
right-hand side is simpler than the left. Squaring b oth sides gives us
p
AB : (4.10) X + Y = A + B +2
2
One way to satisfy this equation is to set X = A + B and Y =4AB .Now if (4.9) is
valid, then it should also b e true that
p p
p
X Y = A B: (4.11)
p
2 2