{"id":9,"date":"2016-09-22T18:51:18","date_gmt":"2016-09-22T18:51:18","guid":{"rendered":"http:\/\/keithmellinger.com\/magma\/?page_id=9"},"modified":"2016-11-03T19:36:41","modified_gmt":"2016-11-03T19:36:41","slug":"basic-set-manipulation","status":"publish","type":"page","link":"https:\/\/keithmellinger.com\/magma\/basic-set-manipulation\/","title":{"rendered":"Basic Set Manipulation"},"content":{"rendered":"<p>It\u2019s not uncommon to ask students to compute small examples of groups, ring or fields, and then find specific elements in that structure to help understand characteristics. <em>Magma<\/em> always keeps track of where the elements live and calls that set the Parent. Let\u2019s use some basic <em>Magma<\/em> commands to explore this a bit.<\/p>\n<p>Let\u2019s create a set by listing its elements explicitly.<\/p>\n<p><code>&gt; S := { (7^2+1)\/5, (8^2+1)\/5, (9^2-1)\/5 };<br \/>\n&gt; S;<br \/>\n{ 10, 13, 16 }<br \/>\n&gt; Parent(S);<br \/>\nSet of subsets of Rational Field<\/code><\/p>\n<p>Thus <em>S<\/em> was created as a set of rationals, because the operation \u201c\/\u201d on integers has a rational result. If one wishes to obtain a set of integers, one could specify the universe (or one could use <code>div<\/code>). Also, one could use <code>!<\/code> on every element to coerce it into the ring of integers. When you type <code>P!x<\/code>, you are telling <em>Magma<\/em> to think of <em>x<\/em> as being an element of <em>P<\/em>.<\/p>\n<p><code>&gt; T := { Integers() | (7^2+1)\/5, (8^2+1)\/5, (9^2-1)\/5 };<br \/>\n&gt; T;<br \/>\n{ 10, 13, 16 }<br \/>\n&gt; Parent(T);<br \/>\nSet of subsets of Integer Ring<\/code><\/p>\n<p>If you want the set of integers, you use <code>Integers()<\/code>. But that command is more general. Using <code>Integers(n)<\/code> creates the ring of residue classes of integers modulo <em>n<\/em>. Let\u2019s look the group Z<sub>12<\/sub> and see which elements are squares and which are cubes.<\/p>\n<p><code>&gt; Z12 := Integers(12);<br \/>\n&gt; Z12;<br \/>\nResidue class ring of integers modulo 12<br \/>\n&gt; Squares := { x^2 : x in Z12 };<br \/>\n&gt; Cubes := { x^3 : x in Z12 };<br \/>\n&gt; Squares;<br \/>\n{ 0, 1, 4, 9 }<br \/>\n&gt; Cubes;<br \/>\n{ 0, 11, 1, 3, 4, 5, 7, 8, 9 }<\/code><\/p>\n<p>So, it appears that all of the squares are also cubes. We can confirm this using the <em>Magma<\/em> command <code>meet<\/code> which computes a set intersection.<\/p>\n<p><code>&gt; Squares meet Cubes eq Squares;<br \/>\ntrue<\/code><\/p>\n<p>The union command in <em>Magma<\/em> is <code>join<\/code>.<\/p>\n<p><code>&gt; Squares join Cubes;<br \/>\n{ 0, 11, 1, 3, 4, 5, 7, 8, 9 }<\/code><\/p>\n<p>Suppose you want to know if there is some element which squares to 1, but is not equal to 1. We could compute via brute force:<\/p>\n<p><code>&gt; S := { x^2 : x in Z12 | x ne 1};<br \/>\n&gt; S;<br \/>\n{ 0, 1, 4, 9 }<\/code><\/p>\n<p>So it looks like there is some other element out there that squares to 1.\u00a0 Can you figure it out?\u00a0 Is there more than one of them?<\/p>\n<p>Finally, if you try to do set computations with something that <em>Magma<\/em> considers to be an algebraic object, you\u2019ll get an error. Suppose we want to compute which elements of Z<sub>12<\/sub> are not cubes. One might try this:<\/p>\n<p><code>&gt; Z12 diff Cubes;<\/code><\/p>\n<p><code>&gt;&gt; Z12 diff Cubes;<br \/>\n^<br \/>\nRuntime error in 'diff': Bad argument types<br \/>\nArgument types given: RngIntRes, SetEnum[RngIntResElt]<\/code><\/p>\n<p>Instead, we need to first tell Magma to think of the algebraic structure <code>Z12<\/code> as a set. Then we can compute the set difference:<\/p>\n<p><code>&gt; Set(Z12) diff Cubes;<br \/>\n{ 2, 6, 10 }<\/code><\/p>\n<p><strong><em>Exercise:<\/em><\/strong> The Magma command for a finite field is GF(<em>q<\/em>) where <em>q<\/em> is the order of the field. So, the command <code>F := GF(8)<\/code> will let F be the field with 8 elements.<\/p>\n<ol>\n<li>Create the field with 7 elements, compute the set of non-zero squares and the set of non-squares. Check that these sets have the same size.<\/li>\n<li>Create the field with 8 elements and check that every element is a square.<\/li>\n<li>Find an element <em>x<\/em> of GF(23) such that <em>x<\/em> is a square and <em>x<\/em>+1 is also a square.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s not uncommon to ask students to compute small examples of groups, ring or fields, and then find specific elements in that structure to help understand characteristics. Magma always keeps track of where the elements live and calls that set the Parent. Let\u2019s use some basic Magma commands to explore this a bit. Let\u2019s create &hellip; <a href=\"https:\/\/keithmellinger.com\/magma\/basic-set-manipulation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Basic Set Manipulation<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-9","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/pages\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":14,"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/pages\/9\/revisions"}],"predecessor-version":[{"id":56,"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/pages\/9\/revisions\/56"}],"wp:attachment":[{"href":"https:\/\/keithmellinger.com\/magma\/wp-json\/wp\/v2\/media?parent=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}