How to minimize $(x-1)^2+(y-1)^2+(z-1)^2$ under the constraint $xyz=s$? Let $s \in (0,1)$ be a parameter.
Can we find an exact closed form expression for
$$
F(s)=\min_{xyz=s,x,y,z>0}(x-1)^2+(y-1)^2+(z-1)^2, \tag{1}
$$
and exact formulas the minimizers $x(s) \le y(s) \le z(s)$?
I tried using Mathematica but failed (However I am not very skillful).

Using Lagrange's multipliers, one gets
$$
(x-1,y-1,z-1)=\lambda (\frac{1}{x},\frac{1}{y},\frac{1}{z}),
$$
so $x,y,z$ should all satisfy the quadratic equation $t(1-t)=-\lambda$. If $t$ is a solution then so is $1-t$; thus, if we denote the solution of this equation by $a$, then
$$
\{x,y,z\} \subseteq \{a,1-a \}.
$$
One possible solution is the symmetric solution $x=y=z=\sqrt[3] s$. If $x,y,z$ do not all coincide, then they must take both values $a$ and $1-a$.
Since we required $x,y,z>0$ this means that $a,1-a$ should be positive, so $0<a<1$.
After a possible a renaming/switching, we may assume that $x=a, y=z=1-a$, so the value $1-a$ is attained twice.
So, if we define,
$$
G(s)=\min_{a \in (0,1),a(1-a)^{2}=s} (1-a)^2+2a^2, \tag{2}
$$
then
$$
F(s)=\min \{3(1-\sqrt[3]s)^2,G(s)\}.
$$
Since $\max_{a \in (0,1)}a(1-a)^{2}=4/27$, it follows that the non-symmetric solution is possible only if $s \le 4/27$.
The term $3(1-\sqrt[3]s)^2$ comes from comparing with the symmetric solution $x=y=s$.
I am not sure how to continue, since analyzing explicitly the solutions to the quintic equation is not so nice.
Motivation:
This problem is a special case of the problem of finding the closest matrix to $\text{SO}_n$ with a given determinant.
 A: The real solutions of
$$x(1-x)^2=s$$ are not bad at all.
We have
$$\Delta=(4-27 s) s$$ which is positive in a small region $(0 < s < \frac 4{27})$.
$$s<0 \quad \implies \quad x=-\frac{4}{3} \sinh ^2\left(\frac{1}{6} \cosh
   ^{-1}\left(1-\frac{27 s}{2}\right)\right)$$
$$s> \frac 4{27} \quad \implies \quad x=\frac{4}{3} \cosh ^2\left(\frac{1}{6} \cosh ^{-1}\left(\frac{27
   s}{2}-1\right)\right)$$
Otherwise
$$x_k=\frac{4}{3} \cos ^2\left(\frac{1}{6} \left(2 \pi  k-\cos
   ^{-1}\left(\frac{27 s}{2}-1\right)\right)\right) \qquad k=0,1,2$$
The last case
$$s=\frac 4{27}\quad \implies \quad x_1=x_2=\frac 13\qquad x_3=\frac 43$$
A: You need to solve $$\nabla ((x-1)^2+(y-1)^2+(z-1)^2)=\lambda \nabla (xyz-s)$$ $$[2(x-1),2(y-1),2(z-1)]=[\lambda yz,\lambda xz, \lambda xy]$$ Equating $\lambda /2$ for the first and second terms, we have $$\frac {x-1}{yz}=\frac {y-z}{xz}$$ Note that the constraint $xyz=s $ guarantees that $x,y,z$ are all non-zero. A bit of algebra gives $$x^2-y^2=x-y$$ so $x=y$ or $x+y=1.$Similarly, by comparing first and third or second and third terms in the gradient equation, we obtain $x=z $ or $x+z=1$ and $y=z$ or $y+z=1$ respectively.If $x=y=z$ we have $x=y=z=s^{1/3}.$ If $x+y=1,x+z=1,y+z=1$ we have $x=y=z=1/2$ which is a contradiction unless $s=1/8$, if $s=1/8$ we have the previous point.If $x=y, x+z=1$, that gives $x^2z=s,x+s/x^2=1,x^3-x^2+s=0$ which is a cubic equation that we can solve by the metods of Cardano and his contemporaries.We obtain similar cubic equations for the cases $y=z,y+x=1$ and $z=x,z+y=1$. At each point $x,y,z$ we calculate $(x-1)^2+(y-1)^2+(z-1)^2$and take the minimumof these values.
