One familiar proof of the Pythagorean theorem (for right triangles,
2
a
+
2
b
=
2
c
) can be case-checked by transforming polygons as point sets. The System can accomplish this using RegionDifference, but not to infinite precision. The purpose of this memo is to give another quality assurance test to our favorite new tool: WFR`PlanarPolygonFragmentation.

Machine Precision

In[]:=
abSq=Polygon[N@{{0,0},{1,0},{1,1},{0,1}}]
Out[]=
Polygon
Number of points: 4
Embedding dimension: 2

In[]:=
cSq=Polygon[N[{{#,0},{1,#},{1-#,1},{0,1-#}}&[​​slider=RandomReal[1]​​]]]
Out[]=
Polygon
Number of points: 4
Embedding dimension: 2


First, the right-hand side:

In[]:=
Graphics[{Opacity[0],EdgeForm[Black],abSq,cSq}]
Out[]=
In[]:=
triangles=RegionDifference[abSq,cSq]
Out[]=
Polygon
Number of points: 12
Embedding dimension: 2

In[]:=
Graphics[{EdgeForm[Black],​​Transpose[{{Red,Green,Blue,Yellow},​​Polygon/@triangles[[1]]}]}]
Out[]=
In[]:=
translates=Polygon/@MapThread[​​Function[{tri,off},​​tri+Threaded[off]],​​{triangles[[1]],​​{​​{0,0},​​{0,1-slider},​​{-1+slider,-slider},​​{slider,0}​​}​​}]
Out[]=
Polygon
Number of points: 3
Embedding dimension: 2
,Polygon
Number of points: 3
Embedding dimension: 2
,Polygon
Number of points: 3
Embedding dimension: 2
,Polygon
Number of points: 3
Embedding dimension: 2


Next, the left-hand side:

In[]:=
Graphics[{EdgeForm[Black],White,abSq,​​Transpose[{{Red,Green,Blue,Yellow},​​translates}]}]
Out[]=
In[]:=
res=Map[Polygon,Fold[RegionDifference[#1,#2]&,abSq,translates][[1]]]
Out[]=
Polygon
Number of points: 4
Embedding dimension: 2
,Polygon
Number of points: 4
Embedding dimension: 2

In[]:=
Graphics[res]
Out[]=

Final checks

In[]:=
Map[PlanarAngle,Partition[abSq[[1]],3,1,1]]​​SameQ@@%
Out[]=
{1.5708,1.5708,1.5708,1.5708}
Out[]=
True
In[]:=
MapApply[EuclideanDistance,Partition[res[[1,1]],2,1,1]]​​SameQ@@%
Out[]=
{0.851577,0.851577,0.851577,0.851577}
Out[]=
True
In[]:=
Map[PlanarAngle,Partition[res[[1,1]],3,1,1]]​​SameQ@@%
Out[]=
{1.5708,1.5708,1.5708,1.5708}

Infinite Precision

Now useless:

Continue:

Passes inspection:

Bad hacking:

(keep these failures for later)

Final checks

Post script

If you notice pops from PPF, make sure to dig the source code and trace it to the real problem. Hint: you shouldn’t need to go too deep... It’s nothing to do with “Extra Effort” mode.

CITE THIS NOTEBOOK

Case checking the Pythagorean theorem​
by Brad Klee​
Wolfram Community, STAFF PICKS, November 16, 2023
​https://community.wolfram.com/groups/-/m/t/3066323