{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3"
  }
 },
 "cells": [
  {
   "cell_type": "code",
   "id": "cell-0",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": "# --- house style (the Press palette: accent/navy/gold/parchment) ---\nimport matplotlib as mpl\nACCENT, NAVY, GOLD, PARCH = '#7a1f1f', '#1f3a5f', '#b8860b', '#f7f2e7'\nmpl.rcParams.update({'figure.facecolor': PARCH, 'axes.facecolor': '#fffdf6',\n                     'axes.edgecolor': '#c9bfa3', 'font.family': 'serif'})\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib import animation\n\nfig, ax = plt.subplots(figsize=(9, 2.5))\ndef draw(k):\n    ax.clear()\n    x0 = 0.0\n    for i in range(k):\n        seg = 0.5**(i + 1)                      # tessera i: half of what remains\n        ax.barh(0, seg, left=x0, color=mpl.cm.viridis(i / 12), edgecolor='k', lw=0.5)\n        x0 += seg\n    ax.barh(0, 1.0, fill=False, edgecolor='k', lw=1.5)\n    S = 1 - 0.5**k\n    ax.set(xlim=(0, 1), yticks=[],\n           title=f\"k = {k}:  S_k = 1 - 2^-k = {S:.8f}   remainder 2^-k = {0.5**k:.2e}\")\n\nani = animation.FuncAnimation(fig, draw, frames=range(0, 13), interval=700)\n# Colab:  from IPython.display import HTML; HTML(ani.to_jshtml())\n# Web:    ani.save('py12_zeno.gif', writer='pillow', fps=2)\nplt.show()\n\n# The limit, paid by the Vanishing Tesseract (7.7) via Thm 8.3:\nprint(f\"1/2 + 1/4 + 1/8 + ... = {sum(0.5**k for k in range(1, 60)):.15f} -> 1  (Cor. 8.4)\")\n"
  }
 ]
}