- 注册时间
- 2021-11-19
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 8861
- 在线时间
- 小时
|
楼主 |
发表于 2024-11-13 08:41:59
|
显示全部楼层
我只会拉格朗日乘子法。
- Clear["Global`*"];(*清除所有变量*)
- (*拉格朗日乘子法建立目标函数*)
- f=3*sa+4*sb+18(sa*cb+ca*sb)+m*(sa^2+ca^2-1)+n*(sb^2+cb^2-1)
- (*求偏导数,求解方程组*)
- ans=Solve[D[f,{{sa,ca,sb,cb,m,n}}]==0,{sa,ca,sb,cb,m,n}]//FullSimplify//ToRadicals
- Grid[ans,Alignment->Left](*列表显示*)
- N@%
- (*目标函数值*)
- aaa=(f/.ans)//FullSimplify
- N@%
复制代码
方程组求解结果
\[\begin{array}{llllll}
\text{sa}\to -\frac{\sqrt{7}}{4} & \text{ca}\to \frac{3}{4} & \text{sb}\to -\frac{1}{16} \left(5 \sqrt{7}\right) & \text{cb}\to \frac{9}{16} & m\to \frac{15 \sqrt{7}}{4} & n\to 4 \sqrt{7} \\
\text{sa}\to \frac{\sqrt{7}}{4} & \text{ca}\to \frac{3}{4} & \text{sb}\to \frac{5 \sqrt{7}}{16} & \text{cb}\to \frac{9}{16} & m\to -\frac{1}{4} \left(15 \sqrt{7}\right) & n\to -4 \sqrt{7} \\
\text{sa}\to -\sqrt{\frac{256 \sqrt{37}}{81}-\frac{1535}{81}} & \text{ca}\to \frac{4}{9} \left(\sqrt{37}-8\right) & \text{sb}\to \frac{1}{3} (-2) \sqrt{4 \sqrt{37}-23} & \text{cb}\to \frac{1}{3} \left(\sqrt{37}-8\right) & m\to \frac{1}{2} (-3) \sqrt{4 \sqrt{37}+5} & n\to -\sqrt{16 \sqrt{37}-43} \\
\text{sa}\to \frac{1}{9} \sqrt{256 \sqrt{37}-1535} & \text{ca}\to \frac{4}{9} \left(\sqrt{37}-8\right) & \text{sb}\to \frac{2}{3} \sqrt{4 \sqrt{37}-23} & \text{cb}\to \frac{1}{3} \left(\sqrt{37}-8\right) & m\to \frac{3}{2} \sqrt{4 \sqrt{37}+5} & n\to \sqrt{16 \sqrt{37}-43} \\
\text{sa}\to \frac{1}{9} i \sqrt{256 \sqrt{37}+1535} & \text{ca}\to \frac{1}{9} (-4) \left(\sqrt{37}+8\right) & \text{sb}\to \frac{1}{3} (-2) i \sqrt{4 \sqrt{37}+23} & \text{cb}\to \frac{1}{3} \left(-\sqrt{37}-8\right) & m\to \frac{1}{2} (-3) i \sqrt{4 \sqrt{37}-5} & n\to i \sqrt{16 \sqrt{37}+43} \\
\text{sa}\to -\frac{1}{9} i \sqrt{256 \sqrt{37}+1535} & \text{ca}\to \frac{1}{9} (-4) \left(\sqrt{37}+8\right) & \text{sb}\to \frac{2}{3} i \sqrt{4 \sqrt{37}+23} & \text{cb}\to \frac{1}{3} \left(-\sqrt{37}-8\right) & m\to \frac{3}{2} i \sqrt{4 \sqrt{37}-5} & n\to -i \sqrt{16 \sqrt{37}+43} \\
\end{array}\]
数值化
\[\begin{array}{llllll}
\text{sa}\to -0.661438 & \text{ca}\to 0.75 & \text{sb}\to -0.826797 & \text{cb}\to 0.5625 & m\to 9.92157 & n\to 10.583 \\
\text{sa}\to 0.661438 & \text{ca}\to 0.75 & \text{sb}\to 0.826797 & \text{cb}\to 0.5625 & m\to -9.92157 & n\to -10.583 \\
\text{sa}\to -0.52337 & \text{ca}\to -0.852106 & \text{sb}\to -0.769141 & \text{cb}\to -0.639079 & m\to -8.12372 & n\to -7.3705 \\
\text{sa}\to 0.52337 & \text{ca}\to -0.852106 & \text{sb}\to 0.769141 & \text{cb}\to -0.639079 & m\to 8.12372 & n\to 7.3705 \\
\text{sa}\to 0.\, +6.1786 i & \text{ca}\to -6.25901 & \text{sb}\to 0.\, -4.5865 i & \text{cb}\to -4.69425 & m\to 0.\, -6.59506 i & n\to 0.\, +11.8459 i \\
\text{sa}\to 0.\, -6.1786 i & \text{ca}\to -6.25901 & \text{sb}\to 0.\, +4.5865 i & \text{cb}\to -4.69425 & m\to 0.\, +6.59506 i & n\to 0.\, -11.8459 i \\
\end{array}\]
函数值
\[\left\{-\frac{1}{4} \left(35 \sqrt{7}\right),\frac{35 \sqrt{7}}{4},\frac{1}{3} \sqrt{148 \sqrt{37}+661},-\frac{1}{3} \sqrt{148 \sqrt{37}+661},-\frac{1}{3} i \sqrt{148 \sqrt{37}-661},\frac{1}{3} i \sqrt{148 \sqrt{37}-661}\right\}\]
数值化
{-23.1503, 23.1503, 13.1709, -13.1709, 0. - 5.15589 I, 0. + 5.15589 I}
很显然第二个是最大值。
|
|