« previous | Thursday, January 17, 2013 | next »
Fundamental Theorem of Arithmatic
Any
can be written as
for pairwise distinct primes
and
Corollary
Corollary
If
with
= 1 and
Extended Euclidean Algorithm
Input: 
Output:
and
with
- Form matrix

- Use elementary column operations (only allowing divisions by ≠ 1) to reduce to

- You have your answers
,
, and 
Example
Solve
Rewrite as
. Find
and
such that
Therefore, all of the following are true:



Complexity: Lame's Theorem
Number of column operations needed is ≤ 5 × number of digits in smaller number
Theorem on Congruences
Given any
, the congruence
has exactly
solutions when
and no solutions otherwise
Example
has solutions
.
How would we have known?
- find
via Extended Euclidean Algorithm (
;
)
- divide out equation by
(
)
- solve equation above (
)
- solutions are:

Proof
First note that
implies no solutions.
Indeed
implies
for some
.
, so
leads to a contradiction.
For example,
cannot be solved since
is even and
is odd.
Let's assume
if
, and
is any solution to
, so is
for any
Indeed,
Moreover,
are clearly distinct mod
It's enough to consider
To conclude,
has only one solution.
Now suppose if there are two solutions
and
, then we get
, so since
divides the RHS, it also divides the LHS
Therefore,
Q.E.D.
CAS Stuff
Maple
> (* Matrices *)
> M := matrix([[a,b,c],[d,e,f],[g,h,i]]);
Sage
sage: # Affine Ciphers == of the form: f(x) = a*x + b (mod 26)
sage: A = AffineCryptosystem(AlphabeticStrings());
sage: P = A.encoding("Hey! How's it going?");
=> HEYHOWSITGOING
sage: a,b = (9,13);
sage: cipher = A.enciphering(a,b,P);
=> YXVYJDTHCPJHAP
Solving Linear Systems
(mod an integer)
Put into an augmented matrix
First operation would be to subtract 7/2 times the first row from the second row... TROUBLE! What's 1/2 mod 26? (undefined)
2 options
- Do gaussian elimination without dividing by two (similar to E.E.A.)
- Use adjoints
First Option
We can invert -1/7 mod 26:
Second Option
Cramer's rule
We only have to invert 7, which is relatively prime to 26, so it is possible.
Theorem
You can solve
for any
matrix of integers
and any
vector of integers
when