Post Reply 
(12C) Pythagorean Triple
09-18-2019, 11:37 AM (This post was last modified: 09-19-2019 12:48 AM by Gamo.)
Post: #1
(12C) Pythagorean Triple
Program to generate a Pythagorean Triples based on this formula

a = m^2 - n^2 , b = 2mn , c = m^2 + n^2

for m > n with m and n co-prime and not both odd

-------------------------------------------------
Procedure: FIX 0

Your choice of integer m > n

m [ENTER] n [R/S] display answer a ... b ... c [R/S] add one on both m and n and display next result.

To start over with new pair of m and n f [PRGM]
-------------------------------------------------
example: f [PRGM]

m = 2 , n = 1

2 [ENTER] 1 display 3 .... 4 .... 5 [R/S] 5 ... 12 ... 13

To review result use [R↓] [R↓] [R↓]

--------------------------------------------------
Program:
Code:

01 STO 2  // n
02 R↓
03 STO 1  // m
04 RCL 1
05 RCL 2
06  -
07 LSTx
08 X<>Y
09 ENTER
10  x
-------------
11 √x
12 X=0
13 GTO 15
14 GTO 06
15 X<>Y  // GCD routine
16  1
17  -
18 X=0  // Test for a co-prime
19 GTO 24
20  1
-----------
21 STO+1
22 STO+2
23 GTO 04
24 RCL 1
25  2
26  ÷
27 FRAC
28 X=0  // Test for odd or even integer
29 GTO 39
30 RCL 2
-----------
31  2
32  ÷
33 FRAC
34 X=0  // Test to make sure not both odd integer
35 GTO 39
36  1
37 STO+1
38 GTO 04
39 RCL 1
40 ENTER
-----------
41  x
42 RCL 2
43 ENTER 
44  x
45  +
46 STO 3
47 RCL 1
48 RCL 2
49  x
50  2
----------
51  x
52 STO 4
53 RCL 1
54 ENTER
55  x
56 RCL 2
57 ENTER 
58  x
59  -
60  0
----------
61 X<>Y
62 PSE  // display a
63 RCL 4
64 PSE // display b
65 RCL 3  // display c
66 R/S
67  1
68 STO+1
69 STO+2
70 GTO 04  // add one and start over

Gamo
Find all posts by this user
Quote this message in a reply
09-20-2019, 04:33 PM
Post: #2
RE: (12C) Pythagorean Triple
If circle x² + y² = c = m² + n², we know P = (m,n) is on the circle.

We can get rational parametizations of the circle, using this rational point.

Let line that pass thru P, y = (x-m)t + n.
To get its intersection of the other point, Q, substitute it into circle equation:

x² + ((x-m)t + n)² = m² + n²

(1+t²) x² + (2nt - 2mt²) x + (-m² - 2mnt + m²t²) = 0

Product of roots, xP xQ = m xQ = (-m² - 2mnt + m²t²) / (1+t²)

xQ = (-m - 2nt + mt²) / (1+t²)

Thus, rational parametized points on the circle is

\(\Large Q = \left( {-m - 2nt + mt² \over 1+t²} , {n - 2mt - nt² \over 1+t²} \right) \)

If circle is unit circle, and we pick P=(-1, 0), we get trig substitution form, t=tan(½θ)

\(\Large Q = (\cos θ, \sin θ) = \left( {1 - t² \over 1+t²}, {2t \over 1+t²} \right) \)

Example, with P=(-5,0), and for positive ts we get Qs:

\(\large (0,5), (-3,4), (-4,3), ({-75 \over 17}, {40 \over 17}), ({-60 \over 13}, {25 \over 13}), ({-175 \over 37}, {60 \over 37}), ({-24 \over 5}, {7 \over 5}), ({-63 \over 13}, {16 \over 13}) ... \)

ref: "The Irrationals", appendix B, by Julian Havil
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)