Lagrange Multipliers Example 5: 3D Constrained Optimization Visualization

Lagrange Multipliers Example 5: 3D Constrained Optimization Visualization
Loading the math board and drawing, please wait…
2020-07-15 19:19
① This example demonstrates the method of Lagrange multipliers for solving constrained optimization problems through a 3D visualization, showing the intersection of the objective function surface and the constraint surface, along with the optimal point. ② Core mathematical concepts include multivariable extrema, constrained optimization, gradient vectors, Lagrange multipliers, and surface-curve intersections. ③ Construction highlights: from the construction summary, Surface and CurveCartesian are used to draw 3D surfaces and curves, Point and Vector mark key points and gradient directions, Angle and Text display angles and labels, Sequence and Zip generate data series, Simplify and LeftSide simplify equations, multiple buttons (button4, button6, etc.) enable interactive control, and LaTeX text and TableText present mathematical formulas. ④ Suitable for university-level calculus or advanced mathematics courses teaching Lagrange multipliers, and also for advanced high school students to explore the geometric meaning of constrained extrema.

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]] / 2) → u_g
  8. Vector(B, B + UnitVector[Vector[B, Df]] / 2) → 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. Zip((x(a), y(a), f(a)), a, Sequence[Point[Cu_g, t / n], t, 0, n]) → lg_1
  15. Textfield(n) → InputBox5
  16. Element(l1, Indexmax1) → Amax1
  17. Element(l1, Indexmin1) → Amin1
  18. Element(l1f, Indexmax1) → Amax1_{3D}
  19. Element(l1f, Indexmin1) → Amin1_{3D}
  20. Element(l2f, Indexmin2) → Amin2_{3D}
  21. LaTeX(Amin2_{3D}, true, true) → text17
  22. Surface((-4.4 * cos(t)), sqrt(1 - cos(t)^(2)), u, t, (-π), π, u, -5, 60) → g1a
  23. Surface((-4.4 * cos(t)), (-sqrt(1 - cos(t)^(2))), u, t, (-π), π, u, -5, 60) → g2a
  24. CurveCartesian((-sqrt(t)), sqrt((1 - t^(3)) / 3), f((-sqrt(t)), sqrt((1 - t^(3)) / 3)), t, 0, 1) → q2
  25. Surface((-(1 - (3 * t^(2)))^(1 / 6)), t, u, t, -1 / sqrt(3), 1 / sqrt(3), u, -1.2, 1.2) → g2
  26. CurveCartesian((-sqrt(t)), (-sqrt((1 - t^(3)) / 3)), f((-sqrt(t)), (-sqrt((1 - t^(3)) / 3))), t, 0, 1) → q1a
  27. CurveCartesian(sqrt(t), (-sqrt((1 - t^(3)) / 3)), f(sqrt(t), (-sqrt((1 - t^(3)) / 3))), t, 0, 1) → q2a
  28. CurveCartesian((rr(t) * cos(t / 2)), (rr(t) * sin(t / 2)), f((rr(t) * cos(t / 2)), (rr(t) * sin(t / 2))), t, 0, 12) → q1
  29. Surface((rr(t) * cos(t / 2)), (rr(t) * sin(t / 2)), v, t, 0, (4 * π), v, 0, 4) → g1
  30. RotateText(text1, 90°) → text3
  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. 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
  33. Segment(B, C) → f_1
  34. Text("∇g", Point[u_g, 1]) → text25g
  35. Text("∇f", Point[u_f, 1]) → text25f
  36. Element(l2, Indexmax2) → Amax2
  37. Element(l2f, Indexmax2) → Amax2_{3D}
  38. Element(l2, Indexmin2) → Amin2
  39. Simplify(fx'(x, y) - (gx'(x, y) * fy'(x, y) / gy'(x, y))) → Cu_xf
  40. Simplify(fy'(x, y) - (gy'(x, y) * fx'(x, y) / gx'(x, y))) → Cu_yf
  41. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 2], a, l1xy'_f, c, l1]) → lvec1_f
  42. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 2], a, l1xy'_g, c, l1]) → lvec1_g
  43. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 2], a, l2xy'_f, c, l2]) → lvec2_f
  44. RemoveUndefined(Zip[Vector[c, c + UnitVector[a] / 2], a, l2xy'_g, c, l2]) → lvec2_g
  45. Textfield(txtCu01_x) → InputBox1
  46. Textfield(txtCu01_y) → InputBox2
  47. Zip(Segment[a, b], a, l1, b, l1f) → l1seg
  48. Sequence(Text[i, l1(i) - (0.3, 0.1)], i, 1, lä1) → l1txt
  49. Sequence(Text[i, l2(i) - (0.3, 0.1)], i, 1, lä2) → l2txt
  50. Zip(Segment[a, b], a, l2, b, l2f) → l2seg

AI Drawing Prompt Reference

Draw a 3D visualization of a constrained optimization problem, including the intersection of the objective function surface and the constraint surface, as well as the gradient vectors at the optimal point. Start by drawing the objective function surface, then draw the constraint surface, find their intersection and mark the optimal point. Finally, draw the gradient vectors of the objective and constraint functions at the optimal point and calculate the angle between them.
The prompt above was compiled from the original drawing commands and is for reference only.