# Heuristic package to denest radicals

**URL:** <https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753>\
**Category:** Staff Picks\
**Tags:** computer-science, wolfram-add-ons, algebra, packages-and-paclets, symbolic-computations, computer-based-maths, staff-pick, mathematics-and-foundations\
**Created:** [December 13, 2016, 5:39pm UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753 "2016-12-13T17:39:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwmgosper](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rwmgosper/32/35760_2.png) [@rwmgosper](https://community.wolfram.com/u/rwmgosper)\
**Post date:** [December 13, 2016, 5:39pm UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753/1 "2016-12-13T17:39:45Z")

</div>

_NOTE: package and examples notebooks are attached at the end of this post_

* * *

If you square a surd, and then take the square root, you just get it back. But how do you take the ? if you expand it after you square it?

 ![ScreenShot2016-12-13at11.02.59AM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/d/6de69c6a4e2a421908a65f1201535bf229f4c376.png)

Sometimes FullSimplify is smart enough:

![ScreenShot2016-12-13at11.05.03AM.png](https://global.discourse-cdn.com/wolfram/original/3X/0/7/071b2b05a238b2c2d5e59f9397be4f43686fdb23.png)

Usually, it isnt:

 ![ScreenShot2016-12-13at11.11.57AM.png](https://global.discourse-cdn.com/wolfram/original/2X/f/ff95efe65fa7e80cb8f53281eef5b27153d74e8a.png)

![ScreenShot2016-12-13at11.13.18AM.png](https://global.discourse-cdn.com/wolfram/original/2X/7/705585faa05f99798a71ba00b5f5c9be5fbe6561.png)

Corey Ziegler Hunts wrote a big heuristic package to **denest** radicals:

![ScreenShot2016-12-13at11.15.04AM.png](https://global.discourse-cdn.com/wolfram/original/2X/e/e9ea74b952899467f21eb58ca9ae958df14e1060.png)

(Why Strad?) But usually radicals dont **denest** :

![ScreenShot2016-12-13at11.18.09AM.png](https://global.discourse-cdn.com/wolfram/original/3X/f/5/f5f9ce4b28a378c0b8b31a4bee5b09d4baa4fe43.png)

When they do, the result can be startling:

 ![ScreenShot2016-12-13at11.21.46AM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/5/659bfe32cd7b041f5900898bb97bea0d58fd9b4c.png)

Can this be right?

![ScreenShot2016-12-13at11.23.18AM.png](https://global.discourse-cdn.com/wolfram/original/3X/8/3/83ea2549251d11caedbb502fded4ade02b4ec820.png)

Yep. Hopefully this will be obsoleted by Mathematica’s developers. But maybe not. I confess near total ignorance of Galois theory, which underlies all the **denesting** papers. But those papers never exhibit any cool new **denestings**! SAGE and Maple are rumored to **denest** , but again, where are goodies like

 ![ScreenShot2016-12-13at11.30.09AM.png](https://global.discourse-cdn.com/wolfram/original/2X/c/c45f530db2355ce2d75bcd5935df8f9a1b512f86.png)

There are some issues. If there is no **denesting** , it can take infeasibly long to give up. And it doesn’t listify. It misconstrues lists.

Illustrating the widespread underuse of denesting, [Theta Function](https://en.wikipedia.org/wiki/Theta_function) gives:

 ![ScreenShot2016-12-13at3.28.43PM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/4/6465185298bbb7a3d2698555e6b13eb3eeaf08e6.png)

![ScreenShot2016-12-13at3.32.31PM.png](https://global.discourse-cdn.com/wolfram/original/2X/5/5ad0952373cedf30ff6b7ef79cde7cc2f57d5906.png)

Tsk.

 ![ScreenShot2016-12-13at3.35.03PM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/2/621db4d8dac03a6c8edd2e87adbfb1c855ccb933.png)

Is it possible for the nth root of a real binomial to denest to more than five terms? I’ve never seen one.

---

<div class="post-metadata">

**Author:** ![vreshetnikov](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vreshetnikov/32/8768_2.png) [@vreshetnikov](https://community.wolfram.com/u/vreshetnikov)\
**Post date:** [December 16, 2016, 9:42pm UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753/2 "2016-12-16T21:42:32Z")

</div>

Dear Bill,

This is an amazing package! What license have you published it under? May I use it and derivative work in my open source projects?

---

<div class="post-metadata">

**Author:** ![vaungureanu](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vaungureanu/32/23129_2.png) [@vaungureanu](https://community.wolfram.com/u/vaungureanu)\
**Post date:** [December 17, 2016, 10:26am UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753/3 "2016-12-17T10:26:45Z")

</div>

What about applying PowerExpand?

```
In[2]:= Sqrt[PowerExpand[(Sqrt[2] - 1)^2]]

Out[2]= -1 + Sqrt[2]

In[3]:= Sqrt[PowerExpand[(Sqrt[3] - Sqrt[2])^2]]

Out[3]= -Sqrt[2] + Sqrt[3]

```

 ![radicals.png](https://global.discourse-cdn.com/wolfram/original/2X/e/e4cb492285f67b659fe7aa0db9869338dc417cf3.png)

---

<div class="post-metadata">

**Author:** ![rwmgosper](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rwmgosper/32/35760_2.png) [@rwmgosper](https://community.wolfram.com/u/rwmgosper)\
**Post date:** [December 30, 2016, 6:19pm UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753/4 "2016-12-30T18:19:10Z")

</div>

Vladimir: Sorry to have only now seen your query. License? Corey wrote this years ago while of highschool age, and appears to lack further interest in it. He has moved on from mathematics ([Minskys & Trinskys 3rd Edition by Julian & Corey Ziegler Hunts, R.W. Gosper & Jack Holloway | Blurb Books](http://www.blurb.com/b/2172660-minskys-trinskys-3rd-edition)) to software engineering. I believe his chief concern with this package is not to be contacted when someone finds a bug! --Bill

---

<div class="post-metadata">

**Author:** ![rwmgosper](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rwmgosper/32/35760_2.png) [@rwmgosper](https://community.wolfram.com/u/rwmgosper)\
**Post date:** [December 30, 2016, 6:38pm UTC](https://community.wolfram.com/t/heuristic-package-to-denest-radicals/9753/5 "2016-12-30T18:38:25Z")

</div>

Dear Valeriu: PowerExpand has no effect here–you could replace it by Identity. And replacing it with Expand has the exact opposite effect of what Strad (and its verbose cousin DenestRadicals3)

In[491]:= Sqrt[Expand[(Sqrt[3] - Sqrt[2])^2]]

Out[491]= Sqrt[5 - 2 Sqrt[6]]

In[492]:= DenestRadicals3@%

During evaluation of In[492]:= {f[Sqrt[5-2 Sqrt[6]]]}

During evaluation of In[492]:=

During evaluation of In[492]:= problem Sqrt[5-2 Sqrt[6]]

During evaluation of In[492]:= outer root: 2 extra root: 1

During evaluation of In[492]:=

During evaluation of In[492]:= multiplier count: 2 multipliers: {1,Sqrt[6]}

During evaluation of In[492]:= multiplier: 1 minpoly degree: 4

During evaluation of In[492]:= adding new multipliers from: 1

During evaluation of In[492]:= multiplier: Sqrt[6] minpoly degree: 4

During evaluation of In[492]:= adding new multipliers from: Sqrt[6]

During evaluation of In[492]:= multiplier count: 3 from: {1,4}

During evaluation of In[492]:= multiplier: 2 minpoly degree: 2

During evaluation of In[492]:= success: {2,2,{{2,1}}}

During evaluation of In[492]:= history: {{0,[Infinity]},{1,4},{2,2}}

During evaluation of In[492]:= -Sqrt[2]+Sqrt[3]

During evaluation of In[492]:=

Out[492]= -Sqrt[2] + Sqrt[3]

are trying to achieve, namely, to convert the radicand back into a power that cancels the root operation.  
So I don’t understand the objective of PowerExpand here. --Bill
