{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $K$ be a field and let $(u_n)_{n \\ge 0}$ be a sequence in $K$ that satisfies a recurrence relation for $n \\ge 0$.\nThe *generating function method* for this recurrence consists of these steps.\n\n1. Form the [[generating function|0PHAC833JF]] $U(x) = \\sum_{n \\ge 0} u_n x^n$ in the ring $K[\\![x]\\!]$ of [[formal power series|033WGN00BF]].\n2. Multiply the recurrence for index $n$ by a suitable power $x^{n+d}$ and sum over $n \\ge 0$. This gives an equation for $U(x)$ that involves the initial values.\n3. Solve this equation for $U(x)$.\n4. Read off $u_n$ as the coefficient of $x^n$ in the solution.\n\nFor a [[linear recurrence with constant coefficients|081THG13JZ]] $u_{n+d} = c_{d-1} u_{n+d-1} + \\cdots + c_0 u_n$, step 3 gives\n$$U(x) = \\frac{P(x)}{1 - c_{d-1} x - c_{d-2} x^2 - \\cdots - c_0 x^d},$$\nwhere $P$ is a polynomial of degree less than $d$ determined by $u_0, \\dots, u_{d-1}$.\n\n## Remarks\n\nExample: the [[Fibonacci sequence|0GA9K57A39]] has $F_0 = 0$, $F_1 = 1$ and $F_{n+2} = F_{n+1} + F_n$.\nMultiplying by $x^{n+2}$ and summing gives $F(x) - x = x F(x) + x^2 F(x)$, so $F(x) = x/(1 - x - x^2)$.\nPartial fractions with the roots of $1 - x - x^2$ then give $F_n = (\\varphi^n - \\psi^n)/\\sqrt{5}$, where $\\varphi, \\psi$ are the roots of $X^2 - X - 1$.\nNon-example: for the nonlinear recurrence $u_{n+1} = u_n^2$, step 2 does not give an equation in $U$ alone.\nThe series $\\sum u_n^2 x^n$ is not a simple function of $U(x)$, so the method does not apply directly.\nThe denominator in the constant-coefficient case is $x^d \\chi(1/x)$, where $\\chi$ is the [[characteristic polynomial|0YA7X86K05]] of the recurrence.\nOther generating functions, such as exponential ones, suit other recurrences, for example those with factors $n$ in the coefficients.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "WS2E29RZD5",
    "kind": "definition",
    "msc": [
      "39A06",
      "05A15"
    ],
    "name": "Solution of recurrences by generating functions",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Generating_function"
      }
    ],
    "tag": "76NQXSGSHS",
    "uses": [
      "0PHAC833JF",
      "033WGN00BF",
      "081THG13JZ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/76NQXSGSHS/",
  "links": [
    {
      "field": "defines",
      "target": "WS2E29RZD5"
    },
    {
      "field": "uses",
      "target": "0PHAC833JF"
    },
    {
      "field": "uses",
      "target": "033WGN00BF"
    },
    {
      "field": "uses",
      "target": "081THG13JZ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/76NQXSGSHS.md",
  "msc": [
    "39A06",
    "05A15"
  ],
  "name": "Solution of recurrences by generating functions",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/76N/76NQXSGSHS.md",
  "status": null,
  "tag": "76NQXSGSHS",
  "uri": "m2://76NQXSGSHS",
  "url": "https://tamnd.github.io/math2/wiki/solution-of-recurrences-by-generating-functions-definition/",
  "writing": {
    "tag": "76NQXSGSHS",
    "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
      }
    ]
  }
}
