- 注册时间
 - 2021-11-19
 
- 最后登录
 - 1970-1-1
 
- 威望
 -  星
 
- 金币
 -  枚
 
- 贡献
 -  分
 
- 经验
 -  点
 
- 鲜花
 -  朵
 
- 魅力
 -  点
 
- 上传
 -  次
 
- 下载
 -  次
 
- 积分
 - 9927
 
- 在线时间
 -  小时
 
 
 
 
 
 
 | 
 
 楼主 |
发表于 2024-5-9 16:11:31
|
显示全部楼层
 
 
 
如上图标示的变量。 
用拉格朗日乘子法解决问题 
- Clear["Global`*"];
 
 - deg=Pi/180;(*角度制下1°所对应的弧度*)
 
 - (*子函数,利用三边计算角的余弦值,角是c边所对的角*)
 
 - cs[a_,b_,c_]:=((a^2+b^2-c^2)/(2*a*b))
 
 - (*子函数,海伦公式,利用海伦公式计算三角形的面积*)
 
 - heron[a_,b_,c_]:=Module[{p=(a+b+c)/2},Sqrt[p*(p-a)*(p-b)*(p-c)]]
 
 - cond1=Numerator@Together[cs[b,c,3*x]-Cos[60deg]](*△ABC中,对∠BAC使用余弦定理*)
 
 - cond2=Numerator@Together[cs[2*x,2,c]+cs[x,2,b]](*两个角的余弦值相加等于零*)
 
 - f=heron[b,c,3*x]^2+x1*cond1+x2*cond2//Simplify (*建立面积目标函数*)
 
 - ans=Solve[
 
 -     D[f,{{b,c,x,x1,x2}}]==0 (*求偏导数,偏导数等于零*)
 
 -     &&b>0&&c>0&&x>0(*限制变量范围*)
 
 - ,{b,c,x,x1,x2}]//FullSimplify//ToRadicals
 
 - Grid[ans,Alignment->Left](*列表显示*)
 
 - aaa=Sqrt[f/.ans]//Simplify(*求出对应的面积值*)
 
 - (*直接调用mathematica函数求解*)
 
 - Maximize[{heron[b,c,3*x],cond1==0&&cond2==0&&b>=0&&c>=0&&x>=0},{b,c,x}]
 
 
  复制代码 
 
60°约束条件1 
\[b^2-b c+c^2-9 x^2=0\] 
余弦值相加等于零约数条件2 
\[-2 b^2-c^2+6 x^2+12=0\] 
目标函数 
\[f=\text{x1} \left(b^2-b c+c^2-9 x^2\right)-\text{x2} \left(2 b^2+c^2-6 \left(x^2+2\right)\right)-\frac{1}{16} (b-c+3 x) (b+c+3 x) (b-c-3 x) (b+c-3 x)\] 
求解方程组,得到 
\[\begin{array}{lllll} 
 b\to -3 & c\to 0 & x\to -1 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to -3 & c\to 0 & x\to 1 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to -3 & c\to 6 & x\to -\sqrt{7} & \text{x1}\to \frac{9}{2} & \text{x2}\to \frac{81}{8} \\ 
 b\to -3 & c\to 6 & x\to \sqrt{7} & \text{x1}\to \frac{9}{2} & \text{x2}\to \frac{81}{8} \\ 
 b\to 0 & c\to -6 & x\to -2 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to 0 & c\to -6 & x\to 2 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to 0 & c\to 6 & x\to -2 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to 0 & c\to 6 & x\to 2 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to 3 & c\to -6 & x\to -\sqrt{7} & \text{x1}\to \frac{9}{2} & \text{x2}\to \frac{81}{8} \\ 
 b\to 3 & c\to -6 & x\to \sqrt{7} & \text{x1}\to \frac{9}{2} & \text{x2}\to \frac{81}{8} \\ 
 b\to 3 & c\to 0 & x\to -1 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to 3 & c\to 0 & x\to 1 & \text{x1}\to 0 & \text{x2}\to 0 \\ 
 b\to -\sqrt{3} & c\to -2 \sqrt{3} & x\to -1 & \text{x1}\to \frac{3}{2} & \text{x2}\to \frac{9}{8} \\ 
 b\to -\sqrt{3} & c\to -2 \sqrt{3} & x\to 1 & \text{x1}\to \frac{3}{2} & \text{x2}\to \frac{9}{8} \\ 
 b\to \sqrt{3} & c\to 2 \sqrt{3} & x\to -1 & \text{x1}\to \frac{3}{2} & \text{x2}\to \frac{9}{8} \\ 
 b\to \sqrt{3} & c\to 2 \sqrt{3} & x\to 1 & \text{x1}\to \frac{3}{2} & \text{x2}\to \frac{9}{8} \\ 
 b\to 2 (-1)^{11/12} \sqrt[4]{3} & c\to -2 \sqrt[4]{-3} & x\to 0 & \text{x1}\to \frac{3}{2} \left(1+i \sqrt{3}\right) & \text{x2}\to \frac{3}{4} \left(1+i \sqrt{3}\right) \\ 
 b\to \sqrt{6-2 i \sqrt{3}} & c\to 2 \sqrt[4]{-3} & x\to 0 & \text{x1}\to \frac{3}{2} \left(1+i \sqrt{3}\right) & \text{x2}\to \frac{3}{4} \left(1+i \sqrt{3}\right) \\ 
 b\to -2 \sqrt[12]{-1} \sqrt[4]{3} & c\to 2 i \sqrt[4]{-3} & x\to 0 & \text{x1}\to \frac{3}{2} \left(1-i \sqrt{3}\right) & \text{x2}\to \frac{3}{4} \left(1-i \sqrt{3}\right) \\ 
 b\to 2 \sqrt[12]{-1} \sqrt[4]{3} & c\to -2 i \sqrt[4]{-3} & x\to 0 & \text{x1}\to \frac{3}{2} \left(1-i \sqrt{3}\right) & \text{x2}\to \frac{3}{4} \left(1-i \sqrt{3}\right) \\ 
\end{array}\] 
由于bcx三个变量大于零,过滤后,得到 
\[\begin{array}{lllll} 
 b\to \sqrt{3} & c\to 2 \sqrt{3} & x\to 1 & \text{x1}\to \frac{3}{2} & \text{x2}\to \frac{9}{8} \\ 
\end{array}\] 
求得对应的面积 
\[\left\{\frac{3 \sqrt{3}}{2}\right\}\] 
直接调用mathematica函数,得到 
\[\left\{\frac{3 \sqrt{3}}{2},\left\{b\to \sqrt{3},c\to 2 \sqrt{3},x\to 1\right\}\right\}\] 
 
 
 
 
 
 
 
 
 
 
 
 
 |   
 
 
 
 |