mathematica 发表于 2021-1-20 15:37:31

本帖最后由 mathematica 于 2021-1-20 15:56 编辑

Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
(*把三维空间中的三角形转化成球面a^2+b^2+c^2==1*)
fun=(2*a^2-b^2)(2*b^2-c^2)(2*c^2-a^2)+x*(a^2+b^2+c^2-1);
(*求解偏导数,解方程组*)
ans=Solve==0,{a,b,c,x}];
Grid;
(*求解原来的变量值,以及对应函数值*)
aaa=Union@FullSimplify[{a^2,b^2,c^2,fun}/.ans];
(*增加一列,是函数值的数值化*)
bbb=Append[#,N[#[]]]&/@aaa;
(*按照第四列从大到小排序*)
ccc=Sort]>#2[]&];
Grid


拉格朗日方程组的解

解太多,此处略去


原来的函数值的最大最小值
\[
\begin{array}{lllll}
\frac{1}{9} \left(\sqrt{7}+5\right) & 0 & \frac{1}{9} \left(4-\sqrt{7}\right) & \frac{4}{243} \left(7 \sqrt{7}-10\right) & 0.140251 \\
\frac{1}{9} \left(4-\sqrt{7}\right) & \frac{1}{9} \left(\sqrt{7}+5\right) & 0 & \frac{4}{243} \left(7 \sqrt{7}-10\right) & 0.140251 \\
0 & \frac{1}{9} \left(4-\sqrt{7}\right) & \frac{1}{9} \left(\sqrt{7}+5\right) & \frac{4}{243} \left(7 \sqrt{7}-10\right) & 0.140251 \\
\frac{1}{3} & \frac{1}{3} & \frac{1}{3} & \frac{1}{27} & 0.037037 \\
1 & 0 & 0 & 0 & 0. \\
\frac{4}{7} & \frac{1}{7} & \frac{2}{7} & 0 & 0. \\
\frac{2}{7} & \frac{4}{7} & \frac{1}{7} & 0 & 0. \\
\frac{1}{7} & \frac{2}{7} & \frac{4}{7} & 0 & 0. \\
0 & 1 & 0 & 0 & 0. \\
0 & 0 & 1 & 0 & 0. \\
\frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{9} \left(5-\sqrt{7}\right) & 0 & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) & -0.469469 \\
\frac{1}{9} \left(5-\sqrt{7}\right) & 0 & \frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) & -0.469469 \\
0 & \frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{9} \left(5-\sqrt{7}\right) & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) & -0.469469 \\
\end{array}
\]


如果单纯地用拉格朗日乘子法,求解出来的结果不对。
代码如下
Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
fun=(2*a-b)(2*b-c)(2*c-a)+x*(a+b+c-1);
(*求解偏导数,解方程组*)
ans=Solve==0,{a,b,c,x}];
Grid
(*求解原来的变量值,以及对应函数值*)
aaa=FullSimplify[{a,b,c,fun}/.ans];
(*增加一列,是函数值的数值化*)
bbb=Append[#,N[#[]]]&/@aaa;
(*按照第四列从大到小排序*)
ccc=Sort]>#2[]&];
Grid

求解结果如下:
\[\begin{array}{lllll}
\frac{1}{3} & \frac{1}{3} & \frac{1}{3} & \frac{1}{27} & 0.037037 \\
\frac{4}{7} & \frac{1}{7} & \frac{2}{7} & 0 & 0. \\
\frac{2}{7} & \frac{4}{7} & \frac{1}{7} & 0 & 0. \\
\frac{1}{7} & \frac{2}{7} & \frac{4}{7} & 0 & 0. \\
\end{array}\]

在边界上的最值,理论上还有检测abc当中有两个等于零的情况,以及三个等于零的情况,但是不演示了
(*在边界上查看最值*)
Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
c=0;(*三个边界感觉对称,只假设其中一个等于零就可以了*)
fun=(2*a-b)(2*b-c)(2*c-a)+x*(a+b+c-1);
(*求解偏导数,解方程组*)
ans=Solve==0,{a,b,x}];
Grid
(*求解原来的变量值,以及对应函数值*)
aaa=FullSimplify[{a,b,c,fun}/.ans];
(*增加一列,是函数值的数值化*)
bbb=Append[#,N[#[]]]&/@aaa;
(*按照第四列从大到小排序*)
ccc=Sort]>#2[]&];
Grid

求解结果
\[
\begin{array}{lllll}
\frac{1}{9} \left(4-\sqrt{7}\right) & \frac{1}{9} \left(\sqrt{7}+5\right) & 0 & \frac{4}{243} \left(7 \sqrt{7}-10\right) & 0.140251 \\
\frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{9} \left(5-\sqrt{7}\right) & 0 & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) & -0.469469 \\
\end{array}
\]




mathematica 发表于 2021-1-20 16:01:00

mathematica 发表于 2021-1-20 15:37
拉格朗日方程组的解

解太多,此处略去


类似问题
已知a^2+b^2+c^2=1,求(a-b)(b-c)(c-a)的最小值
https://bbs.emath.ac.cn/forum.php?mod=viewthread&tid=17456&fromuid=865

mathematica 发表于 2021-1-21 08:48:05

本帖最后由 mathematica 于 2021-1-21 08:50 编辑

利用kkt条件来吊打你这个问题!

(*利用KKT条件来解决问题*)
Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
(*定义函数*)
fun=(2*a-b)(2*b-c)(2*c-a)+x*(a+b+c-1)-x1*a-x2*b-x3*c;
(*求解所有可能的点,其实应该还限制abc都大于等于零*)
ans=FullSimplify@Solve==0&&x1*a==0&&x2*b==0&&x3*c==0,{a,b,c,x,x1,x2,x3}];
aaa=Append[#,FullSimplify[(fun/.#)]]&/@ans;(*增加一列函数值*)
bbb=Sort]>#2[]&];(*按照函数值降序排列*)
Grid
Grid



解析解
\[\begin{array}{llllllll}
a\to \frac{1}{9} \left(4-\sqrt{7}\right) & b\to \frac{1}{9} \left(\sqrt{7}+5\right) & c\to 0 & x\to \frac{1}{81} (-4) \left(7 \sqrt{7}-10\right) & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to \frac{1}{81} (-7) \left(13 \sqrt{7}-7\right) & \frac{4}{243} \left(7 \sqrt{7}-10\right) \\
a\to \frac{1}{9} \left(\sqrt{7}+5\right) & b\to 0 & c\to \frac{1}{9} \left(4-\sqrt{7}\right) & x\to \frac{1}{81} (-4) \left(7 \sqrt{7}-10\right) & \text{x1}\to 0 & \text{x2}\to \frac{1}{81} (-7) \left(13 \sqrt{7}-7\right) & \text{x3}\to 0 & \frac{4}{243} \left(7 \sqrt{7}-10\right) \\
a\to 0 & b\to \frac{1}{9} \left(4-\sqrt{7}\right) & c\to \frac{1}{9} \left(\sqrt{7}+5\right) & x\to \frac{1}{81} (-4) \left(7 \sqrt{7}-10\right) & \text{x1}\to \frac{1}{81} (-7) \left(13 \sqrt{7}-7\right) & \text{x2}\to 0 & \text{x3}\to 0 & \frac{4}{243} \left(7 \sqrt{7}-10\right) \\
a\to \frac{1}{3} & b\to \frac{1}{3} & c\to \frac{1}{3} & x\to -\frac{1}{9} & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to 0 & \frac{1}{27} \\
a\to 1 & b\to 0 & c\to 0 & x\to 0 & \text{x1}\to 0 & \text{x2}\to -4 & \text{x3}\to 2 & 0 \\
a\to \frac{4}{7} & b\to \frac{1}{7} & c\to \frac{2}{7} & x\to 0 & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to 0 & 0 \\
a\to \frac{2}{7} & b\to \frac{4}{7} & c\to \frac{1}{7} & x\to 0 & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to 0 & 0 \\
a\to \frac{1}{7} & b\to \frac{2}{7} & c\to \frac{4}{7} & x\to 0 & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to 0 & 0 \\
a\to 0 & b\to 1 & c\to 0 & x\to 0 & \text{x1}\to 2 & \text{x2}\to 0 & \text{x3}\to -4 & 0 \\
a\to 0 & b\to 0 & c\to 1 & x\to 0 & \text{x1}\to -4 & \text{x2}\to 2 & \text{x3}\to 0 & 0 \\
a\to \frac{1}{9} \left(\sqrt{7}+4\right) & b\to \frac{1}{9} \left(5-\sqrt{7}\right) & c\to 0 & x\to \frac{4}{81} \left(7 \sqrt{7}+10\right) & \text{x1}\to 0 & \text{x2}\to 0 & \text{x3}\to \frac{7}{81} \left(13 \sqrt{7}+7\right) & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) \\
a\to \frac{1}{9} \left(5-\sqrt{7}\right) & b\to 0 & c\to \frac{1}{9} \left(\sqrt{7}+4\right) & x\to \frac{4}{81} \left(7 \sqrt{7}+10\right) & \text{x1}\to 0 & \text{x2}\to \frac{7}{81} \left(13 \sqrt{7}+7\right) & \text{x3}\to 0 & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) \\
a\to 0 & b\to \frac{1}{9} \left(\sqrt{7}+4\right) & c\to \frac{1}{9} \left(5-\sqrt{7}\right) & x\to \frac{4}{81} \left(7 \sqrt{7}+10\right) & \text{x1}\to \frac{7}{81} \left(13 \sqrt{7}+7\right) & \text{x2}\to 0 & \text{x3}\to 0 & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) \\
\end{array}\]


数值化后
\[\begin{array}{llllllll}
a\to 0.150472 & b\to 0.849528 & c\to 0. & x\to -0.420754 & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to -2.36745 & 0.140251 \\
a\to 0.849528 & b\to 0. & c\to 0.150472 & x\to -0.420754 & \text{x1}\to 0. & \text{x2}\to -2.36745 & \text{x3}\to 0. & 0.140251 \\
a\to 0. & b\to 0.150472 & c\to 0.849528 & x\to -0.420754 & \text{x1}\to -2.36745 & \text{x2}\to 0. & \text{x3}\to 0. & 0.140251 \\
a\to 0.333333 & b\to 0.333333 & c\to 0.333333 & x\to -0.111111 & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to 0. & 0.037037 \\
a\to 1. & b\to 0. & c\to 0. & x\to 0. & \text{x1}\to 0. & \text{x2}\to -4. & \text{x3}\to 2. & 0. \\
a\to 0.571429 & b\to 0.142857 & c\to 0.285714 & x\to 0. & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to 0. & 0. \\
a\to 0.285714 & b\to 0.571429 & c\to 0.142857 & x\to 0. & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to 0. & 0. \\
a\to 0.142857 & b\to 0.285714 & c\to 0.571429 & x\to 0. & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to 0. & 0. \\
a\to 0. & b\to 1. & c\to 0. & x\to 0. & \text{x1}\to 2. & \text{x2}\to 0. & \text{x3}\to -4. & 0. \\
a\to 0. & b\to 0. & c\to 1. & x\to 0. & \text{x1}\to -4. & \text{x2}\to 2. & \text{x3}\to 0. & 0. \\
a\to 0.738417 & b\to 0.261583 & c\to 0. & x\to 1.40841 & \text{x1}\to 0. & \text{x2}\to 0. & \text{x3}\to 3.57733 & -0.469469 \\
a\to 0.261583 & b\to 0. & c\to 0.738417 & x\to 1.40841 & \text{x1}\to 0. & \text{x2}\to 3.57733 & \text{x3}\to 0. & -0.469469 \\
a\to 0. & b\to 0.738417 & c\to 0.261583 & x\to 1.40841 & \text{x1}\to 3.57733 & \text{x2}\to 0. & \text{x3}\to 0. & -0.469469 \\
\end{array}\]

补充内容 (2021-1-26 10:36):
这个做法最标准最好了!

补充内容 (2021-1-26 10:36):
只不过还需要用不等式过滤条件过滤一下!

mathematica 发表于 2021-1-25 12:47:05

先消去变量c,只留下两个变量,这样有利于简化问题。

Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
(*定义函数*)
fun=(2*a-b)(2*b-c)(2*c-a)/.c->(1-a-b);
(*求解变量值,以及对应的函数值*)
ans={a,b,1-a-b,fun}/.Solve==0,{a,b}];
Grid
Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
(*考虑在边界b=0的情况下的最优值*)
b=0;
fun=(2*a-b)(2*b-c)(2*c-a)/.{c->1-a-b};
(*求解变量值,以及对应的函数值*)
ans={a,b,1-a-b,fun}/.Solve==0,{a}]//FullSimplify;
Grid
Clear["Global`*"];(*mathematica11.2,win7(64bit)Clear all variables*)
(*考虑在边界a=0的情况下的最优值*)
a=0;
fun=(2*a-b)(2*b-c)(2*c-a)/.{c->1-a-b};
(*求解变量值,以及对应的函数值*)
ans={a,b,1-a-b,fun}/.Solve==0,{b}]//FullSimplify;
Grid


很显然函数值是有界的,求出所有的可能的极值点,那么最大值就是最大值,最小值就是函数的最小值
非边界的极值点
\[\begin{array}{llll}
\frac{1}{7} & \frac{2}{7} & \frac{4}{7} & 0 \\
\frac{2}{7} & \frac{4}{7} & \frac{1}{7} & 0 \\
\frac{1}{3} & \frac{1}{3} & \frac{1}{3} & \frac{1}{27} \\
\frac{4}{7} & \frac{1}{7} & \frac{2}{7} & 0 \\
\end{array}
\]

边界b=0上的极值点
\[\begin{array}{llll}
\frac{1}{9} \left(5-\sqrt{7}\right) & 0 & \frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) \\
\frac{1}{9} \left(\sqrt{7}+5\right) & 0 & \frac{1}{9} \left(4-\sqrt{7}\right) & \frac{4}{243} \left(7 \sqrt{7}-10\right) \\
\end{array}
\]

边界a=0上的极值点
\[\begin{array}{llll}
0 & \frac{1}{9} \left(4-\sqrt{7}\right) & \frac{1}{9} \left(\sqrt{7}+5\right) & \frac{4}{243} \left(7 \sqrt{7}-10\right) \\
0 & \frac{1}{9} \left(\sqrt{7}+4\right) & \frac{1}{9} \left(5-\sqrt{7}\right) & \frac{1}{243} (-4) \left(7 \sqrt{7}+10\right) \\
\end{array}
\]
当a=b=0的时候,函数值等于零!
页: 1 2 3 4 5 6 7 [8]
查看完整版本: 一个代数不等式