One familiar proof of the Pythagorean theorem (for right triangles, +=) 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.
2
a
2
b
2
c
Machine Precision
Machine Precision
In[]:=
abSq=Polygon[N@{{0,0},{1,0},{1,1},{0,1}}]
Out[]=
Polygon
In[]:=
cSq=Polygon[N[{{#,0},{1,#},{1-#,1},{0,1-#}}&[slider=RandomReal[1]]]]
Out[]=
Polygon
First, the right-hand side:
First, the right-hand side:
In[]:=
Graphics[{Opacity[0],EdgeForm[Black],abSq,cSq}]
Out[]=
In[]:=
triangles=RegionDifference[abSq,cSq]
Out[]=
Polygon
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,Polygon,Polygon,Polygon
Next, the left-hand side:
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,Polygon
In[]:=
Graphics[res]
Out[]=
Final checks
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
Infinite Precision
Now useless:
Now useless:
Continue:
Continue:
Passes inspection:
Passes inspection:
Bad hacking:
Bad hacking:
(keep these failures for later)
(keep these failures for later)
Final checks
Final checks
Post script
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
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
by Brad Klee
Wolfram Community, STAFF PICKS, November 16, 2023
https://community.wolfram.com/groups/-/m/t/3066323