# General solution of inscribed square problem

There is my earlier question about Inscribed square problem

Now I tried to find the general solution for any curve $f(x,y)=0$.

For instance :

$\qquad \left(x^2+y^2-1\right)^3-x^2 y^3=0$

ContourPlot[(-1 + x^2 + y^2)^3 == x^2*y^3, {x, -1.4, 1.4}, {y, -1.3, 1.5},
Frame -> False, PlotPoints -> 200] There are three general conditions to find vertices of a square:

Coordinates of vertices are $(p1,k1),(p2,k2),(p3,k3),(p4,k4)$

Let

g[x_, y_] := (x^2 + y^2 - 1)^3 - x^2 y^3


$1.$ Vertex coordinates satisfy heart equation $g(x,y)=0$

eq1 = g[p1, k1] == 0;
eq2 = g[p2, k2] == 0;
eq3 = g[p3, k3] == 0;
eq4 = g[p4, k4] == 0;


$2.$ All sides have equal length.

eq5 =
EuclideanDistance[{p1, k1}, {p2, k2}] ==
EuclideanDistance[{p2, k2}, {p3, k3}] ==
EuclideanDistance[{p3, k3}, {p4, k4}] ==
EuclideanDistance[{p1, k1}, {p4, k4}];


$3.$ Every interior angle is a right angle

angle1 = VectorAngle[{p4 - p1, k4 - k1}, {p2 - p1, k2 - k1}] == Pi/2;
angle2 = VectorAngle[{p1 - p2, k1 - k2}, {p3 - p2, k3 - k2}] == Pi/2;
angle3 = VectorAngle[{p4 - p3, k4 - k3}, {p2 - p3, k2 - k3}] == Pi/2;

NSolve[eq1 && eq2 && eq3 && eq4 && eq5 && angle1 && angle2 &&
angle3, {p1, p2, p3, p4, k1, k2, k3, k4}]


How can I solve the following system of equation by using Mathematica?

g[x_, y_] := (x^2 + y^2 - 1)^3 - x^2 y^3

eq1 = g[p1, k1] == 0;
eq2 = g[p2, k2] == 0;
eq3 = g[p3, k3] == 0;
eq4 = g[p4, k4] == 0;

eq5 =
EuclideanDistance[{p1, k1}, {p2, k2}] ==
EuclideanDistance[{p2, k2}, {p3, k3}] ==
EuclideanDistance[{p3, k3}, {p4, k4}] ==
EuclideanDistance[{p1, k1}, {p4, k4}];

angle1 = VectorAngle[{p4 - p1, k4 - k1}, {p2 - p1, k2 - k1}] == Pi/2;
angle2 = VectorAngle[{p1 - p2, k1 - k2}, {p3 - p2, k3 - k2}] == Pi/2;
angle3 = VectorAngle[{p4 - p3, k4 - k3}, {p2 - p3, k2 - k3}] == Pi/2;

• You have 9 equations, and 8 variables. – Feyre Dec 25 '16 at 14:07
• You only need three equations concerning the vertex angles. If three of them are right angles, the fourth must be a right angle. – m_goldberg Dec 25 '16 at 15:20
• @m_goldberg ok, I tried 8 equation, (three equations concerning the vertex angles) but there is no answer.. – vito Jan 24 '17 at 17:09
• These problems and solutions are highly constrained. The conjecture holds for an arbitrary closed non-self-intersecting curve. How would you find the point here? PolarPlot[Cos[t] + .3 Sin[3 t] + .1 Cos[7 t - .4] + .3 Cos[9 t], {t, 0, 2 \[Pi]}] And how would one find all the inscribed squares? – David G. Stork Jul 2 '17 at 2:06