如何求 Sqrt[3x+1]+Sqrt[3y+1]+Sqrt[3z+1] 的最小值?

发布于 2024-10-04 11:20:58 字数 748 浏览 7 评论 0原文

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

我想使用mathematica 获得 x>=0&&y>=0&&z>=0&&x+y+z==1 的 f 的最小值。

PS:我确实知道如何通过数学方法获得最小值:

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:我预计以下代码会起作用,但它没有。

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

实际上,正如 Simon 指出的那样,它是有效的......运行时间比我预期的要长,我在 Mahtematica 向我展示结果之前关闭了它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

莫相离 2024-10-11 11:20:58

这是你想要的吗?

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}}

请注意,文档中说“即使在多个点达到相同的最小值,也只会返回一个”,因此您必须自己强加问题的排列对称性。


聚苯乙烯
您可以将其转化为拉格朗日乘子问题

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]))}}}

,并看到唯一的驻点是 x=y=z=1/3 处的最大值。因此最小值必须位于边界上。然后,您可以使用类似的代码,但仅限于边界,最终找到正确的结果。

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.

遮云壑 2024-10-11 11:20:58

只是为了好玩,这是西蒙给出的解决方案的图:

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

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

小糖芽 2024-10-11 11:20:58

你说你对“数学方法”不感兴趣(我不确定你这么说时的想法,但这让我想到了拉格朗日乘子的最小化方法)。如果这是正确的,你为什么要把 Mathematica 纳入讨论呢?你认为它会用来做什么?

我必须假设你指的是数字的计算机解决方案。我将从线性规划和单纯形法开始。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文