Friday, December 31, 2010

Pythagorean Triples, ellipses and hyperbolas

Intriguingly to me, you can connect discrete ellipses and hyperbolas in some simple ways, which is something that I first came across with Pythagorean Triples when I went from my very general Quadratic Diophantine Theorem.

So I noticed that given what is commonly called Pell's Equation, x2 - Dy2 = 1, I had:

(D-1)j2 + (j+1)2 = (x+y)2, where j = ((x+Dy)-1)/D


(D-1)j2 + (j-1)2 = (x+y)2, where j = ((x+Dy)+1)/D

which gives a Pythagorean triple whenever D-1 is a square, as j will be an integer for one of them.

For instance with D=2, I have a solution with x=17, y=12, 172 - 2(12)2 = 1, as

j = ((17+2(12)-1)/2 = 20 is a solution giving:

202 + 212 = 292

The equations work in reverse as well, so with a Pythagorean Triple you can solve Pell's Equation. For instance, consider 52 + 122 = 132.

So x+y=13, and notice j-1 = 5, works giving j=6, so D-1 = 4, giving D=5.

And, j = ((x+Dy)+1)/D, gives x+5y = 29. So 4y = 16, and y=4.

So x=9, and 92 - 5(4)2 = 1.

Which I think is rather cool, as there is this deep connection between these equations. Sort of like they know each other and are reflections of something or other.

The discrete hyperbola of Pell's Equation connected to the discrete ellipse of the Pythagorean Triple.

A little later on I re-discovered the parametric solution to Pell's Equation:

y = 2t/(D - t2) and x = (D + t2)/(D - t2)

Which, of course, was known to Fermat. Notice with it you can get ellipses or hyperbolas dependent on the sign of D.

For my re-derivation go to an earlier post.

Though finding parametric solutions is trivial, as consider:

(n2 - t2)2 - (n2 - 2t2)n2 = t4, so n4 - 2n2t2 + t4 - n4 + 2n2t2 = t4

It seems worth mentioning that an easy set of solutions to Pell's Equation, come from situations like:

if D+2 is a perfect square, then D = n2 - 2 for some natural number n, as then

(n2 - 1)2 - (n2 - 2)n2 = 1, so n4 - 2n2 + 1 - n4 + 2n2 = 1.

Which has other variations like when D-2 is a perfect square.

So then notice also that:

(n2 - 3)j2 + (j+1)2 = (x+y)2, where j = ((x+Dy)-1)/D


(n2 - 3)j2 + (j-1)2 = (x+y)2, where j = ((x+Dy)+1)/D

is trivial to solve discretely.

James Harris

Sunday, December 05, 2010

Approximating square roots, easier math?

Here's a fun little result which uses what mathematicians usually call Pell's Equation to find rational approximations to square roots, which was what the earlier mathematicians often used it for anyway, where I also get to sneak in one of my own research findings.

The base equation then is: x2 - Dy2 = 1

Where we want integer solutions, for instance, with D=2: (3)2 - 2(2)2 = 1, and

(17)2 - 2(12)2 = 1, are solutions.

But notice that 17/12 is approximately 1.416, which is close to the sqrt(2).

One result of mine is that given:

u2 + Dv2 = F.

it must be true that

(u-Dv)2 + D(u+v)2 = F(D+1)

which is a general result where I can use u=x, v=y, D = -2, and use it twice to get:

(3x+4y)2 - 2(2x + 3y)2 = 1

so we can easily find another solution using x = 17, y = 12, from above.

So: (3(17)+4(12))2 - 2(2(17) + 3(12))2 = 1

Which is: (99)2 - 2(70)2 = 1

And that gives the slightly more impressive approximation of: 99/70 is about: 1.4142

And if you're bored you can just keep going! Where now x=99 and y=70. And it works out to infinity with ever more precise approximations to sqrt(2). (Next one is: x=577, y=408, and 577/408 is approximately 1.41421.)

Ok, so sqrt(2) is easy, but what about others? Sorry that trick works best for sqrt(2), as I'm sticking to easy. Given one solution to Pell's Equation there are other ways to get new solutions besides my equation which works so simply with D=2.

Finding solutions to Pell's Equation that are integers can be difficult in general, but in some cases it's very easy. For instance, if D+2 is a perfect square then x=D+1, and y = (D-1)/2 are solutions.

For instance, with D=7: 7+2 is a square as it is 9, so x=8:

82 - 7*32 = 1

And that is just one trick for some easy solutions. To see more you can see one of my more complicated posts (swinging for the fences) called Pell's Equation Basics.

But regardless of what more of my research you consider, just be thankful for modern computers which make getting square roots easy, as earlier mathematicians had to figure them out, or rely on approximate tables, where if you needed more precision, you needed to work it out for yourself, versus just asking a computer.

And that need drove research. But for modern people these mathematical tidbits are just curiosities maybe useful for an idle afternoon playing with fractions simply for the fun of it!

James Harris

Saturday, April 03, 2010

Ellipses, Hyperbolas and Pell's Equation

Some simple algebra can connect ellipses and hyperbolas, two conic sections, with the equation x2 - Dy2 = 1, which is commonly known as Pell's Equation.

While Pell's Equation is usually considered as a Diophantine equation, it is easier to let it be rational, so what follows is in the field of rationals, and my first relational equation is:

(D-1)j2 + (j+/-1)2 = (x+y)2

where j = ((x+Dy) -/+1)/D

Here the +/- indicates that one variation will work so it is an OR and not an AND. Either plus OR minus will give a valid j.

(For the derivation go to an earlier post.)

Notice you get Pythagorean Triples if D-1 is a perfect square! So immediately Pell's Equation is connected to circles.

Here's an example.

With D=2, and x=17, y=12, you solve Pell's as 172 - 2(12)2 = 1, and going with the minus of the plus or minus:

j = ((17+2(12)-1)/2 = 20 is a solution giving:

202 + 212 = 292

So D-1 a perfect square relates to circles but otherwise gives non-circular ellipses!

So you can always find integer solutions for af2 + g2 = h2 by using a solution for Pell's Equation where D = a+1.

For example with D=3, x=2, y=1 works as 22 - 3(1)2 = 1.

And going with the plus of the plus or minus:

j = ((2+3(1)) +1 )/3 = 2 is a solution giving, 2(2)2 + 12 = 32

But I've set the field as rationals which allows me to bring in one other result known since antiquity which is the rational parametric solution for Pell's Equation:

y = 2t/(D - t2) and x = (D + t2)/(D - t2)

(For my re-derivation go to an earlier post.)

So you can always find integer solutions for the ellipse using the single parameter t.

But in rationals x2 - Dy2 = 1, where D is a positive integer will give you hyperbolas, but for each solution for x and y, you get an ellipse, so there is a direct connection between hyperbolas as ellipse generators.

So one can directly connect ellipses to hyperbolas using Pell's Equation as a hyperbola itself in rationals and get Diophantine solutions for the ellipses as well, so the rational hyperbola can generate integer solutions to ellipses, including for the special case D-1, Pythagorean Triples.

Beautifully simple relations between two of the conic sections.

James Harris

Thursday, February 04, 2010

Prime residue axiom

Given differing primes p1 and p2, where p1 > p2, there is no preference for any particular residue of p2 for p1 mod p2 over any other.

I'll note that I don't consider 0 to be a residue.

The value of the axiom can be seen from my post on twin primes probability. Quite simply, by the axiom since primes do not prefer a particular residue modulo each other, you can determine the probability of twin primes in the following way.

If x is prime and greater than 3 the probability that x+2 is prime is given by:

prob = ((pj-2)/(pj-1))*((pj-1-2)/(pj-1-1))*...*(1/2)

where j is the number of primes up to sqrt(x+2), and pj is the jth prime, pj-1 is the prime before it and so forth.

The result is easy as it is just multiplying the probability for each prime that it is NOT true that

x + 2 ≡ 0 mod p

which probability is just the result of dividing one minus the number of non-zero residues by the total number of residues together to get the total probability that a prime plus 2 is also prime.

So let's try it out. Between 52 and 72, there are 6 primes. The probability then is given by:

prob = ((5-2)/(5-1))*((3-2)/(3-1) = (3/4)*(1/2) = 0.375

And 6*0.375 = 2.25 so you expect 2 twin primes in that interval.

The primes are 29, 31, 37, 41, 43, 47 and you'll notice, two twin primes as predicted: 29,31 and 41, 43.

However, there is an issue which shifts the probability slightly.

If you go into the actual residues it jumps out at you:

29, 31, 37, 41, 43, 47

mod 3: 2, 1, 1, 2, 1, 2
mod 5: 4, 1, 2, 1, 3, 2

Here all the residues for 5 were in evidence so the count came out right, but for random it should have been possible for ALL the residues mod 5 to be 4, but it's not because with 6 primes there isn't enough space in the interval--4*5 = 20, but 49-25=24, where only 12 are odd and only 6 are primes. So the probability is actually off! A scenario where all residues are 4 is precluded by the size of the interval for the larger prime.

That will tend to over-count because the higher residues are less likely to occur because they cannot fit. Easy explanation that jumps out at you with even a small example.

If that seems suspicious remember the prime number 5 has no idea I've clipped the interval to only go from 25 to 49. It doesn't care. But once you know there are 6 primes in that interval it's not possible for them all to be 4 mod 5, as the interval is too small.

For the smaller primes it's not an issue as if the prime is greater than interval/(prime count in interval) then that prime isn't affected and its residues can have purely random behavior. For instance, for 3 between 25 and 49, you have 24/(6) = 4, and as that is greater than 3, there is no clipping for 3.

Another example can be found using all the primes up to 100, for which I got:

prob = 0.1558 to 4 significant digits.

So that says that the probability that for a prime between 972 and 1002 that adding 2 to it gives a prime is about 15.58% and there are 66 primes in that interval so there should be about 10 twin primes, and a quick count shows that there are:

(9419, 9421), (9431, 9433), (9437, 9439), (9461, 9463), (9629, 9631), (9677, 9679), (9719, 9721), (9767, 9769), (9857, 9859), (9929, 9931)

So you have this random behavior which is just about probability which follows from the prime residue axiom--since primes don't care about their residue modulo each other, you get a probabilistic behavior, which means you should be within one standard deviation about 68% of the time.

Oddly enough the equation I show above does appear in the mathematical literature on twin primes where it is part of what is called the twin primes constant.

So there is a LOT of numerical data supporting random behavior where mathematicians appear to have mixed up random behavior with the non-random behavior of the prime distribution itself. That error is a fascinating one. But if not corrected it can be awfully convenient for continuing research where no other answer is available. Random means there is no further answer as random means--no reason.

I've explained myself why the prime distribution itself is not random.

Going further leads to the prime gap equation which handles prime gaps of arbitrary size.

I hypothesize that the clipping behavior for the bigger primes in the interval should actually be less significant as the gap size increases. Notice the prime gap post also hypothesizes that the max gap for primes is given by p+1 where p is the largest prime less than sqrt(x+g) where g is a positive prime gap.

But that number is significant only at lower values as later the prime gap probability dominates meaning that the gaps get pushed out further from where they are first allowed.

James Harris