ToNumberField won't recognize Root as an explicit algebraic number - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-08-18T02:04:05Z https://mathematica.stackexchange.com/feeds/question/23908 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://mathematica.stackexchange.com/q/23908 13 ToNumberField won't recognize Root as an explicit algebraic number Tobias Hagge https://mathematica.stackexchange.com/users/5523 2013-04-24T00:34:34Z 2015-07-22T22:33:00Z <p><strong>Bug fixed in 10.0.0</strong></p> <hr> <p>In <em>Mathematica 9.0.1</em>, it appears that <code>ToNumberField</code> will not always recognize a <code>Root</code> object as an explicit algebraic number.</p> <pre><code>ToNumberField[ Root[{ 1 - #1 + #1^2 - #1^3 + #1^4 - #1^5 + #1^6 &amp;, #1^5 + #1^3 #2 + #1 #2^2 + #2^3 - #1 #2^3 + #1^2 #2^3 - #1^3 #2^3 + #1^4 #2^3 - #1^5 #2^3 - #1^4 #2^4 - #1^2 #2^5 - #2^6 &amp;}, {6, 6}] ] </code></pre> <blockquote> <pre><code>ToNumberField::nalg: "Root[{1 -#1 + #1^2 - #1^3 + #1^4 - #1^5 + #1^6&amp;, #1^5 + #1^3 #2 + #1 #2^2 + #2^3 - #1 #2^3 + #1^2 #2^3 -#1^3 #2^3 + #1^4 #2^3 - #1^5 #2^3 - #1^4 #2^4 - #1^2 #2^5 - #2^6 &amp;}, {6,6}] is not an explicit algebraic number. &gt;&gt;" </code></pre> </blockquote> <p>A different root of the same polynomial works just fine:</p> <pre><code>ToNumberField[ Root[{1 - #1 + #1^2 - #1^3 + #1^4 - #1^5 + #1^6 &amp;, #1^5 + #1^3 #2 + #1 #2^2 + #2^3 - #1 #2^3 + #1^2 #2^3 - #1^3 #2^3 + #1^4 #2^3 - #1^5 #2^3 - #1^4 #2^4 - #1^2 #2^5 - #2^6 &amp;}, {6, 1}] ] </code></pre> <blockquote> <pre><code>AlgebraicNumber[Root[1 + #1 + #1^2 + #1^3 + #1^4 + #1^5 + #1^6 &amp;, 2], {0, 1, 0, 0, 0, 0}] </code></pre> </blockquote> <p>Is this a bug, and is there any way I can work around it?</p> <p><strong>Edit</strong>: In case it matters, that first <code>Root</code> expression will <code>FullSimplify</code> to <code>1</code>.</p> https://mathematica.stackexchange.com/questions/23908/-/23992#23992 17 Answer by Adam Strzebonski for ToNumberField won't recognize Root as an explicit algebraic number Adam Strzebonski https://mathematica.stackexchange.com/users/6258 2013-04-24T23:52:35Z 2013-12-15T19:39:32Z <p>This is caused by a bug in <code>RootReduce</code> for <code>Root</code> objects representing last coordinates of solutions of triangular systems. The bug affects cases where the last coordinate of the solution is real, but some of the other coordinates are not real. Thanks for pointing it out. </p> <p>The problem can be fixed with the following patch (you can put it in your <code>init.m</code> file).</p> <pre><code>rootReduceFix[r:Root[fs_List, ks_List]] := Module[{X, vars, polys, rts, nr, prec=20}, vars = X /@ Range[ Length[fs]]; polys = # @@ vars&amp; /@ fs; res = Last[polys]; Do[ res = Resultant[ res, polys[[i]], vars[[i]]]; res = Times @@ (First /@ FactorSquareFreeList[res]), {i, Length[polys] - 1, 1, -1}]; rts = Last[vars]/.Solve[ res==0, Last[vars]]; While[ Length[rts] != 1, nr = N[r, prec]; rts = Select[ rts, # - nr == 0&amp;]; prec*=2]; First[rts]] problemRootQ[r_] := Head[r] === Root &amp;&amp; Length[r] == 2 &amp;&amp; ListQ[r[]] &amp;&amp; (Head[#] === Complex &amp;&amp; Im[#] == 0 &amp;[N[r]]) rootReduceFixFlag = True; Unprotect /@ { RootReduce, ToNumberField}; RootReduce[e_] /; rootReduceFixFlag := Block[{ rootReduceFixFlag=False}, RootReduce[ e/.(r_?problemRootQ) :&gt; rootReduceFix[r]]] ToNumberField[args__] /; rootReduceFixFlag := Block[{ rootReduceFixFlag = False}, ToNumberField @@ ( {args}/.(r_?problemRootQ) :&gt; rootReduceFix[r])] Protect /@ { RootReduce, ToNumberField}; </code></pre>