# How to solve this simple equation?

I want to minimize a quadratic equation, but Mathematica does not solve it and only rewrites the solution. I wonder if there exist any way I can skip the computation by hand (I can solve it using Lagrangian method, but it is too long).

y = {y1, y2, y3}
yp = {yp1, yp2, yp3}
ypp = {ypp1, ypp2, ypp3}
Minimize[{(ypp1 - yp1)^2 + (ypp2 - yp2)^2 + (ypp3 - yp3)^2,
Mean[ypp] == 0 && Variance[ypp] == 1}, ypp]

• I'd shift ypp and work out the new mean and variance, then use Minimize[{Total[(ypp)^2], Mean[ypp] == a, Simplify[Variance[ypp], Assumptions -> {ypp \[Element] Reals}] == b}, ypp, Reals]. May 26 '13 at 16:27
• This is a repeat of this question: mathematica.stackexchange.com/questions/25845/… (last version in the answer) May 26 '13 at 16:30
• @bills You can vote to mark it as a duplicate. To do that (in case you don't know), click the "close" link > duplicate > enter the URL of the question.
– rm -rf
May 26 '13 at 16:38
• But the program above produces: Minimize::infeas: There are no values of {ypp1,ypp2,ypp3} for which the constraints 1/3 (ypp1+ypp2+ypp3)==0&&1/3 (ypp1^2+ypp2^2-ypp2 ypp3+ypp3^2-ypp1 (ypp2+ypp3))=={5,3,6,3} are satisfied and the objective function ypp1^2+ypp2^2+ypp3^2 is real valued.
– remo
May 26 '13 at 16:42
• @bill I believe there is a difference. yp1, yp2, and yp3 are symbolical here, contrary to v in your previous answer, and you don't get a result. May 26 '13 at 18:59

Firstly, variance uses Conjugate and that stumbles Minimize if ypp is symbolic. It can be mended with ComplexExpand. Secondly, evaluation is going for long. I supect it is due to many variants of relative positions of yp components. Setting the order explicitely, say yp1<yp2<yp3, gives the result:

y = {y1, y2, y3}
yp = {yp1, yp2, yp3}
ypp = {ypp1, ypp2, ypp3}
Minimize[{(ypp1 - yp1)^2 + (ypp2 - yp2)^2 + (ypp3 - yp3)^2,
Mean[ypp] == 0 && Variance[ypp] == 1 // ComplexExpand,  yp1 < yp2 < yp3}, ypp][[1, 1, 1, 1]]


$$-\frac{4 \sqrt{\text{yp1}^2-\text{yp1} \text{yp2}-\text{yp1} \text{yp3}+\text{yp2}^2-\text{yp2} \text{yp3}+\text{yp3}^2}}{\sqrt{3}}+\text{yp1}^2+\text{yp2}^2+\text{yp3}^2+2$$

• Thanks a lot. It's really wonderful why such a simple question takes too long.
– remo
May 26 '13 at 17:14
• Nice trick. (+1) May 26 '13 at 19:01