There are three possible orientations for the largest square inside an equilateral triangle, by symmetry.
There are also three possible orientations for the largest square inside a special isosceles triangle called the Calabi triangle. (see wikipedia).
base of Calabi Triangle, assuming sides have length 1
In[1]:= base = x /. Solve[2 x^3 - 2 x^2 - 3 x + 2 == 0, x, Reals][[3]]
Out[1]= Root[2 - 3 #1 - 2 #1^2 + 2 #1^3 &, 3]
height of triangle
In[2]:= height = y /. Solve[y^2 + (base/2)^2 == 1, y][[2]]
Out[2]= 1/2 Sqrt[4 - Root[2 - 3 #1 - 2 #1^2 + 2 #1^3 &, 3]^2]
vertices of triangle
In[3]:= ctrip = Polygon[{{-base/2, 0}, {base/2, 0}, {0, height}}];
square centered at {xc,yc} with side a, rotated by angle \[Theta]
In[4]:= sqr[{xc_, yc_}, a_, \[Theta]_] =
Polygon[(a/2 (RotationMatrix[\[Theta]].#) & /@ {{-1, -1}, {-1, 1}, {1,
1}, {1, -1}}) /. {x_, y_} -> {x + xc, y + yc}];
Find the three orientations
In[5]:= sln1 = FindMaximum[{a,
RegionWithin[ctrip, sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta],
0}, {xc, 0}, {yc, 0}}]
Out[5]= {0.448612, {a -> 0.448612, \[Theta] -> -5.33582*10^-21, xc -> -4.00508*10^-17,
yc -> 0.224306}}
In[13]:= p1 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln1[[2]],
ImageSize -> Small];
In[7]:= sln2 = FindMaximum[{a,
RegionWithin[ctrip,
sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta], .6}, {xc, 0}, {yc,
0}}]
Out[7]= {0.448612, {a -> 0.448612, \[Theta] -> 0.682984, xc -> -0.0324308,
yc -> 0.315555}}
In[14]:= p2 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln2[[2]],
ImageSize -> Small];
In[9]:= sln3 = FindMaximum[{a,
RegionWithin[ctrip, sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta],
2 \[Pi] - .6}, {xc, 0}, {yc, 0}}]
Out[9]= {0.448612, {a -> 0.448612, \[Theta] -> 5.6002, xc -> 0.0324308,
yc -> 0.315555}}
In[15]:= p3 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln3[[2]],
ImageSize -> Small];
Check equality of square sizes
In[11]:= {sln1[[1]] - sln2[[1]], sln1[[1]] - sln3[[1]], sln2[[1]] - sln3[[1]]}
Out[11]= {-7.72961*10^-9, -7.72961*10^-9, 5.55112*10^-17}