{
 "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\nwA, wB, wC = 2.0, 5.0, 12.0        # nested parts A c B c C of one opus\nlhs = (wA / wB) * (wB / wC)        # the middle weight cancels\nrhs = wA / wC\nprint(f\"(wA/wB)(wB/wC) = {lhs:.6f}   wA/wC = {rhs:.6f}   \"\n      f\"equal: {np.isclose(lhs, rhs)}  telescoped (Thm 5.4)\")\n\nfig, ax = plt.subplots(figsize=(7, 2.5))\nfor y, (val, name, col) in enumerate([(wC, 'C (opus)', 'lightsteelblue'),\n                                      (wB, 'B', NAVY),\n                                      (wA, 'A', ACCENT)]):\n    ax.barh(y, val, color=col, edgecolor='k')\n    ax.text(val + 0.15, y, f\"{name}: {val:g}\", va='center')\nax.set(yticks=[], xlabel='weight',\n       title='chains of sub-opuses multiply: the middle link cancels')\nplt.tight_layout(); plt.show()\n"
  }
 ]
}