{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Example\n\nThe *square wave* is the $2\\pi$-periodic function $f$ with $f(x) = 1$ for $0 \u003c x \u003c \\pi$, $f(x) = -1$ for $-\\pi \u003c x \u003c 0$, and $f(0) = f(\\pi) = 0$.\nIt is odd, so its cosine coefficients vanish, and for $n \\ge 1$\n$$b_n = \\frac{2}{\\pi} \\int_0^\\pi \\sin nx \\, dx = \\frac{2 (1 - (-1)^n)}{\\pi n},$$\nwhich is $\\frac{4}{\\pi n}$ for odd $n$ and $0$ for even $n$.\nSo its Fourier series is\n$$\\frac{4}{\\pi} \\left( \\sin x + \\frac{\\sin 3x}{3} + \\frac{\\sin 5x}{5} + \\cdots \\right).$$\nThe function is of bounded variation, so by the [[Dirichlet conditions|75ZQW12WY0]] the series converges at every $x$ to $\\frac{1}{2}(f(x^+) + f(x^-))$.\nThis is $f(x)$ at every $x$, including the points of [[jump discontinuity|004FH91BN5]] $x \\in \\pi\\Z$, where both sides are $0$.\n\n## Remarks\n\nAt $x = \\pi/2$ the series gives $1 = \\frac{4}{\\pi}(1 - \\frac{1}{3} + \\frac{1}{5} - \\cdots)$, which is the Leibniz formula for $\\pi/4$.\nThe coefficients decay only like $1/n$, because of the jumps, so the series does not converge absolutely.\nThe convergence is uniform on every closed interval that avoids $\\pi\\Z$, but not on $\\R$, since the limit is discontinuous.\nNear each jump the partial sums overshoot: their maximum just to the right of $0$ tends to $\\frac{2}{\\pi} \\int_0^\\pi \\frac{\\sin t}{t} \\, dt \\approx 1.179$, the [[Gibbs phenomenon|VMF169AT67]].\n\n## Explanations\n\n### L1 human\n\nThe square wave switches between $-1$ and $1$ every half period, like an ideal on-off signal.\nIt is built from the odd harmonics only, with amplitudes $1, \\frac{1}{3}, \\frac{1}{5}, \\dots$ times $\\frac{4}{\\pi}$.\nAdding more harmonics makes the flat parts flatter and the jumps steeper, but a small spike of about $9\\%$ of the jump remains near each jump.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "illustrates": [
      "G12KXDHPPS",
      "VMF169AT67"
    ],
    "kind": "example",
    "msc": [
      "42A16",
      "42A20"
    ],
    "name": "Square wave",
    "same_as": {
      "wikidata": "Q1136640",
      "wikipedia": "Square wave (waveform)"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Square_wave_(waveform)"
      }
    ],
    "tag": "TB2TR373RC",
    "uses": [
      "75ZQW12WY0",
      "004FH91BN5"
    ]
  },
  "kind": "example",
  "link": "https://tamnd.github.io/math2/node/TB2TR373RC/",
  "links": [
    {
      "field": "illustrates",
      "target": "G12KXDHPPS"
    },
    {
      "field": "illustrates",
      "target": "VMF169AT67"
    },
    {
      "field": "uses",
      "target": "75ZQW12WY0"
    },
    {
      "field": "uses",
      "target": "004FH91BN5"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/TB2TR373RC.md",
  "msc": [
    "42A16",
    "42A20"
  ],
  "name": "Square wave",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/TB2/TB2TR373RC.md",
  "status": null,
  "tag": "TB2TR373RC",
  "uri": "m2://TB2TR373RC",
  "url": "https://tamnd.github.io/math2/wiki/square-wave/",
  "writing": {
    "tag": "TB2TR373RC",
    "kind": "example",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
