Pythagorean Triple

Coloring Formula

by Kerry Mitchell, 06 Feb 2000

Basic information

A Pythagorean Triple is a set of 3 integers that satisfy the Pythagorean theorem, x2 + y2 = z2.  If you've ever taken a geometry or a trigonometry class, you've probably run into the most famous triple, (3,4,5).  In that case, x and y represent the lengths of the 2 legs (shorter sides) of a right triangle, and z is the length of the hypotenuse (the longest side).  Even though there are an infinity of them, they are relatively rare in the study of right triangles.  Another example is (5,12,13).

What has this to do with fractals?  Every complex number can be represented by a right triangle, with its magnitude given by the Pythagorean theorem: x is the real part, y the imaginary part, and z the magnitude.  This coloring formula scans the sequence of iterates, which are taken to be complex numbers.  It looks for the orbit's approach to Pythagorean triples, and colors the pixel accordingly.

The pertinent parts are then:

There are 4 choices for the triple, given by the 4 functions that make complex integers:  round, trunc, ceil, and floor.  See Ultra Fractal's help for more information on those functions.

Whether or not the triple represents a Pythagorean triple depends on the point's distance from the integers.  The real part, imaginary part, and magnitude each have their own integer, and the respective distances from the integers are combined into one distance.  Several methods exist for determining the distance between 2 sets of coordinates, and this formula offers 5: Euclidean, minimum, maximum, sum, and product.

The Euclidean distance is the normal distance, based on the Pythagorean theorem.  This can be generalized by changing the exponent (2 above):

d = (|x|n + |y|n)1/n,

where n is at least 1.  The vertical bars mean "absolute value", and are required to keep the x and y parts positive and real.

Alternatively, either the minimum of |x| and |y|, or the maximum can be used.  Oddly enough, these are the "minimum" and "maximum" distance types.  Also, |x| and |y| can be added ("sum") or multiplied ("product").  In the latter case, the cube root is taken after the product is formed.

Ten options are provided for how to color the pixel, based on how close or how far the orbit came to a Pythagorean triple.

Parameters

Hints

To see the locations of the triples in the x-y plane (z is determined by x and y): The brightest spots represent Pythagorean triples.  The dimmer spots are points that are close, but not quite.

For outside pixels, use a fairly large bailout to give the orbit substantial opportunity to find a triple.

Sample images

PythagoreanTripleSample1 {
; copyright Kerry Mitchell 06feb00
;
; sample of "pythagorean triple" coloring
;
fractal:
  title="Pythagorean Triple Sample 1" width=600 height=400
  author="Kerry Mitchell" created="February 6, 2000" numlayers=2
layer:
  method=multipass caption="maximum" opacity=100 visible=yes alpha=no
  mergemode=difference
mapping:
  center=0.352157894000746314/0.20700772089973672 magn=4.58471760797342193
  angle=301.081131443854084
formula:
  filename="Standard.ufm" entry="Julia" maxiter=100 percheck=off
  p_seed=-0.125/0.649519052838 p_power=2/0 p_bailout=1000000000000
inside:
  filename="lkm.ucl" entry="pythagorean-triple" density=4 transfer=sqr
  repeat=yes p_inttype="round" p_rtype="maximum" p_colorby="min/max combo"
  p_power=2
outside:
  filename="lkm.ucl" entry="pythagorean-triple" density=0.25
  transfer=linear repeat=yes p_inttype="round" p_rtype="maximum"
  p_colorby="minimum distance" p_power=2
gradient:
  smooth=yes numnodes=4 index=0 color=293124 index=100 color=13758688
  index=200 color=7996697 index=300 color=15064798
layer:
  method=multipass caption="minimum" opacity=100 visible=yes alpha=no
  mergemode=difference
mapping:
  center=0.352157894000746314/0.20700772089973672 magn=4.58471760797342193
  angle=301.081131443854084
formula:
  filename="Standard.ufm" entry="Julia" maxiter=100 percheck=off
  p_seed=-0.125/0.649519052838 p_power=2/0 p_bailout=1000000000000
inside:
  filename="lkm.ucl" entry="pythagorean-triple" density=4 transfer=sqr
  repeat=yes p_inttype="round" p_rtype="minimum" p_colorby="min/max combo"
  p_power=2
outside:
  filename="lkm.ucl" entry="pythagorean-triple" density=0.25
  transfer=linear repeat=yes p_inttype="round" p_rtype="minimum"
  p_colorby="minimum distance" p_power=2
gradient:
  smooth=yes numnodes=4 index=99 color=1712417 index=199 color=8780518
  index=299 color=3018527 index=399 color=16418298
}
 

PythagoreanTripleSample2 {
; copyright Kerry Mitchell 06feb00
;
; sample of "pythagorean triple" coloring
;
fractal:
  title="Pythagorean Triple Sample 2" width=600 height=480
  author="Kerry Mitchell" created="February 6, 2000" numlayers=1
layer:
  outsolid=8388607 method=multipass caption="Layer 1" opacity=100
  visible=yes alpha=no mergemode=difference
mapping:
  center=0.442359998031099591/0.576249381917956611 magn=39.4553427976048464
  angle=300.674426640456562
formula:
  filename="Standard.ufm" entry="Julia" maxiter=100 percheck=off
  p_seed=0.168715824268/0.565343860149 p_power=2/0 p_bailout=1000000000000
inside:
  filename="lkm.ucl" entry="pythagorean-triple" density=7 transfer=sqr
  repeat=yes p_inttype="round" p_rtype="minimum"
  p_colorby="amean/gmean combo" p_power=2
outside:
  filename="lkm.ucl" entry="pythagorean-triple" transfer=none repeat=yes
  p_inttype="round" p_rtype="Euclidean" p_colorby="minimum distance"
  p_power=2
gradient:
  smooth=yes numnodes=6 index=0 color=0 index=50 color=128 index=150
  color=33023 index=200 color=131071 index=250 color=33023 index=350
  color=128
}