{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $F \\colon \\R^n \\times \\R^p \\to \\R^n$ and $j \\colon \\R^n \\times \\R^p \\to \\R$ be continuously differentiable, written $F(u, \\theta)$ and $j(u, \\theta)$.\nLet $\\theta_0 \\in \\R^p$ and let $u(\\theta)$ be a continuously differentiable map defined near $\\theta_0$ with $F(u(\\theta), \\theta) = 0$.\nAssume that the [[Jacobian matrix|047NDTEPCV]] $F_u = \\partial F / \\partial u$ is invertible at $(u(\\theta), \\theta)$.\nLet $J(\\theta) = j(u(\\theta), \\theta)$ be the reduced objective.\nThe *adjoint state* at $\\theta$ is the vector $\\lambda \\in \\R^n$ that solves the *adjoint equation*\n$$F_u(u(\\theta), \\theta)^T \\lambda = \\nabla_u j(u(\\theta), \\theta).$$\nThe *adjoint state method* computes the [[gradient|0ABK9V9Y64]] of $J$ by the formula\n$$\\nabla J(\\theta) = \\nabla_\\theta j(u(\\theta), \\theta) - F_\\theta(u(\\theta), \\theta)^T \\lambda.$$\n\n## Remarks\n\nThe formula follows from the [[chain rule|0RXX2PT1MQ]].\nDifferentiating $F(u(\\theta), \\theta) = 0$ gives $F_u \\, u'(\\theta) = -F_\\theta$, so $\\nabla J^T = j_u u'(\\theta) + j_\\theta = -j_u F_u^{-1} F_\\theta + j_\\theta = -\\lambda^T F_\\theta + j_\\theta$.\nBy the [[implicit function theorem|0BXBADR94C]], invertibility of $F_u$ at a solution gives the smooth map $u(\\theta)$ locally.\nThe forward method needs $p$ linear solves with $F_u$, one for each column of $u'(\\theta)$; the adjoint method needs one solve with $F_u^T$.\nFor a time-dependent state equation the adjoint equation runs backward in time; in optimal control it is the [[costate equation|WS9MRAZMFW]].\n\nExample: $F(u, \\theta) = A u - \\theta$ with $A$ an invertible $n \\times n$ matrix and $p = n$, and $j(u, \\theta) = \\frac{1}{2} \\abs{u - d}^2$ for a fixed $d \\in \\R^n$.\nThen $F_u = A$, $F_\\theta = -I$ and $\\nabla_\\theta j = 0$, so $A^T \\lambda = u - d$ and $\\nabla J(\\theta) = \\lambda$.\nDirectly, $J(\\theta) = \\frac{1}{2} \\abs{A^{-1} \\theta - d}^2$ has gradient $A^{-T} (A^{-1} \\theta - d) = \\lambda$, as it should.\n\nNon-example: let $n = p = 1$ and $F(u, \\theta) = u^2 - \\theta$, at the point $u = \\theta = 0$, where $F_u = 0$ is singular.\nThe adjoint equation $0 \\cdot \\lambda = j_u$ need not have a solution, and the state is not a differentiable function of $\\theta$ there.\n\n## Explanations\n\n### L1 human\n\nThe gradient of an objective constrained by an equation is found from one extra linear solve with the transposed Jacobian, whatever the number of parameters.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "YD8SA6WS01",
    "kind": "definition",
    "msc": [
      "49M41",
      "65K10",
      "49K20"
    ],
    "name": "Adjoint state method",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Adjoint_state_method"
      }
    ],
    "tag": "X9F8SQFQGP",
    "uses": [
      "0ABK9V9Y64",
      "047NDTEPCV",
      "0BXBADR94C",
      "0RXX2PT1MQ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/X9F8SQFQGP/",
  "links": [
    {
      "field": "defines",
      "target": "YD8SA6WS01"
    },
    {
      "field": "uses",
      "target": "0ABK9V9Y64"
    },
    {
      "field": "uses",
      "target": "047NDTEPCV"
    },
    {
      "field": "uses",
      "target": "0BXBADR94C"
    },
    {
      "field": "uses",
      "target": "0RXX2PT1MQ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/X9F8SQFQGP.md",
  "msc": [
    "49M41",
    "65K10",
    "49K20"
  ],
  "name": "Adjoint state method",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/X9F/X9F8SQFQGP.md",
  "status": null,
  "tag": "X9F8SQFQGP",
  "uri": "m2://X9F8SQFQGP",
  "url": "https://tamnd.github.io/math2/wiki/adjoint-state-method-definition/",
  "writing": {
    "tag": "X9F8SQFQGP",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
