Arithmetic in a clock

WTF is "signing" something with ETH anyways, and what does it have to do with geometry? Part 2: Arithmetic in finite fields

By webguy24 | terrible-math | 13 Aug 2023


PLEASE DON'T JUST SCROLL DOWN TO THE BOTTOM OF THIS ARTICLE TO TIP! Read it, please.

 

So in a previous post we defined what a field was. (Refresher: it's a set with addition and multiplication that behave in the "usual" ways).

Our first example of arithmetic in different sets we saw was "clock arithmetic"; basically counting in a circle. We will denote this with (mod 12).

(Note: just like how the field of reals is called R, we will call this set of 12 elements, Z/12Z, for... reasons. Think of it as "1/12th of the integers").

Clock practice

Try these problems to get a sense of how things behave in clock math, and please comment your answers!

What is 6+8 in Z/12Z? You should get 2

What is 3*5?

What is 1*6? What about 1*x? (It's obviously just x, right?)

What about (6+7)*x?

An important note:

Note that even though addition and multiplication behave similarily to normal... many important properties are not the same!

It's probably obvious that if x*y=0, then one  of x or y have to be 0. Is this true in "clock math"? No! 

3 is not 0, and 4 is not 0, but 3*4=12=0. 

(another note on the note: any set that satisfies this is known as an "integral domain").

 

Okay, so why the hell is it not a finite field then? Addition and multiplication all behave as expected.

Multiplication here is the problem.

We know that in the reals every number has a multiplicative inverse; a number A for every B such that A*B=1.

Our clock arithmetic does not have one! (Think about it for a sec before continuing)

Answer: It should be obvious to see that any multiple of 3 is either equivalent to 3,6,9,or 0 in clock arithmetic. (Think about what time it is 3 hours later from 3 o clock, then 3 hours later from that, etc). Thus there is no element A such that A*3=1!

(This is basically just the statement that 12 is divisible by 3, so likewise 4 doesn't  have an inverse either, if you want to learn more about this google Chinese Remainder Theorem).

If clock math is not a finite field, then what the hell is? 

Note that this weird thing only happens for a "circle" of size a composite integer (one that's not prime). Since primes have no divisors besides 1 and itself, it should be "obvious" to see that every element has an inverse. A more explicit proof is given below

Proof: Suppose I have a number p which is prime, and x which is not a multiple of p, and x is not equal to 1. Then, the LCM of p and x is going to be p*x.

How many possible "numbers" are in a circle of size p? Obviously there are the numbers from 0 to p-1, right? So there's p numbers.

And how many times do you need to add x to itself to get to p*x, the earliest one of these numbers can be repeated by simply "adding x to itself"? p times, obviously.

By the definition of the LCM, no number on this circle can be repeated by simply adding x, less than p number of times. (If you could repeat, 2 for example, by adding x, lets say 5 times for a p>5, such that upon dividing 2+5x by p the remainder is 2, then by the definition of remainder, 5x has remainder 0 when you divide it by p, implying 5x is divisible by p, which is less than p*x, which contradicts the definition of LCM, particularily the "least" part).

So now we effectively have p "slots" for numbers we can get, and we have to place p multiples of x in those slots, and we can't put two in one slot (that would be repetition which is not allowed as we just proved).

So there's only one way! This way is to fill every slot. (Think of putting 5 balls in 5 boxes such that each box only fits one ball, you have to fill every ball).

This implies that x at some point fills the "1" slot, which implies a multiple of x=1, aka m*x=1, and thus m is the multiplicative inverse of x.

Thus we are done, and we have found our first example of a finite field ! Yay! We denote this field as F_p for prime p.

A concrete example: F_2, the field with two elements, {0,1}, such that 0+0=0, 0+1=1, 1+1=0, and 0*0=0, 0*1=0, 1*1=1.

A family of finite fields: F_p for p prime, the finite field with p elements such that we count in a circle of size p, where 0=p, 1=p+1, etc.

 

A bit of a lead into the next post:

 

We know that (x+y)^n is not equal to x^n+y^n. (This is basic HS math, if you don't get this try some small examples.)

 

1200px-Freshman%27s_Dream.svg.png

What does (x+y)^p equal, if we work in F_p? (small hint: this is called the "freshman dream")

 

Thank you all for reading this advanced math! We will get into Ethereum soon, after we get to elliptic curves.

 

 

How do you rate this article?

19



terrible-math
terrible-math

Terrible math related content is posted here. Mostly for fun. Also I started this to get 100 gwei in order to transfer out some USDC i have locked away in ETH, and I have no money to pay for gas fees. So I'm basically begging for money on the internet. proof: 0xB032058526305C70AE533D4020e9062F9Cde5DA5 is the account with USDC in it

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.