Lagrange Multipliers Example 8: Constrained Optimization on a 3D Surface

Lagrange Multipliers Example 8: Constrained Optimization on a 3D Surface
Loading the math board and drawing, please wait…
2020-07-16 03:21
① This example visually demonstrates the method of Lagrange multipliers for finding extrema of a function subject to a constraint, showing the intersection of the objective surface with a constraint cylinder and the optimal point. ② Core mathematical concepts include multivariable optimization, Lagrange multipliers, gradient vectors, constraint curves, tangent planes, and solving systems of partial derivative equations. ③ Construction highlights: Based on the construction summary, GeoGebra commands such as CurveCartesian (parametric curves), Surface, Point, Vector, Segment, and Text are used, with functions f (objective) and g (constraint) and their partial derivatives fx', fy', gx', gy' defined; gradient vectors Vf and Vg, Lagrange multipliers l1 and l2, interactive buttons (button4, etc.), and a slider (α) are included for dynamic exploration. ④ Suitable for university-level calculus or advanced mathematics courses explaining conditional extrema, and useful for teaching mathematical modeling or engineering optimization, helping students grasp both the geometric intuition and algebraic solution of Lagrange multipliers.

GeoGebra Commands & Parameters

  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 Drawing Prompt Reference

Draw a 3D surface defined by the function f(x,y), along with a constraint surface g(x,y). First, draw contour lines of f(x,y), then draw contour lines of g(x,y). Next, find the intersection points of f(x,y) and g(x,y), mark these points, and draw gradient vectors at these points. Finally, adjust parameter α to observe the changes in the angle between the gradient vectors, understanding the application of Lagrange multipliers in conditional extremum problems.
The prompt above was compiled from the original drawing commands and is for reference only.