Wednesday, February 18, 2026

Graphing Congruences in Modular Arithmetic And Turning a Cartesian Graph Into a Polar One

Even though this isn't anywhere close to Fields Medal level stuff, and it's not very deep, I think it's still pretty cool.  I haven't seen it before, but I'm pretty sure someone somewhere already did something like this.

What if we want to transform a graph in cartesian coordinates into one that looks like polar coordinates, where the x-values circle around some center point, and the y-values measure a distance from that center?  X would be comparable to Theta and Y would be comparable to R.  So we'd do a transformation as follows:

Theta = X times (( 2 times pi ) over a modulus)

R = Y

This modulus would cut the distance we have to travel around the center point into equal pieces.  We'll use the modulus 7 for this demonstration.

So if I wanted to take the arbitrary function Y=X^7 (this is an unrelated 7 - sorry I'm using the same number twice) and graph it in this system, I could do so, but first I'd have to do some easy algebra and express X in terms of Theta instead of Theta in terms of X.  Just divide both sides by (( 2 times pi ) over the modulus 7).

We end up getting R = ((7 times Theta) over (2 times pi)) raised to the power of 7.  That is something we can graph in Desmos.

Now, if I cut the distance around the origin into 7 parts, it would just be the angle Theta = (( 2 times pi ) over 7).  For some reason Demos really doesn't like me graphing that and won't let me do it, so I use the graph Y = tan(( 2 times pi ) over 7) times x, since that's the same thing.

So this line shows one-seventh of the distance around the origin.  But only the upper right part of the line stemming from the origin.  The lower left part is just a continuation of it, and does not represent another portion of 7 parts around the line as far as I know.

Modular arithmetic would tell us that once our Y=X^7 equation crosses this line, that equation is congruent to 1 (mod 7) at the R value where it crosses.  When the equation crosses the right side of the x-axis, that's when it's congruent to 0 (mod 7).  We could do this with other values as well if we were willing to draw more lines (and I'm not).

Anyway, we can test it out.  Here in this picture, we see that our X to the 7 function, the red curve, crosses the 1 (mod 7) line, the green line, right where that blue circle is.  The blue circle is just R = 8^7.  A pretty big number.  Over 2 million.  Is it congruent to 1 (mod 7)?  Indeed it is.  It's equal to 299,593 times 7 plus 1.  

Let's try another one.  This time we see the graph crosses the line at another purple circle, much larger than the last blue circle.  In fact, the blue circle at R = 8^7 looks almost like a small dot here.  This purple circle is R = 15^7.  Is this also congruent to 1 (mod 7)?  Sure is.  It's equal to 24,408,482 times 7 plus 1.  Nice to see computers confirming what the math shows.  And it's fun to graph this thing and zoom in and out on it.  Reminds me of the old Spirograph toy from a long time ago.

And that's all I've got to say about modular arithmetic here.

Now I want to do a conversion of a cartesian graph into a polar one using this same transformation, just because I think it looks interesting.

Let's do a nice and easy graph of a system of linear equations and note their intersection point.  Here the diagonal green and blue lines intersect at the red x=1 line and the orange y=7 line.

Applying our transformation to this system, we see the red x=1 line is now diagonal at the origin, the orange y=7 line is now a circle, and the two diagonal lines that cross each other there have become some kind of crazy spirals.  Very complicated looking.

So I just took something nice and easy and made it way more complicated for no reason.  I just think it's something kind of worth looking at, at least for me.

No comments:

Post a Comment