{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nAn *affine form* is an expression\n$$\\hat x = x_0 + \\sum_{i=1}^{k} x_i \\varepsilon_i,$$\nwith real coefficients $x_0, \\ldots, x_k$ and *noise symbols* $\\varepsilon_1, \\ldots, \\varepsilon_k$.\nThe noise symbols stand for unknown reals in $[-1, 1]$, shared by all affine forms of a computation.\nIts *range* is the [[interval|0Q1D85B8G6]] $[x_0 - r, x_0 + r]$ with radius $r = \\sum_{i=1}^{k} \\abs{x_i}$.\n*Affine arithmetic* computes with affine forms by the following rules.\n\n1. Affine operations are exact: $\\hat x \\pm \\hat y = (x_0 \\pm y_0) + \\sum (x_i \\pm y_i) \\varepsilon_i$ and $c \\hat x + d = (c x_0 + d) + \\sum c x_i \\varepsilon_i$ for reals $c, d$.\n2. A nonlinear operation $g$ is replaced by an affine form $\\hat z = z_0 + \\sum z_i \\varepsilon_i + z_{k+1} \\varepsilon_{k+1}$ with a new noise symbol $\\varepsilon_{k+1}$. It is chosen so that $g(x, y, \\ldots) \\in \\hat z$ for all values of $\\varepsilon_1, \\ldots, \\varepsilon_k$ in $[-1, 1]$.\n3. For multiplication one may take $\\hat x \\hat y = x_0 y_0 + \\sum_{i=1}^{k} (x_0 y_i + y_0 x_i) \\varepsilon_i + r_x r_y \\, \\varepsilon_{k+1}$, where $r_x, r_y$ are the radii of $\\hat x, \\hat y$.\n\n## Remarks\n\nExample: $\\hat x = 2 + \\varepsilon_1$ represents $x \\in [1, 3]$, and $\\hat x - \\hat x = 0$ by rule 1, while [[interval arithmetic|QPKKTE1ZY0]] gives $[1, 3] - [1, 3] = [-2, 2]$.\nExample: $\\hat x \\cdot \\hat x = 4 + 4\\varepsilon_1 + \\varepsilon_2$ by rule 3, with range $[-1, 9]$, which contains the true range $[1, 9]$ of $x^2$.\nNon-example: replacing $x^2$ by its tangent $4 + 4\\varepsilon_1$ alone, without a new noise term, violates rule 2: at $\\varepsilon_1 = 1$ it gives $8$, but $x^2 = 9$.\nIn a computer the coefficients are rounded outward, and the rounding errors are also absorbed into a new noise term.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "YPE8E9CVXP",
    "kind": "definition",
    "msc": [
      "65G30",
      "65G40"
    ],
    "name": "Affine arithmetic",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Affine_arithmetic"
      }
    ],
    "tag": "DJXX3X6TEQ",
    "uses": [
      "QPKKTE1ZY0",
      "0Q1D85B8G6"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/DJXX3X6TEQ/",
  "links": [
    {
      "field": "defines",
      "target": "YPE8E9CVXP"
    },
    {
      "field": "uses",
      "target": "QPKKTE1ZY0"
    },
    {
      "field": "uses",
      "target": "0Q1D85B8G6"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/DJXX3X6TEQ.md",
  "msc": [
    "65G30",
    "65G40"
  ],
  "name": "Affine arithmetic",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/DJX/DJXX3X6TEQ.md",
  "status": null,
  "tag": "DJXX3X6TEQ",
  "uri": "m2://DJXX3X6TEQ",
  "url": "https://tamnd.github.io/math2/wiki/affine-arithmetic-definition/",
  "writing": {
    "tag": "DJXX3X6TEQ",
    "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
      }
    ]
  }
}
