{"id":2983,"date":"2023-11-26T14:49:07","date_gmt":"2023-11-26T20:49:07","guid":{"rendered":"http:\/\/www.ishygddt.xyz\/~blog\/?p=2983"},"modified":"2025-06-22T18:56:24","modified_gmt":"2025-06-22T23:56:24","slug":"galois-fields-explained-simply","status":"publish","type":"post","link":"http:\/\/www.ishygddt.xyz\/~blog\/2023\/11\/galois-fields-explained-simply","title":{"rendered":"[DRAFT] Finite fields for mortal comprehension"},"content":{"rendered":"<p>So you've got the \u201cnatural numbers\u201d, <span lang=\"x-mathjax\">$\\mathbb{N}=\\left\\{0, 1, 2, \\dots\\right\\}$<\/span>. Or the \u201ccounting numbers\u201d, or whatever you want to call them.<\/p>\n<p>Addition works, and multiplication works. <strong>But<\/strong> subtraction is broken, because there isn't any natural number equal to <span lang=\"x-mathjax\">$2-3$<\/span>.<\/p>\n<p>We might think about fixing subtraction, and <em>one<\/em> way of doing this is by moving to the integers, which allows negative numbers: <span lang=\"x-mathjax\">$\\mathbb{Z}=\\left\\{\\dots, -2, -1, 0, 1, 2, \\dots\\right\\}$<\/span>.<\/p>\n<p>But that still leaves division broken\u2014there isn't any integer equal to <span lang=\"x-mathjax\">$3 \\div 4$<\/span>!<\/p>\n<p>One path forward is to move over to the rational numbers: <span lang=\"x-mathjax\">$\\mathbb{Q}=\\text{\u201cProper Fractions\u201d}$<\/span>. This fixes division and subtraction at the same time. But\u2026 this path forward locks us into an infinitely large set. Sometimes (especially in cryptography) it's useful to have a smaller set of numbers that you can actually do ALL the math on.<\/p>\n<p>The official word for \u201ca set of numbers you can do all the math on\u201d is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Field_(mathematics)\">field<\/a>. For example, <span lang=\"x-mathjax\">$\\mathbb{Q}$<\/span> is a field. But (obviously) there are infinitely many fractions, so it's an infinite field. Today you're going to learn about <strong>finite<\/strong> fields\u2014which are exactly what they say on the tin. They're sometimes called \u201cGalois fields\u201d (gal'waah fields). They're used in almost all cryptographic algorithms. (They probably have other uses, too. [TODO look this up])<\/p>\n<p>However, building these is a bit complicated. I'll need to explain 3 ideas first.<\/p>\n<h2>Idea #1: Modular arithmetic: <span lang=\"x-mathjax\">$\\mathbb{Z}_n$<\/span><\/h2>\n<p>One popular starting block for thinking about smaller universes of numbers is <strong>modular arithmetic<\/strong>. It starts out just like the natural numbers, but when you're about to reach the limit\u2014the \u201cmodulus\u201d\u2014the numbers loop back around to 0. Also, if you try to go back below 0, you get sent up to the highest number. This gives you a miniature \u201ctoy version\u201d of the integers that you can do math on without having to worry about looking infinity in the eye! (The way that galaxy-brained mathematicians think of this is \u201cthe <a href=\"https:\/\/en.wikipedia.org\/wiki\/Equivalence_class#quotient_set\">quotient set<\/a> of the integers, using the remainder of division by the modulus as the equivalence operator\u201d\u2014but you <em>absolutely don't<\/em> need to learn about that to get a basic understanding of how modular arithmetic works.)<\/p>\n<p>Now, no matter what modulus you pick (as long as it's an integer <span lang=\"x-mathjax\">$\\ge 2$<\/span>), addition works great, and multiplication at least kinda works. (Subtraction works perfectly, too; but I'll leave that as an exercise for the reader, since it doesn't matter for what we're doing today.)<\/p>\n<p>For example, here's <strong>the integers modulo 8<\/strong>, which I'll write as <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span> (colored indigo so you can tell the modular integers from this \u201cminiature universe\u201d apart from regular integers):<\/p>\n<p><strong>Addition in <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} + &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} \\\\ \\hline \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} \\\\ \\hline \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} \\\\ \\hline \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} \\\\ \\hline \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} \\\\ \\hline \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} \\\\ \\hline \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} \\\\ \\hline \\end{array}$$<\/div>\n<p>Notice that (for example) <span lang=\"x-mathjax\">$\\textcolor{indigo}{6} + \\textcolor{indigo}{2} = \\textcolor{indigo}{0}$<\/span>, because <span lang=\"x-mathjax\">$6 + 2 = 8$<\/span>, which wraps back around to <span lang=\"x-mathjax\">$8-8 = \\textcolor{indigo}{0}$<\/span>!<\/p>\n<p><strong>Multiplication in <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} \\times &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{6} \\\\ \\hline \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{5} \\\\ \\hline \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{4} \\\\ \\hline \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{3} \\\\ \\hline \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{0} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{2} \\\\ \\hline \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p>Again using the \u201cwrap-around arithmetic\u201d, notice that <span lang=\"x-mathjax\">$\\textcolor{indigo}{3} \\times \\textcolor{indigo}{5} = \\textcolor{indigo}{7}$<\/span>, because <span lang=\"x-mathjax\">$3 \\times 5 = 15$<\/span>, which wraps back around to <span lang=\"x-mathjax\">$15-8 = \\textcolor{indigo}{7}$<\/span>.<\/p>\n<p>However, if you look carefully, you'll also see that <span lang=\"x-mathjax\">$\\textcolor{indigo}{4} \\times \\textcolor{indigo}{6} = \\textcolor{indigo}{0}$<\/span>\u2014that is, two things, neither of which is <span lang=\"x-mathjax\">$\\textcolor{indigo}{0}$<\/span>, multiply to produce <span lang=\"x-mathjax\">$\\textcolor{indigo}{0}$<\/span>! This a perverse result, and the fact that it happens means your division tables will <em>necessarily<\/em> be totally ruined:<\/p>\n<p><strong>\"Division\" in <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} \\div &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{1} &amp; \u2007 &amp; \\textcolor{indigo}{3} &amp; \u2007 &amp; \\textcolor{indigo}{5} &amp; \u2007 &amp; \\textcolor{indigo}{7} \\\\ \\hline \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{2} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{6} &amp; \u2007 &amp; \\textcolor{indigo}{2} &amp; \u2007 &amp; \\textcolor{indigo}{6} \\\\ \\hline \\textcolor{indigo}{3} &amp; \\textcolor{indigo}{3} &amp; \u2007 &amp; \\textcolor{indigo}{1} &amp; \u2007 &amp; \\textcolor{indigo}{7} &amp; \u2007 &amp; \\textcolor{indigo}{5} \\\\ \\hline \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{4} &amp; \u2007 &amp; \\textcolor{indigo}{4} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{4} &amp; \u2007 &amp; \\textcolor{indigo}{4} \\\\ \\hline \\textcolor{indigo}{5} &amp; \\textcolor{indigo}{5} &amp; \u2007 &amp; \\textcolor{indigo}{7} &amp; \u2007 &amp; \\textcolor{indigo}{1} &amp; \u2007 &amp; \\textcolor{indigo}{3} \\\\ \\hline \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{6} &amp; \u2007 &amp; \\textcolor{indigo}{2} &amp; \u2007 &amp; \\textcolor{indigo}{6} &amp; \\textcolor{indigo}{1} &amp; \\textcolor{indigo}{2} \\\\ \\hline \\textcolor{indigo}{7} &amp; \\textcolor{indigo}{7} &amp; \u2007 &amp; \\textcolor{indigo}{5} &amp; \u2007 &amp; \\textcolor{indigo}{3} &amp; \u2007 &amp; \\textcolor{indigo}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p>Joking aside, the technical reason the division table is ruined is that <span lang=\"x-mathjax\">$\\textcolor{indigo}{2}$<\/span>, <span lang=\"x-mathjax\">$\\textcolor{indigo}{4}$<\/span>, and <span lang=\"x-mathjax\">$\\textcolor{indigo}{6}$<\/span> don't have any multiplicative inverse in <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span>\u2014that is, there <em>isn't any<\/em> solution to \u201c<span lang=\"x-mathjax\">$\\textcolor{indigo}{2} \\times \\textcolor{indigo}{\\text{?}} = \\textcolor{indigo}{1}$<\/span>\u201d*. Because of that, we say that division <em>just isn't defined<\/em> on <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$<\/span>.<\/p>\n<p>(*Yes, you guessed right: \u201c<span lang=\"x-mathjax\">$\\textcolor{indigo}{4} \\times \\textcolor{indigo}{\\text{?}} = \\textcolor{indigo}{1}$<\/span>\u201d and \u201c<span lang=\"x-mathjax\">$\\textcolor{indigo}{6} \\times \\textcolor{indigo}{\\text{?}} = \\textcolor{indigo}{1}$<\/span>\u201d <em>also<\/em> have no solution. You can double-check this yourself by looking back at the multiplication table and noticing there isn't any <span lang=\"x-mathjax\">$\\textcolor{indigo}{1}$<\/span> to be found in the <span lang=\"x-mathjax\">$\\textcolor{indigo}{2}$<\/span>, <span lang=\"x-mathjax\">$\\textcolor{indigo}{4}$<\/span>, or <span lang=\"x-mathjax\">$\\textcolor{indigo}{6}$<\/span> columns!)<\/p>\n<p>Now, you might ask: can this be fixed? The answer: yes, but it's hard. (But that's what we're here today to do!)<\/p>\n<p>The easy solution is just to give up and instead use a prime number (like 2; 7; or <a href=\"https:\/\/csrc.nist.gov\/files\/pubs\/fips\/186-3\/final\/docs\/fips_186-3.pdf#%5B%7B%22num%22%3A220%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22Fit%22%7D%5D\">6,277,101,735,386,680,763,835,789,423,207,666,416,083,908,700,390,324,961,279<\/a>) as your modulus. Then, multiplication and division will just work right away, without any problem.<\/p>\n<p>The hard solution requires two more ideas before we can start to explain it\u2026 actually, the first of these ideas <em>is<\/em> the easy solution, so let's look into that!<\/p>\n<h2>Idea #2: Finite Fields of prime order (<span lang=\"x-mathjax\">$\\mathbb{F}_p$<\/span>)<\/h2>\n<p>What if we tried to make a modular arithmetic table with <span lang=\"x-mathjax\">$7$<\/span> (which is prime) as the modulus, rather than 8?<\/p>\n<p>Well, I already spoiled it earlier: all the math\u2014including division\u2014will just work. (But let's look at the example anyway!)<\/p>\n<p><strong>Addition in <span lang=\"x-mathjax\">$\\textcolor{teal}{\\mathbb{F}_7}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} + &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{0} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{1} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} \\\\ \\hline \\textcolor{teal}{2} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} \\\\ \\hline \\textcolor{teal}{3} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} \\\\ \\hline \\textcolor{teal}{4} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} \\\\ \\hline \\textcolor{teal}{5} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} \\\\ \\hline \\textcolor{teal}{6} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{0} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} \\\\ \\hline \\end{array}$$<\/div>\n<p>(As you probably expected, nothing to see here; addition never had any problems. Moving along&#8230;)<\/p>\n<p><strong>Multiplication in <span lang=\"x-mathjax\">$\\textcolor{teal}{\\mathbb{F}_7}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} \\times &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{1} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{2} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{5} \\\\ \\hline \\textcolor{teal}{3} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{4} \\\\ \\hline \\textcolor{teal}{4} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{3} \\\\ \\hline \\textcolor{teal}{5} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{2} \\\\ \\hline \\textcolor{teal}{6} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p>Without putting your finger on it, doesn't that table look\u2026 prettier? Tidier? Neater?<\/p>\n<p>OK, now put your finger on it: notice that each column and each row includes each (non-<span lang=\"x-mathjax\">$\\textcolor{teal}{0}$<\/span>) element exactly once! That means that you can turn any (non-<span lang=\"x-mathjax\">$\\textcolor{teal}{0}$<\/span>) element into any other element, just by a single multiplication! And you'll never <em>accidentally<\/em> get <span lang=\"x-mathjax\">$\\textcolor{teal}{0}$<\/span>; the only way to reach it by multiplication is by multiplying by <span lang=\"x-mathjax\">$\\textcolor{teal}{0}$<\/span> <em>on purpose<\/em>. Of course, this means\u2026<\/p>\n<p><strong>Division in <span lang=\"x-mathjax\">$\\textcolor{teal}{\\mathbb{F}_7}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} \\div &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{1} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{6} \\\\ \\hline \\textcolor{teal}{2} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{5} \\\\ \\hline \\textcolor{teal}{3} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{4} \\\\ \\hline \\textcolor{teal}{4} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{3} \\\\ \\hline \\textcolor{teal}{5} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{1} &amp; \\textcolor{teal}{2} \\\\ \\hline \\textcolor{teal}{6} &amp; \\textcolor{teal}{6} &amp; \\textcolor{teal}{3} &amp; \\textcolor{teal}{2} &amp; \\textcolor{teal}{5} &amp; \\textcolor{teal}{4} &amp; \\textcolor{teal}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p>\u2026our division table doesn't have any holes in it\u2014division actually works now!<\/p>\n<p>All this to say that, whenever <span lang=\"x-mathjax\">$p$<\/span> is prime, then <span lang=\"x-mathjax\">$\\mathbb{Z}_p$<\/span> (the integers modulo <span lang=\"x-mathjax\">$p$<\/span>) is just exactly the same thing as <span lang=\"x-mathjax\">$\\mathbb{F}_p$<\/span> (the finite field with <span lang=\"x-mathjax\">$p$<\/span> elements).<\/p>\n<p>Now you know about finite fields with a prime number of elements!<\/p>\n<p>But there are some finite fields with a non-prime number of elements, and we occasionally need those, so let's keep learning until we find out how they work&#8230;<\/p>\n<h2>Idea #3: Polynomial rings<\/h2>\n<h1 style=\"margin-bottom: 50em\">Below here under active construction, don't read further<\/h1>\n<hr \/>\n<p>Now, the mathematicians call a group of numbers that has addition, subtraction, and multiplication that at least kinda works a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ring_(mathematics)\">ring<\/a>. (Rings don't care whether division works. As you might have guessed, <span lang=\"x-mathjax\">$\\textcolor{indigo}{\\mathbb{Z}_8}$ from earlier is a ring.)<\/span><\/p>\n<p>Actually, the elements of the ring don't even have to be numbers. They can be any object. Let's create a ring right now with a ridiculous object in it!<\/p>\n<p>We'll start out with <span lang=\"x-mathjax\">$\\textcolor{olive}{\\mathbb{F}_3}$<\/span> (which is a field, admittedly)\u2014<\/p>\n<p><strong>Addition in <span lang=\"x-mathjax\">$\\textcolor{olive}{\\mathbb{F}_3}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} + &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} \\\\ \\hline \\textcolor{olive}{0} &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} \\\\ \\hline \\textcolor{olive}{1} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{0} \\\\ \\hline \\textcolor{olive}{2} &amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p><strong>Multiplication in <span lang=\"x-mathjax\">$\\textcolor{olive}{\\mathbb{F}_3}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} \\times &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} \\\\ \\hline \\textcolor{olive}{1} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} \\\\ \\hline \\textcolor{olive}{2} &amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{1} \\\\ \\hline \\end{array}$$<\/div>\n<p>and we just throw some garbage in there and say \u201cthis is an element now\u201d\u2014for example, if we added an arbitrary symbol \ud83d\uddff in just to see how the math would cope: <span lang=\"x-mathjax\">${\\textcolor{olive}{\\mathbb{F}_3}}{[{\\text{\ud83d\uddff}}]}$<\/span>.<\/p>\n<p>The good news is: this \u201cadjoinment\u201d does not break addition, subtraction, or multiplication!<\/p>\n<p>The bad news is: it breaks division (which is why the result is called a \u201cring\u201d), <em>and<\/em> it has an infinite amount of elements\u2014<\/p>\n<p><strong>Addition in <span lang=\"x-mathjax\">$\\textcolor{olive}{\\mathbb{F}_3}{[{\\text{\ud83d\uddff}}]}$<\/span><\/strong><\/p>\n<div lang=\"x-mathjax\">$$\\begin{array} {r|r|} + &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff}^2 &amp; \\dots &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff}^{100} &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{0} &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1}&amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff}^2 &amp; \\dots &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff}^{100} &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{1} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} &amp; \\textcolor{olive}{0} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff}^2 + \\textcolor{olive}{1}})} &amp; \\dots &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff}^{100} + \\textcolor{olive}{1}})} &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{0} &amp; \\textcolor{olive}{1} &amp; \\textcolor{olive}{2} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff}^2 + \\textcolor{olive}{1}\\text{\ud83d\uddff}})} &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; {({\\textcolor{olive}{1}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\textcolor{olive}{1}\\text{\ud83d\uddff} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{1}})} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; {({\\textcolor{olive}{2}\\text{\ud83d\uddff} + \\textcolor{olive}{2}})} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\_ &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{1}\\text{\ud83d\uddff}^2 &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp;\\_ &amp; \\dots \\\\<br \/>\n\\hline \\dots &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp;\\_ &amp; \\dots \\\\<br \/>\n\\hline \\textcolor{olive}{1}\\text{\ud83d\uddff}^{100} &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\_ &amp; \\dots &amp; \\textcolor{olive}{2}\\text{\ud83d\uddff}^{100} &amp; \\dots \\\\<br \/>\n\\hline \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots &amp; \\dots \\\\<br \/>\n\\hline \\end{array}$$<\/div>\n","protected":false},"excerpt":{"rendered":"<p>So you've got the \u201cnatural numbers\u201d, $\\mathbb{N}=\\left\\{0, 1, 2, \\dots\\right\\}$. Or the \u201ccounting numbers\u201d, or whatever you want to call them. Addition works, and multiplication works. But subtraction is broken, because there isn't any natural number equal to $2-3$. We might think about fixing subtraction, and one way of doing this is by moving to &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,97],"tags":[],"class_list":["post-2983","post","type-post","status-publish","format-standard","hentry","category-drafts","category-original-content"],"_links":{"self":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/2983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/comments?post=2983"}],"version-history":[{"count":177,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/2983\/revisions"}],"predecessor-version":[{"id":3260,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/2983\/revisions\/3260"}],"wp:attachment":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/media?parent=2983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/categories?post=2983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/tags?post=2983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}