How to Simplify equations over a Ring with Mathematica? - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-08-18T02:02:33Z https://mathematica.stackexchange.com/feeds/question/7082 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://mathematica.stackexchange.com/q/7082 7 How to Simplify equations over a Ring with Mathematica? Osiris Xu https://mathematica.stackexchange.com/users/333 2012-06-19T22:21:34Z 2012-06-26T12:22:02Z <p>For example, when we work over a ring, the equation <code>x^3=0</code> does not imply <code>x^2=0</code> or <code>x=0</code>, but the vice versa is true. Can we use Mathematica to Simplify equations over a ring?</p> https://mathematica.stackexchange.com/questions/7082/-/7084#7084 8 Answer by Artes for How to Simplify equations over a Ring with Mathematica? Artes https://mathematica.stackexchange.com/users/184 2012-06-19T22:35:44Z 2012-06-26T12:22:02Z <p>If you want to solve an equation over integer rings \$\mathbb{Z}_n\$ you should specify them with <code>Modulus</code> e.g. </p> <pre><code>Column[Solve[x^3 == 0, x, Modulus -&gt; #] &amp; /@ Range[2, 9]] </code></pre> <p><img src="https://i.stack.imgur.com/uVIf3.gif" alt="enter image description here"></p> <p><strong>Edit</strong></p> <p>Since there was no further example of any expression to simplify over a finite ring let's define e.g. a polynomial which cannot be factorized over rationals (as <code>Mathematica</code> does by default)</p> <pre><code>p[x_] := x^5 + 3 x^4 + 6 x^3 - 2 x^2 + 1 Factor[p[x]] p /@ Range </code></pre> <blockquote> <pre><code>1 - 2 x^2 + 6 x^3 + 3 x^4 + x^5 {9, 121, 631, 2145, 5701} </code></pre> </blockquote> <p>however over rings \$\mathbb{Z}_n\$ it is evaluated automatically with <code>Mod[ p[x], n]</code>, (it has the <code>Listable</code> attribute), thus</p> <pre><code>Column[ Mod[p /@ Range[2, 10], #] &amp; /@ Range[2, 10]] </code></pre> <blockquote> <pre><code> {{{1, 1, 1, 1, 1, 1, 1, 1, 1}}, {{1, 1, 0, 1, 1, 0, 1, 1, 0}}, {{1, 3, 1, 1, 1, 3, 1, 1, 1}}, {{1, 1, 0, 1, 4, 1, 1, 0, 1}}, {{1, 1, 3, 1, 1, 3, 1, 1, 3}}, {{2, 1, 3, 3, 2, 1, 2, 2, 1}}, {{1, 7, 1, 5, 1, 3, 1, 1, 1}}, {{4, 1, 3, 4, 1, 6, 4, 1, 0}}, {{1, 1, 5, 1, 9, 1, 1, 5, 1}} } </code></pre> </blockquote> <p>On the other hand you can use <code>PolynomialMod</code> to "simplify" a polynomial over a ring \$\mathbb{Z}_n\$, e.g.</p> <pre><code>Column[ PolynomialMod[ p[x], #] &amp; /@ Range[2, 6] ] </code></pre> <blockquote> <pre><code>1 + x^4 + x^5 1 + x^2 + x^5 1 + 2 x^2 + 2 x^3 + 3 x^4 + x^5 1 + 3 x^2 + x^3 + 3 x^4 + x^5 1 + 4 x^2 + 3 x^4 + x^5 </code></pre> </blockquote> <p>So to get the table <code>Column[ Mod[p /@ Range[2, 10], #] &amp; /@ Range[2, 10]]</code> as above, you can <code>Apply</code> as well <code>PolynomialMod</code> on a specific level of an adequate <code>Table</code>, e.g. </p> <pre><code>Column[ Apply[ PolynomialMod[ p[#2], #1] &amp;, Table[{i, j}, {i, 2, 10}, {j, 2, 10}], {2}] ] === Column[ Mod[ p /@ Range[2, 10], #] &amp; /@ Range[2, 10]] </code></pre> <blockquote> <pre><code>True </code></pre> </blockquote> <p>In case you'd like to factorize <code>p[x]</code> over a finite field (for n prime \$\mathbb{Z}_n\$ is a field) it can be done with <code>Modulus</code> as well, e.g. </p> <pre><code>Column[ Factor[ p[x], Modulus -&gt; #] &amp; /@ Prime @ Range] </code></pre> <p><img src="https://i.stack.imgur.com/C67id.gif" alt="enter image description here"></p> <p>Some related details (e.g. <code>Extension</code> to work with polynomials and algebraic functions over rings of <code>Rationals</code> extended by selected algebraic numbers) you could find <a href="https://mathematica.stackexchange.com/questions/4362/factorizing-polynomials-over-fields-other-than-mathbbc/4372#4372">here</a>.</p> <p>Consider another polynomial</p> <pre><code>w[x_] := 6 - 12 x + x^2 - 2 x^3 - x^4 + 2 x^5 </code></pre> <p>you can solve the equation <code>w[x] == 0</code> over the field of <code>Rationals</code> as well (by default <code>Mathematica</code> solves over <code>Complexes</code>, and then you needn't specify the domain), e.g.</p> <pre><code>Column[ Solve[w[x] == 0, x, #] &amp; /@ {Integers, Rationals, Reals, Complexes} ] </code></pre> <p><img src="https://i.stack.imgur.com/LyyCT.gif" alt="enter image description here"></p> <p>You could factorize completely this polynomial with <code>Extension</code> : </p> <pre><code>Factor[ w[x]] Factor[ w[x], Extension -&gt; {Sqrt, Sqrt, I}] </code></pre> <p><img src="https://i.stack.imgur.com/iDXVN.gif" alt="enter image description here"></p> <p>There is also a package <a href="https://sites.google.com/site/eaamhl/abstractalgebra/capabilities" rel="nofollow noreferrer">AbstractAlgebra</a> to work with adequate algebraic concepts and a related book <a href="https://sites.google.com/site/eaamhl/eaam" rel="nofollow noreferrer">Exploring Abstract Algebra with Mathematica</a>. </p>