Scatter plot of the legs (a, b) of the Pythagorean triples.
import matplotlib.pyplot as plt
x=[]
y=[]
n=2 # power
pmax=10000 # number of points
for a in range(2,pmax):
for b in range(2,pmax):
c = (a**n + b**n)**(1/n)
if( c - int(c) == 0 ):
x.append(a)
y.append(b)
print("a=",a," b=",b," c=",int(c))
fig1, ax = plt.subplots()
fig1.set_size_inches(18.5, 10.5)
ax.set_box_aspect(1)
plt.scatter(x,y,s=1)
plt.savefig('ex302.png', dpi=72)
plt.show()
Last Updated on 2022-10-07 by gantovnik

Recent Comments