Post Reply 
(41C) Pythagorean Triples
07-03-2022, 08:18 AM (This post was last modified: 07-03-2022 02:06 PM by C.Ret.)
Post: #7
RE: (41C) Pythagorean Triples
(07-01-2022 11:55 AM)John Keith Wrote:  Additionally, Berggren's method does not require GCD and is pretty fast and simple on any calculator that can handle matrices. It generates all primitive triples but in a different order than the complex squaring method.

Thanks for pointing out this method which easily produces tons of primary Pythagorean triples using a very simple recursive program on an advanced calculator natively manipulating vectors and matrices:

PYT:
« 1 +
 [[ 1 2 2 ][ 2 1 2 ][ 2 2 3]] → T n M          \(T=\left[a_0,b_0,c_0 \right]\)
 «
   "             " 1 n 2 * SUB T →STR + PR1 STR→
   IF n N <
   THEN
      M T 2 DUP2 GET NEG PUT * n PYT      \(\left[a_1,b_1,c_1\right]=\begin{bmatrix}1&-2&2\\2&-1&2\\2&-2&3\\\end{bmatrix}\times \left [ a_0,b_0,c_0 \right ]=\begin{bmatrix}1&2&2\\2&1&2\\2&2&3\\\end{bmatrix}\times \left [ a_0,-b_0,c_0 \right ]\)
      M T             * n PYT      \(\left[a_2,b_2,c_2\right]=\begin{bmatrix}1&2&2\\2&1&2\\2&2&3\\\end{bmatrix}\times \left [ a_0,b_0,c_0 \right ]\)
      M T 1 DUP2 GET NEG PUT * n PYT      \(\left[a_3,b_3,c_3\right]=\begin{bmatrix}-1&2&2\\-2&1&2\\-2&2&3\\\end{bmatrix}\times \left [ a_0,b_0,c_0 \right ]=\begin{bmatrix}1&2&2\\2&1&2\\2&2&3\\\end{bmatrix}\times \left [ -a_0,b_0,c_0 \right ]\)
   END » »

Store max depth into N register:
4 'N' STO

Set printer online, aim to it and print by typing:
[ 3 4 5 ] 0 PYT

   
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(41C) Pythagorean Triples - SlideRule - 10-15-2019, 12:57 PM
RE: (41C) Pythagorean Triples - C.Ret - 06-26-2022, 09:29 AM
RE: (41C) Pythagorean Triples - John Keith - 07-01-2022, 11:55 AM
RE: (41C) Pythagorean Triples - C.Ret - 07-03-2022 08:18 AM
RE: (41C) Pythagorean Triples - John Keith - 07-03-2022, 01:55 PM
RE: (41C) Pythagorean Triples - C.Ret - 07-03-2022, 01:41 PM



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