{
 "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\nr = np.linspace(-3, 3, 400)\nx, y = 5.0, 3.0\nlogb = lambda v: np.log(v) / np.log(b)\n\nlx, ly, lxy = logb(x), logb(y), logb(x * y)\nprint(f\"log {x:g} + log {y:g} = {lx:.6f} + {ly:.6f} = {lx+ly:.6f}\")\nprint(f\"log ({x:g}.{y:g})     = {lxy:.6f}   equal: {np.isclose(lx+ly, lxy)}  (Thm 8.8)\")\n\nfig, ax = plt.subplots(figsize=(8, 4))\nax.plot(r, b**r, color=NAVY, lw=2, label=f\"ladder {b:g}^r\")\nax.axhline(1, color='grey', lw=0.8)\nfor k in range(-3, 4):\n    ax.plot(k, b**k, 'o', color=GOLD, ms=5)\nax.plot(lx, x, 'o', color=ACCENT, ms=9)\nax.annotate(f\"x = {x:g} stands at rung {lx:.3f}\", (lx, x),\n            textcoords='offset points', xytext=(10, -14))\nax.set(xlabel='rung r', ylabel='value', title='every value stands at exactly one rung (Thm 8.7)')\nax.legend(); plt.tight_layout(); plt.show()\n"
  }
 ]
}