{
 "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\n\nb = 2.0                                          # try np.e: gauge snaps to 1\nfig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 3.8))\n\nns = np.logspace(0, 6, 200)\nlo = (1 + 1/ns)**ns                              # banker, increasing (Thm 9.2)\nhi = (1 + 1/ns)**(ns + 1)                        # the twin bound, decreasing\nax1.semilogx(ns, lo, color=ACCENT, label=r'$(1+1/n)^n$')\nax1.semilogx(ns, hi, color=NAVY, ls='--', label=r'$(1+1/n)^{n+1}$')\nax1.axhline(np.e, color=GOLD, lw=1.5)\nax1.text(1.2, np.e + 0.01, f\"e = {np.e:.7f}\", color=GOLD)\nax1.set(xlabel='n', title=\"the banker's tiling, compounded ever finer\")\nax1.legend()\n\nhs = np.logspace(-8, 0, 300)\nax2.semilogx(hs, (b**hs - 1)/hs, color=ACCENT, label=rf'$({b:g}^h-1)/h$')\nax2.axhline(np.log(b), color=GOLD, lw=1.5)\nax2.text(1e-7, np.log(b), rf'ln {b:g} = {np.log(b):.6f}', color=GOLD, va='bottom')\nax2.set(xlabel='h', title=r'the gauge: $\\gamma(b) = \\ln b$ (Thm 9.7)')\nax2.legend()\n\nplt.tight_layout(); plt.show()\nprint(f\"gauge check: gamma({b:g}) = {(b**1e-8 - 1)/1e-8:.6f}   ln {b:g} = {np.log(b):.6f}\")\nprint(f\"banker at n=10^6: {(1+1e-6)**1e6:.10f}   e = {np.e:.10f}\")\n"
  }
 ]
}