Showing posts with label geometry. Show all posts
Showing posts with label geometry. Show all posts

Sunday, 24 May 2020

rational conics

I’m currently reading Elliptic Tales, some light relief from lockdown.  On reading the preface alone, I discovered something I hadn’t known before.  This might be quite well-know to people with a “traditonal” maths background, but I did “modern maths” at school: lots of cool set and group theory, very little classical geometry.

The discussion in the book is just about circles, but a little googling helped me discover this is a result that applies more broadly.

Consider the general quadratic equation of two variables:

\(a x^2 + b x y + c y^2 + d x + e y + f = 0\)

where not all of the coefficients of the quadratic terms, \(a,b,c\),  are zero.  Depending on the coefficent values, this gives a circle, ellipse, parabola, or hyperbola, that is, a conic section.

Let’s now consider the restricted case where all the coefficients are rational numbers.  A rational solution to this equation is a solution \((x,y)\) where both \(x\) and \(y\) are rational numbers.

Now comes the interesting bit.  Take a straight line with rational slope, \(y = q x + r\), where \(q\) is rational, that cuts the quadratic curve at two points.  Then either both points are rational solutions, or neither is.

The book proves this for the case of a circle, and then shows how to use the result to find all the rational points on the unit circle, \(x^2+y^2=1\).  You need one point that you know is rational, so let’s chose \((-1,0)\).  Then draw a straight line with rational slope that crosses the \(y\) axis at \(q\); that is, \(q\) is rational.  This line has equation \(y=q(x+1)\).  Then solve for the other point where the line crosses the circle to get a rational solution:

It is clear from the form of the solution that if \(q\) is rational, so is the point \((x_q,y_q)\).  Additionally, there are no rational solutions that correspond to an irrational value of \(q\), so we can use \(q\) to parameterise all the rational solutions.

Notice also that if we scale up the yellow right-angled triangle, multiplying it by a suitable integer \(n\), so that both  \(n x_q\) and \(n y_q\) are integers, the three sides form a Pythagorean triple.

These points and triples can be generated very easily, just by scanning through values of \(q\) and printing out the unique triples.  And Python’s fraction module makes this particularly straightforward (with a bit of fiddling to print in a fixed width format to make things line up neatly; yes, I’m a bit picky about things like this):
from fractions import Fraction as frac

found = set()
for denom in range(1,15):
    for num in range(1,denom):
        q = frac(num,denom)
        xq = (1-q*q)/(1+q*q)
        yq = 2*q/(1+q*q)
        
        n = xq.denominator
        triple = sorted([int(xq*n), int(yq*n), n])
        
        if triple[0] not in found:
            print( '{0:<7}  ({1:^7}, {2:^7})  {3}'.format(str(q),str(xq),str(yq),triple) )
            found.add(triple[0])
This gives the output:
1/2      (  3/5  ,   4/5  )  [3, 4, 5]
2/3      ( 5/13  ,  12/13 )  [5, 12, 13]
1/4      ( 15/17 ,  8/17  )  [8, 15, 17]
3/4      ( 7/25  ,  24/25 )  [7, 24, 25]
2/5      ( 21/29 ,  20/29 )  [20, 21, 29]
4/5      ( 9/41  ,  40/41 )  [9, 40, 41]
1/6      ( 35/37 ,  12/37 )  [12, 35, 37]
5/6      ( 11/61 ,  60/61 )  [11, 60, 61]
2/7      ( 45/53 ,  28/53 )  [28, 45, 53]
4/7      ( 33/65 ,  56/65 )  [33, 56, 65]
6/7      ( 13/85 ,  84/85 )  [13, 84, 85]
1/8      ( 63/65 ,  16/65 )  [16, 63, 65]
3/8      ( 55/73 ,  48/73 )  [48, 55, 73]
5/8      ( 39/89 ,  80/89 )  [39, 80, 89]
7/8      (15/113 , 112/113)  [15, 112, 113]
2/9      ( 77/85 ,  36/85 )  [36, 77, 85]
4/9      ( 65/97 ,  72/97 )  [65, 72, 97]
8/9      (17/145 , 144/145)  [17, 144, 145]
3/10     (91/109 , 60/109 )  [60, 91, 109]
7/10     (51/149 , 140/149)  [51, 140, 149]
9/10     (19/181 , 180/181)  [19, 180, 181]
2/11     (117/125, 44/125 )  [44, 117, 125]
4/11     (105/137, 88/137 )  [88, 105, 137]
6/11     (85/157 , 132/157)  [85, 132, 157]
8/11     (57/185 , 176/185)  [57, 176, 185]
10/11    (21/221 , 220/221)  [21, 220, 221]
1/12     (143/145, 24/145 )  [24, 143, 145]
5/12     (119/169, 120/169)  [119, 120, 169]
7/12     (95/193 , 168/193)  [95, 168, 193]
11/12    (23/265 , 264/265)  [23, 264, 265]
2/13     (165/173, 52/173 )  [52, 165, 173]
4/13     (153/185, 104/185)  [104, 153, 185]
6/13     (133/205, 156/205)  [133, 156, 205]
8/13     (105/233, 208/233)  [105, 208, 233]
10/13    (69/269 , 260/269)  [69, 260, 269]
12/13    (25/313 , 312/313)  [25, 312, 313]
3/14     (187/205, 84/205 )  [84, 187, 205]
5/14     (171/221, 140/221)  [140, 171, 221]
9/14     (115/277, 252/277)  [115, 252, 277]
11/14    (75/317 , 308/317)  [75, 308, 317]
13/14    (27/365 , 364/365)  [27, 364, 365]
and larger values are readily calculated, such as:
500/1001  (752001/1252001, 1001000/1252001)  [752001, 1001000, 1252001]

So I’ve only read the Preface so far, and yet I’ve already learned some interesting stuff, and had an excuse to play with Python.  Let’s hope the rest is as good (but I suspect it will rapidly get harder…)


Sunday, 3 April 2016

pull to grow

pull it, and it stretches both lengthways and widthways




For all my social networking posts, see my Google+ page

Tuesday, 12 August 2014

Applications of Finsler Geometry to Speed Limits to Quantum Information Processing

New publication:

Benjamin Russell, Susan Stepney.
Applications of Finsler Geometry to Speed Limits to Quantum Information Processing
International Journal of Foundations of Computer Science, 25(4):489–505 2014
doi: 10.1142/S0129054114400073



For all my social networking posts, see my Google+ page

Saturday, 28 June 2014

Euclidean geometry

I saw this interactive geometry game on BoingBoing recently.  I’ve just completed the final level 20.  It’s great fun.  The final couple of levels did have me scribbling on pieces of paper and muttering for a bit.  (Well, it has been a while since I left school!)


For all my social networking posts, see my Google+ page

Saturday, 14 April 2012

climbing up onto the shoulders of giants

Newton
If I have seen further it is by standing on the shoulders of Giants – Isaac Newton 
Newton was not first to say this (and it may or may not have been a jab at Hooke), but the idea is sound: we can get further because we don’t have to invent everything from scratch; we can build on what others have done before. So, if we need to solve a particular problem that needs calculus, we don’t have to invent calculus from scratch to do so, we can use what Newton (and Leibniz, of course) invented. Standing on their shoulders, we can see further.

But how do we get to stand on the giant’s shoulders? (I’ll keep the metaphor to a single giant, as standing on the shoulders of multiple giants sounds too much like a circus act. And I am focussing on the mathematical giant.) We aren’t born up there on the giant’s shoulders. While we don’t have to grow into the giant (invent calculus), we do have to climb up the giant (study calculus).

And the giant is getting ever bigger. On the one hand, this is good: being so much higher we can see so much further. On the other hand, what happens when we have to spend our entire lives climbing up the vast growing giant, and never reach the viewpoint on the ever-distant shoulders?

We need short cuts up the giant. Fortunately, other are building ropes and ladders and lifts: tools to climb the giant more easily. So, we now have computer algebra packages that can solve our differential and integral equations for us; we no long need to spend years studying and practising how to do this.

But wait! cry the purists. That is cheating.
there is no Royal Road to geometry – Euclid
Understanding an idea meant entangling it so thoroughly with all the other symbols in your mind that it changed the way you thought about everything. – Greg Egan
There are no shortcuts, the purists insist. Mathematics is not a “spectator sport”. You have to do it, be immersed in it, internalise it, in order to really understand it.  The youth of today, with their fancy calculators and computers, they don’t really understand arithmetic and algebra and calculus.  Get off my lawn!
Socrates
There is nothing new under the sun when it comes to criticism of youth, of course. Plato, in Phaedrus, has Socrates rail against this new-fangled literacy:
 [writing] will introduce forgetfulness into the soul of those who learn it: they will not practice using their memory because they will put their trust in writing, which is external and depends on signs that belong to others, instead of trying to remember from the inside, completely on their own. You have not discovered a potion for remembering, but for reminding; you provide your students with the appearance of wisdom, not with its reality. Your invention will enable them to hear many things without being properly taught, and they will imagine that they have come to know much while for the most part they will know nothing. And they will be difficult to get along with, since they will merely appear to be wise instead of really being so. 
This sounds suspiciously similar to those modern complaints about using calculators rather than mental arithmetic, or using computer algebra programs rather than slogging through pages of pushing symbols around. These devices give only the “appearance of wisdom”.

a big sum
I do have some sympathy with this view. There does seem to be a lot of blind trust in the output of calculators and computers. However, I’m not sure it is purely the fault of the calculators. There can be uncomprehending blind trust in symbol pushing, too. I remember, many years ago, being in a computer shop, buying four items. The shop assistant wrote down the prices, and laboriously added them up, with much crossing out. When they announced the total, I said “that’s wrong”. They got a bit huffy, but then I pointed out their total was too small: it was less than one of the items on the list! As well as their huffiness, I detected a faint feeling of puzzled wonder from the assistant: how had I known? Despite the hand calculation, the assistant had no feel for the numbers. Maybe Socrates would have said that they should have added the numbers in their head? (Notice here that I didn’t know what the right answer was, but I knew the suggested answer was wrong.)

Another example comes to mind, again from many years ago. We were buying some new pillows: four for £4.99 each. The shop assistant wrote down 4.99 four times in a list, and added them up. Meanwhile I was going “£4.99 is a penny less than £5, so that’s £20 minus 4p, or £19.96.” I had the right money ready by the time the assistant came up with the answer, and was again met with puzzled wonder. (I’m sure that’s the real reason supermarkets took the prices off their goods: to stop some customers freaking out the cashiers by having the right money ready!)

I recounted this pillow story to my mother, who, faster than I did my shortcut calculation, simply multiplied 4.99 by 4 in her head, and got the right answer. I was almost as much in awe of this feat as the shop assistant had been in mine. But which approach shows more understanding of numbers: my short cut or my mother’s brute force calculation? Is it possible that slogging through all those exercises merely enable us to do calculations quickly, without thinking? And if there is no thought, then what have we actually gained? After all, one can learn by rote and merely “parrot” remembered answers.

Back to climbing that giant. What we need is a way of taking short cuts up and of having the “feel” for the numbers. An approach that could work is critical thinking about the supplied results (whether supplied by computer, or by our own unthinking calculations). We can keep the feel by using even shorter short cuts and heuristics that give an approximate answer, as a sanity check. Those shorter cuts and heuristics supply the feel, and when they are done automatically, they are the feel.

So, education shouldn’t be focussed on getting students to wade through pages and pages of exercises, pushing symbols (be they numbers or letters) around (unless they enjoy that sort of thing, of course). It should be more focussed on training in the use of short-cut tools, education on where and how to apply the tools, and meta-training in critical thinking about the results those tools give. Then we can climb the ever-growing giant fast enough to get to the top in time to see something before we die, and confident that we’ll understand what we do see when we get there.