-1

I currently am working on a minor programming project, and I have a program that can plot points in the problem above. However, this requires a lot of computing power that the average school chromebook simply cannot output. I realized that the points were very specifically placed and followed a pattern, but I have no idea where to start linking the info together. [Solutions from the range (-30,-30) to (30,30)][1] If anyone is interested in the code:

var a;
var b;
var c;
var list=[];
// Find A and B
for(var i = -30; i<=30; i++){
  a=i;
  console.log(a);
 for(var j = -30; j<=30; j++){
  b=j;
  console.log(b);
  wholenum(a, b);
  }
}

// Test If a^2+b^2 makes a whole number function wholenum(a, b) { if(Math.floor(Math.sqrt(a^2+b^2)) === Math.sqrt(a^2+b^2)){ c=Math.sqrt(a^2+b^2); appendItem(list, "("+a+","+b+")"); // testpyth(a, b, c); } }

I beleive it could be solutions to a system of a number of equations, but im not sure. Thank you in advance for any help. [1]: https://i.stack.imgur.com/0GIKG.png

Thomas Andrews
  • 177,126

1 Answers1

1

There are many formulas to generate Pythagorean triples and the most common one is Euclid's, which works but requires some restrictions on input to avoid generating trivial and imprimitive triples. $$A=m^2-k^2\qquad B=2mk\qquad C=m^2+k^2$$

There is another formula that generates a Pythagorean triple for any pair of natural numbers $\space (n,k)\space$ with fewer imprimitives than any other formula I have seen.

\begin{align*} &A=(2n-1)^2+&&2(2n-1)k\\ &B= &&2(2n-1)k+2k^2\\ &C=(2n-1)^2+&&2(2n-1)k+2k^2 \end{align*}

Using either formula, we will have $$X=A\quad\text{and}\quad Y=B$$

and we can use these to generate a scatter plot similar to the one shown here.

poetasis
  • 6,338
  • [+1] I didn't know the second family of formulas. Do you have references ? – Jean Marie Sep 16 '22 at 13:51
  • In fact, using https://approach0.xyz/search/ I found this reference, that you should remember. – Jean Marie Sep 16 '22 at 14:08
  • @Jean Marie I developed the 2nd formula, out of ignorance in 2009, and have found no other references to it outside of MSE. It reveals unexpected things too, like the inradius of any triple generated by this formula is $\space (2n-1)k.$ – poetasis Sep 16 '22 at 14:54
  • Interesting indeed... Have you seen this reference ? – Jean Marie Sep 16 '22 at 15:26
  • @Jean Marie I have seen them but never paid that much attention because I like my formula so much. Here are more observations derived from my formula about the lines$\space (x,y,z)\space$ from the incircle center to the vertices

    \begin{align} \text{inradius}=r&=(2n -1)k\ x^2&=2(2n-1)^2k^2\ y^2&=2k^2C\ z^2&=(2n-1)^2C\ \end{align}

    – poetasis Sep 16 '22 at 18:43
  • Interesting. But what is $C$ in the two last formulas ? – Jean Marie Sep 16 '22 at 19:24
  • 1
    @Jean Marie \begin{align}&C=(2n-1)^2+&&2(2n-1)k+2k^2 \end{align} as per the formula I developed. – poetasis Sep 17 '22 at 01:21
  • Besides, IMHO, the most unexpected way to generate (efficiently) all primitive triples is the matrix way with ternary tree given here. – Jean Marie Sep 17 '22 at 05:51