拉格朗日乘数法示例8:三维曲面上的约束最优化

拉格朗日乘数法示例8:三维曲面上的约束最优化
几何画板及绘图内容加载中,请稍等……
2020-07-16 03:21
① 本范例通过三维图形直观演示拉格朗日乘数法在约束条件下求函数极值的过程,展示目标函数曲面与约束曲线(圆柱面)的交线以及最优点位置。② 核心数学概念包括多元函数极值、拉格朗日乘数法、梯度向量、约束曲线、切平面与法向量,以及偏导数方程组的求解。③ 作图要点:从构造摘要可见,使用了GeoGebra的CurveCartesian(参数曲线)、Surface(曲面)、Point(点)、Vector(向量)、Segment(线段)、Text(文本)等命令,并定义了目标函数f、约束函数g及其偏导数fx'、fy'、gx'、gy',通过梯度向量Vf、Vg和拉格朗日乘子l1、l2构建可视化,还包含按钮(button4等)和滑块(α)用于交互调节参数。④ 适合大学微积分或高等数学课程中讲解多元函数条件极值,也可用于数学建模或工程优化问题的教学演示,帮助学生理解拉格朗日乘数法的几何意义与代数求解过程。

GeoGebra 命令及参数

  1. Simplify(Derivative[f, y, 1]) → fy'
  2. Simplify(Derivative[f, x, 1]) → fx'
  3. LeftSide(Cu_g) → g
  4. Simplify(Derivative[g, y, 1]) → gy'
  5. Simplify(Derivative[g, x, 1]) → gx'
  6. Point(Cu_g) → B
  7. Vector(B, B + UnitVector[Vector[B, Dg]] / 3) → u_g
  8. Vector(B, B + UnitVector[Vector[B, Df]] / 3) → u_f
  9. Angle(u_g, u_f) → α
  10. LaTeX(f, true) → text8a
  11. LaTeX(Cu_g, true) → text8b
  12. Textfield(f) → InputBox3
  13. Textfield(Cu_g) → InputBox4
  14. CurveCartesian(sqrt(cos(t)), (0.8 - cos(t)^(2))^(0.25), f(sqrt(cos(t)), (0.8 - cos(t)^(2))^(0.25)), t, (-π), π) → q1
  15. CurveCartesian((-sqrt(cos(t))), (0.8 - cos(t)^(2))^(0.25), f(sqrt(cos(t)), (0.8 - cos(t)^(2))^(0.25)), t, (-π), π) → q2
  16. CurveCartesian(sqrt(cos(t)), (-(0.8 - cos(t)^(2))^(0.25)), f(sqrt(cos(t)), (-(0.8 - cos(t)^(2))^(0.25))), t, (-π), π) → q1a
  17. CurveCartesian((-sqrt(cos(t))), (-(0.8 - cos(t)^(2))^(0.25)), f((-sqrt(cos(t))), (-(0.8 - cos(t)^(2))^(0.25))), t, (-π), π) → q2a
  18. Textfield(n) → InputBox5
  19. Element(l1, Indexmax1) → Amax1
  20. Element(l2, Indexmax2) → Amax2
  21. Element(l1, Indexmin1) → Amin1
  22. Element(l2, Indexmin2) → Amin2
  23. Element(l1f, Indexmax1) → Amax1_{3D}
  24. Element(l2f, Indexmax2) → Amax2_{3D}
  25. Element(l1f, Indexmin1) → Amin1_{3D}
  26. Element(l2f, Indexmin2) → Amin2_{3D}
  27. LaTeX(Amin2_{3D}, true, true) → text17
  28. Zip(ScientificText[a, 4], a, z(l2f)) → l2fa
  29. Zip(ScientificText[a, 4], a, z(l1f)) → l1fa
  30. TableText(Append["N", 1…Length[l2]], Append["\fgcolor{red}{Cp}", l2], Append["\fgcolor{blue}{f}(\fgcolor{red}{C_p })", l2fa], Append["(\dot{f_x},\dot{f_y})", l2xy'_fa], Append["(\dot{g_x},\dot{g_y})", l2xy'_ga], Append["λ_x", lλ2ax], Append["λ_y", lλ2ay], Append["\widehat{\dot{g}\dot{f}} ", lα2], "c|_") → tTab2
  31. TableText(Append["N", 1…Length[l1]], Append["\fgcolor{red}{Cp}", l1], Append["\fgcolor{blue}{f}(\fgcolor{red}{C_p })", l1fa], Append["(\dot{f_x},\dot{f_y})", l1xy'_fa], Append["(\dot{g_x},\dot{g_y})", l1xy'_ga], Append["λ_x", lλ1ax], Append["λ_y", lλ1ay], Append["\widehat{\dot{g}\dot{f}} ", lα1], "c|_") → tTab1
  32. Segment(B, C) → f_1
  33. Text("∇f", Point[u_f, 1]) → text25f
  34. RotateText(text14, 90°) → text15
  35. Text("∇g", Point[u_g, 1]) → text25g
  36. Sequence(If[lα1(i) ≟ 180°, 1, lα1(i) ≟ 0° ∨ lα1(i) ≟ 360°, 2, 3], i, 1, Length[l1]) → l1_α
  37. Surface(((-0.8^(0.25)) * (1 - sin(t)^(4))^(0.25)), (0.8^(0.25) * sin(t)), u, t, 0, (2 * π), u, 0, (4 * 10^(-6))) → g02
  38. Surface((0.8^(0.25) * (1 - sin(t)^(4))^(0.25)), (0.8^(0.25) * sin(t)), u, t, (-π), π, u, 0, (4 * 10^(-6))) → g01
  39. Surface(sqrt(cos(t)), (0.8 - cos(t)^(2))^(0.25), u, t, (-π), π, u, 0, (4 * 10^(-6))) → g1
  40. Surface((-sqrt(cos(t))), (0.8 - cos(t)^(2))^(0.25), u, t, (-π), π, u, 0, (4 * 10^(-6))) → g2
  41. Surface(sqrt(cos(t)), (-(0.8 - cos(t)^(2))^(0.25)), u, t, (-π), π, u, 0, (4 * 10^(-6))) → g1a
  42. Surface((-sqrt(cos(t))), (-(0.8 - cos(t)^(2))^(0.25)), u, t, (-π), π, u, 0, (4 * 10^(-6))) → g2a
  43. RemoveUndefined(Zip[If[(abs(x(A)) * 10^(15)) < 1 ∧ (abs(y(A)) * 10^(15)) < 1, b, (NaN, NaN)], A, l1xy'_f, b, l1]) → l1_{loc}
  44. RemoveUndefined(Zip[If[(abs(x(l2xy'_f(k))) * 10^(14)) < 1 ∧ (abs(y(l2xy'_f(k))) * 10^(14)) < 1, k, NaN], k, 1…Length[l2]]) → l2_{loc}N
  45. RemoveUndefined(Zip[If[(abs(x(l1xy'_f(k))) * 10^(14)) < 1 ∧ (abs(y(l1xy'_f(k))) * 10^(14)) < 1, k, NaN], k, 1…Length[l1]]) → l1_{loc}N
  46. RemoveUndefined(Sequence[If[lα1(i) ≟ 180°, i, NaN], i, 1, Length[l1]]) → l1_πN
  47. RemoveUndefined(Sequence[If[lα2(i) ≟ 180°, i, NaN], i, 1, Length[l2]]) → l2_πN
  48. RemoveUndefined(Sequence[If[lα2(i) ≟ 180°, l2(i), NaN], i, 1, Length[l2]]) → l2_π
  49. RemoveUndefined(Sequence[If[lα1(i) ≟ 180°, l1(i), NaN], i, 1, Length[l1]]) → l1_π
  50. RemoveUndefined(Sequence[If[lα2(i) ≟ 180°, l2f(i), NaN], i, 1, Length[l2]]) → l2_{π3D}
  51. RemoveUndefined(Sequence[If[lα1(i) ≟ 180°, l1f(i), NaN], i, 1, Length[l1]]) → l1_{π3D}
  52. Sequence(Text[i, l2(i) + (0.05, 0.1)], i, 1, lä2) → l2txt
  53. Zip(Segment[a, b], a, l2, b, l2f) → l2seg
  54. Zip(Segment[a, b], a, l1, b, l1f) → l1seg
  55. Sequence(Text[i, l1(i) + (0.05, 0.1)], i, 1, lä1) → l1txt
  56. RemoveUndefined(Zip[If[(abs(x(A)) * 10^(14)) < 1 ∧ (abs(y(A)) * 10^(14)) < 1, b, (NaN, NaN)], A, l2xy'_f, b, l2]) → l2_{loc}
  57. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 3], a, l1xy'_f, c, l1]) → lvec1_f
  58. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 3], a, l1xy'_g, c, l1]) → lvec1_g
  59. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 3], a, l2xy'_f, c, l2]) → lvec2_f
  60. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 3], a, l2xy'_g, c, l2]) → lvec2_g
  61. RemoveUndefined(Zip[If[(abs(x(A)) * 10^(14)) < 1 ∧ (abs(y(A)) * 10^(14)) < 1, b, (NaN, NaN)], A, l2xy'_f, b, l2f]) → l2_{loc3D}
  62. RemoveUndefined(Zip[If[(abs(x(A)) * 10^(14)) < 1 ∧ (abs(y(A)) * 10^(14)) < 1, b, (NaN, NaN)], A, l1xy'_f, b, l1f]) → l1_{loc3D}
  63. Simplify(fy'(x, y) - (gy'(x, y) * fx'(x, y) / gx'(x, y))) → Cu_yf
  64. Simplify(fx'(x, y) - (gx'(x, y) * fy'(x, y) / gy'(x, y))) → Cu_xf
  65. Textfield(txtCu01_x) → InputBox1
  66. Textfield(txtCu01_y) → InputBox2

AI 绘图提示语参考

绘制一个三维曲面,该曲面由函数f(x,y)定义,同时包含一个约束曲面g(x,y)。首先绘制f(x,y)的等高线,然后绘制g(x,y)的等高线,接着找到f(x,y)和g(x,y)的交点,标记出这些交点,并在这些点处绘制梯度向量。最后,通过调整参数α,观察梯度向量之间的夹角变化,理解拉格朗日乘数法在条件极值问题中的应用。
以上提示语为根据原始绘图命令整理而来,仅供参考。