{
  "id": "lagrange-multiplier",
  "version": "367261e67fee",
  "status": "published",
  "name": "Lagrange Multiplier Calculator",
  "question": "What do Lagrange multipliers give?",
  "summary": "Finds where f is largest or smallest on a constraint g = c, by Lagrange multipliers.",
  "category": "math",
  "subcategory": "calculus",
  "url": "https://www.acalculator.org/math/lagrange-multiplier-calculator",
  "markdown": "https://www.acalculator.org/math/lagrange-multiplier-calculator.md",
  "kind": "function",
  "method": "Newton’s method on ∇f = λ∇g from a grid of starts; a second-order test on the constraint.",
  "assumptions": [
    "Decimals to 10 significant figures; points where ∇g = 0 are not candidates."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "f": {
        "title": "Objective f",
        "description": "The function to maximize or minimize, in 2 or 3 letters.",
        "type": "string",
        "maxLength": 200
      },
      "g": {
        "title": "Constraint",
        "description": "An equation such as x + 2y = 7.",
        "type": "string",
        "maxLength": 200
      }
    }
  },
  "outputs": {
    "extrema": {
      "label": "Extrema",
      "description": "The largest local maximum and the smallest local minimum found.",
      "format": "text"
    },
    "points": {
      "label": "All candidate points",
      "description": "Every point where ∇f = λ∇g on the constraint, with f and its type.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "f": "x^2 + 4y^2 - 2x + 8y",
      "g": "x + 2y = 7"
    },
    "outputs": {
      "extrema": "minimum 27 at (5, 1)",
      "points": "(5, 1): f = 27, local minimum"
    },
    "text": "For x^2 + 4y^2 - 2x + 8y with x + 2y = 7: minimum 27 at (5, 1)."
  },
  "examples": [
    {
      "given": {
        "f": "x^2 + 4y^2 - 2x + 8y",
        "g": "x + 2y = 7"
      },
      "expect": {
        "extrema": "minimum 27 at (5, 1)"
      },
      "source": "OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 4.8, Ex. 4.42"
    },
    {
      "given": {
        "f": "48x + 96y - x^2 - 2x y - 9y^2",
        "g": "20x + 4y = 216"
      },
      "expect": {
        "extrema": "maximum 540 at (10, 4)"
      },
      "source": "OpenStax Calculus Vol. 3, 4.8, Ex. 4.43"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 3, section 4.8 Lagrange Multipliers: https://openstax.org/books/calculus-volume-3/pages/4-8-lagrange-multipliers"
  ],
  "related": [
    "partial-derivative",
    "jacobian",
    "equation-solver"
  ],
  "changelog": []
}
