integer right triangles

10142019, 08:29 PM
Post: #1




integer right triangles
I am just playing around with find all of the integer right triangles with my DM 42s.
I have A program that will do it but it gives me twice the count ( 3,4,5 and 4,3,5). Does any one know of any to compare them and remove the duplicates using the DM 42? I am drawing A blank. 

10152019, 12:40 AM
Post: #2




RE: integer right triangles
Start with the smaller number, a. You're now looking for pairs of numbers b, c, such that c^2  b^2 = a^2. For the difference between two squares, there are two useful constraints.
First, you don't want to find the same triplet twice. That leads to the first constraint: b > a. (You don't need to consider b = a, since a^2 + a^2 = c^2 has no solutions in the positive integers, because sqrt(2) is irrational.) Second, you don't want to search any further than you have to. The difference between two consecutive squares grows monotonically: (b+1)^2  b^2 = 2*b  1, so for a given a, you can stop searching when 2*b  1 > a^2. Further optimizations are possible, but with these two constraints, you can write a simple program that will enumerate all the Pythagorean triplets, and do it reasonably efficiently. I actually wrote this on my HP41C back in the day, but that program was lost ages ago. Please share what you come up with! 

10152019, 02:34 AM
(This post was last modified: 10152019 02:35 AM by vanLudwig.)
Post: #3




RE: integer right triangles
Look at Wikipedia for Pythagorean Triples:
Euclid's formula is a fundamental formula for generating Pythagorean triples given an arbitrary pair of integers m and n with m > n > 0. The formula states that the integers $$a=m^{2}n^{2}, b=2mn, c=m^{2}+n^{2}$$ form a Pythagorean triple. The triple generated by Euclid's formula is primitive if and only if m and n are coprime and not both odd. 

10152019, 01:02 PM
(This post was last modified: 10152019 03:21 PM by SlideRule.)
Post: #4




RE: integer right triangles
Perhaps the thread (41C) Pythagorean Triples posted in HP41C Software Library may be of minor interest?
BEST! SlideRule 

10152019, 07:57 PM
(This post was last modified: 10152019 08:45 PM by Lostinozone..)
Post: #5




RE: integer right triangles
ok thank you! All I had to do was modify the inner loop counter on my original program. The program is still A bit of A mess but I dough it will run much faster (my Poor printer can't go that fast)!


10152019, 11:29 PM
Post: #6




RE: integer right triangles
(10152019 02:34 AM)vanLudwig Wrote: Euclid's formula is a fundamental formula for generating Pythagorean triples given an arbitrary pair of integers m and n with m > n > 0. The formula states that the integers A bit of related fun: The sequence of Pell Numbers (1, 2, 5, 12, 29, 70, 169, ...) is defined recursively as P(1)=1, P(2)=2, and P(n)=2*P(n1)+P(n2). Try consecutive pairs of Pell Numbers (e.g. 1 and 2, or 2 and 5) for m and n in the above formulas, and as they get bigger, you'll see why the Pythagorean Triples they yield are called "almostisosceles primitive Pythagorean triangles". Spoiler Alert: the above is an immediate consequence of the matrix definition of Pell Numbers: Just take the determinant of both sides. Voilà! <0ɸ0> Joe 

« Next Oldest  Next Newest »

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