문제

Let

f[x_,y_,z_] := Sqrt[3x+1]+Sqrt[3y+1]+Sqrt[3z+1]

I want to get the minimum of f for x>=0&&y>=0&&z>=0&&x+y+z==1 using mathematica.

PS: I do know how to get the minimum by math method:

Since 0<=x<=1,0<=y<=1,0<=z<=1, we have
0<=x^2<=x,0<=y^2<=y,0<=z^2<=z.
Hence,
3a+1 >= a^2 + 2a + 1 = (a+1)^2, where a in {x,y,z}.
Consequently,
f[x,y,z] >= x+1+y+1+z+1 = 4,
Where the equality holds if and only if (x==0&&y==0||z==1)||...

PS2: I expected the following code would work, but it did't.

Minimize[{f[x,y,z],x>=0&&y>=0&&z>=0&&x+y+z==1},{x,y,z}]

Actually, as Simon point out, it works ... The running time is longer than I expected and I closed it before Mahtematica show me the result.

도움이 되었습니까?

해결책

Is this what you want?

In[1]:= f[x_,y_,z_]:=Sqrt[3x+1]+Sqrt[3y+1]+Sqrt[3z+1]
In[2]:= Minimize[{f[x,y,z],x>=0,y>=0,z>=0,x+y+z==1},{x,y,z}]
Out[2]= {4,{x->1,y->0,z->0}}

Note that the Documentation says "Even if the same minimum is achieved at several points, only one is returned" so you will have to impose the permutation symmetry of the problem yourself.


PS You can turn this into a Lagrange Multiplier problem

In[3]:= Thread[D[f[x,y,z] - \[Lambda](x+y+z-1), {{x,y,z,\[Lambda]}}]==0];
        Reduce[Join[%,{x>=0,y>=0,z>=0}],{x,y,z,\[Lambda]},Reals]
        {f[x,y,z],D[f[x, y, z], {{x, y, z}, 2}]}/.ToRules[%]
Out[4]= x==1/3&&y==1/3&&z==1/3&&\[Lambda]==3/(2 Sqrt[2])
Out[5]= {3 Sqrt[2],{{-(9/(8 Sqrt[2])),0,0},{0,-(9/(8 Sqrt[2])),0},{0,0,-(9/(8 Sqrt[2]))}}}

and see that the only stationary point is the maximum at x=y=z=1/3. Thus the minimum must lie on the boundary. You can then use similar code but restricted to the boundary to eventually find the correct result.

다른 팁

Just for fun, this is a plot of the solution given by Simon:

f[x_, y_, z_] := Sqrt[3 x + 1] + Sqrt[3 y + 1] + Sqrt[3 z + 1]
g1 = ContourPlot3D[f[x, y, z] == 4, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, AxesLabel -> {x,y,z}, MeshFunctions -> {#3 &}, ContourStyle -> {Blue, Opacity[0.5]}];
g2 = ContourPlot3D[ x + y + z == 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, AxesLabel -> {x,y,z}, MeshFunctions -> {#2 &}, ContourStyle -> {Green, Opacity[0.5]}];
Show[g1, g2, Graphics3D[{PointSize[0.05], Red, Point[{1, 0, 0}]}], ViewPoint -> {1.1`, -2.4`, 1.7`}]

alt text

You say you aren't interested in the "math method" (I'm not sure what you have in mind when you say that, but it makes me think of minimization methods with Lagrange multipliers). If that's correct, why do you bring Mathematica into the discussion? What do you think it'll be using?

I'll have to assume that you mean numerical, computer solutions. I'd start with linear programming and the simplex method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top