math-skill 2.1.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.en-US.md +165 -198
  2. package/README.md +165 -198
  3. package/agents/math-critic.en.md +28 -26
  4. package/agents/math-critic.md +33 -33
  5. package/commands/ask.en.md +10 -0
  6. package/commands/ask.md +3 -10
  7. package/design-patterns/attention/equivariant-attention.en.md +72 -0
  8. package/design-patterns/attention/equivariant-attention.md +72 -0
  9. package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
  10. package/design-patterns/attention/geometry-aware-attention.md +72 -0
  11. package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
  12. package/design-patterns/attention/information-bottleneck-attention.md +72 -0
  13. package/design-patterns/attention/projection-attention.en.md +68 -0
  14. package/design-patterns/attention/projection-attention.md +68 -0
  15. package/design-patterns/attention/spectral-attention.en.md +71 -0
  16. package/design-patterns/attention/spectral-attention.md +71 -0
  17. package/design-patterns/compression/leverage-score-selection.en.md +71 -0
  18. package/design-patterns/compression/leverage-score-selection.md +71 -0
  19. package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
  20. package/design-patterns/compression/low-rank-kv-cache.md +60 -0
  21. package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
  22. package/design-patterns/compression/spectral-token-pruning.md +61 -0
  23. package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
  24. package/design-patterns/compression/topology-preserving-compression.md +64 -0
  25. package/design-patterns/loss/constraint-penalty.en.md +67 -0
  26. package/design-patterns/loss/constraint-penalty.md +78 -0
  27. package/design-patterns/loss/contrastive-loss.en.md +59 -0
  28. package/design-patterns/loss/contrastive-loss.md +68 -0
  29. package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
  30. package/design-patterns/loss/information-bottleneck-loss.md +74 -0
  31. package/design-patterns/loss/orthogonality-loss.en.md +56 -0
  32. package/design-patterns/loss/orthogonality-loss.md +60 -0
  33. package/design-patterns/loss/variational-loss.en.md +61 -0
  34. package/design-patterns/loss/variational-loss.md +71 -0
  35. package/design-patterns/representation/equivariant-split.en.md +87 -0
  36. package/design-patterns/representation/equivariant-split.md +89 -0
  37. package/design-patterns/representation/manifold-representation.en.md +85 -0
  38. package/design-patterns/representation/manifold-representation.md +87 -0
  39. package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
  40. package/design-patterns/representation/shared-private-decomposition.md +86 -0
  41. package/design-patterns/representation/subspace-alignment.en.md +90 -0
  42. package/design-patterns/representation/subspace-alignment.md +92 -0
  43. package/design-patterns/routing/graph-routing.en.md +79 -0
  44. package/design-patterns/routing/graph-routing.md +81 -0
  45. package/design-patterns/routing/moe-routing.en.md +85 -0
  46. package/design-patterns/routing/moe-routing.md +87 -0
  47. package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
  48. package/design-patterns/routing/optimal-transport-routing.md +72 -0
  49. package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
  50. package/design-patterns/routing/spectral-clustering-routing.md +90 -0
  51. package/knowledge-base/differential-geometry/connection.en.md +51 -0
  52. package/knowledge-base/differential-geometry/connection.md +51 -0
  53. package/knowledge-base/differential-geometry/curvature.en.md +49 -0
  54. package/knowledge-base/differential-geometry/curvature.md +49 -0
  55. package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
  56. package/knowledge-base/differential-geometry/geodesic.md +51 -0
  57. package/knowledge-base/differential-geometry/manifold.en.md +47 -0
  58. package/knowledge-base/differential-geometry/manifold.md +47 -0
  59. package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
  60. package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
  61. package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
  62. package/knowledge-base/differential-geometry/tangent-space.md +48 -0
  63. package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
  64. package/knowledge-base/information-geometry/fisher-metric.md +56 -0
  65. package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
  66. package/knowledge-base/information-geometry/natural-gradient.md +54 -0
  67. package/knowledge-base/lie-theory/equivariance.en.md +54 -0
  68. package/knowledge-base/lie-theory/equivariance.md +54 -0
  69. package/knowledge-base/lie-theory/group-action.en.md +51 -0
  70. package/knowledge-base/lie-theory/group-action.md +51 -0
  71. package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
  72. package/knowledge-base/lie-theory/lie-algebra.md +51 -0
  73. package/knowledge-base/lie-theory/lie-group.en.md +51 -0
  74. package/knowledge-base/lie-theory/lie-group.md +51 -0
  75. package/knowledge-base/lie-theory/representation.en.md +52 -0
  76. package/knowledge-base/lie-theory/representation.md +52 -0
  77. package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
  78. package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
  79. package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
  80. package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
  81. package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
  82. package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
  83. package/knowledge-base/matrix-analysis/projection.en.md +47 -0
  84. package/knowledge-base/matrix-analysis/projection.md +47 -0
  85. package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
  86. package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
  87. package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
  88. package/knowledge-base/optimization/constrained-optimization.md +53 -0
  89. package/knowledge-base/optimization/convex-optimization.en.md +50 -0
  90. package/knowledge-base/optimization/convex-optimization.md +50 -0
  91. package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
  92. package/knowledge-base/optimization/lagrangian-duality.md +50 -0
  93. package/knowledge-base/optimization/proximal-method.en.md +52 -0
  94. package/knowledge-base/optimization/proximal-method.md +52 -0
  95. package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
  96. package/knowledge-base/optimization/riemannian-optimization.md +51 -0
  97. package/knowledge-base/overview.en.md +29 -218
  98. package/knowledge-base/overview.md +29 -220
  99. package/knowledge-base/probability/concentration-inequality.en.md +45 -0
  100. package/knowledge-base/probability/concentration-inequality.md +45 -0
  101. package/knowledge-base/probability/entropy.en.md +47 -0
  102. package/knowledge-base/probability/entropy.md +47 -0
  103. package/knowledge-base/probability/fisher-information.en.md +48 -0
  104. package/knowledge-base/probability/fisher-information.md +48 -0
  105. package/knowledge-base/probability/information-bottleneck.en.md +49 -0
  106. package/knowledge-base/probability/information-bottleneck.md +49 -0
  107. package/knowledge-base/probability/kl-divergence.en.md +51 -0
  108. package/knowledge-base/probability/kl-divergence.md +51 -0
  109. package/knowledge-base/topology/euler-characteristic.en.md +54 -0
  110. package/knowledge-base/topology/euler-characteristic.md +54 -0
  111. package/knowledge-base/topology/fundamental-group.en.md +52 -0
  112. package/knowledge-base/topology/fundamental-group.md +52 -0
  113. package/knowledge-base/topology/persistent-homology.en.md +54 -0
  114. package/knowledge-base/topology/persistent-homology.md +54 -0
  115. package/lenses/algorithmic.en.md +49 -0
  116. package/lenses/algorithmic.md +49 -0
  117. package/lenses/axiomatization.en.md +48 -0
  118. package/lenses/axiomatization.md +48 -0
  119. package/lenses/categorical.en.md +48 -0
  120. package/lenses/categorical.md +48 -0
  121. package/lenses/causal.en.md +49 -0
  122. package/lenses/causal.md +49 -0
  123. package/lenses/duality.en.md +47 -0
  124. package/lenses/duality.md +47 -0
  125. package/lenses/game.en.md +50 -0
  126. package/lenses/game.md +50 -0
  127. package/lenses/geometric.en.md +53 -0
  128. package/lenses/geometric.md +53 -0
  129. package/lenses/local-to-global.en.md +52 -0
  130. package/lenses/local-to-global.md +52 -0
  131. package/lenses/perturbation.en.md +51 -0
  132. package/lenses/perturbation.md +51 -0
  133. package/lenses/probabilistic.en.md +48 -0
  134. package/lenses/probabilistic.md +48 -0
  135. package/lenses/projection.en.md +50 -0
  136. package/lenses/projection.md +50 -0
  137. package/lenses/spectral.en.md +52 -0
  138. package/lenses/spectral.md +52 -0
  139. package/lenses/symmetry.en.md +49 -0
  140. package/lenses/symmetry.md +49 -0
  141. package/lenses/topological.en.md +48 -0
  142. package/lenses/topological.md +48 -0
  143. package/lenses/variational.en.md +48 -0
  144. package/lenses/variational.md +48 -0
  145. package/package.json +9 -3
  146. package/references/agentic-workflow.en.md +1 -1
  147. package/references/agentic-workflow.md +1 -1
  148. package/references/books/abstract-algebra.en.md +124 -0
  149. package/references/books/abstract-algebra.md +22 -22
  150. package/references/books/algebraic-geometry-rising-sea.en.md +171 -0
  151. package/references/books/algebraic-geometry-rising-sea.md +11 -11
  152. package/references/books/differential-geometry.en.md +140 -0
  153. package/references/books/differential-geometry.md +19 -19
  154. package/references/books/matrix-analysis.en.md +146 -0
  155. package/references/books/matrix-analysis.md +10 -10
  156. package/references/books/micro-lie-theory.en.md +116 -0
  157. package/references/books/micro-lie-theory.md +17 -17
  158. package/references/books/optimization-ml.en.md +163 -0
  159. package/references/books/optimization-ml.md +7 -8
  160. package/references/books/smooth-manifolds.en.md +105 -0
  161. package/references/books/smooth-manifolds.md +14 -14
  162. package/references/gpu-friendly-math.en.md +23 -10
  163. package/references/gpu-friendly-math.md +17 -4
  164. package/references/inspiration.en.md +1 -1
  165. package/references/inspiration.md +2 -2
  166. package/skills/math-research-activator/SKILL.en.md +195 -114
  167. package/skills/math-research-activator/SKILL.md +194 -119
  168. package/skills/math-research-activator/original-texts.en.md +9 -9
  169. package/skills/math-research-activator/original-texts.md +11 -11
  170. package/commands/abstraction.md +0 -11
  171. package/commands/algorithmic-thinking.md +0 -11
  172. package/commands/axiomatization.md +0 -11
  173. package/commands/causal-inference.md +0 -11
  174. package/commands/discrete-combinatorial.md +0 -11
  175. package/commands/game-theory.md +0 -11
  176. package/commands/induction-analogy.md +0 -11
  177. package/commands/information-theory.md +0 -11
  178. package/commands/logic-deduction.md +0 -11
  179. package/commands/modeling.md +0 -11
  180. package/commands/optimization.md +0 -11
  181. package/commands/probability-statistics.md +0 -11
  182. package/commands/symmetry-invariance.md +0 -11
  183. package/commands/topological-thinking.md +0 -11
  184. package/commands/transformation.md +0 -11
  185. package/skills/abstraction/SKILL.en.md +0 -117
  186. package/skills/abstraction/SKILL.md +0 -121
  187. package/skills/abstraction/original-texts.en.md +0 -163
  188. package/skills/abstraction/original-texts.md +0 -175
  189. package/skills/algorithmic-thinking/SKILL.en.md +0 -132
  190. package/skills/algorithmic-thinking/SKILL.md +0 -138
  191. package/skills/algorithmic-thinking/original-texts.en.md +0 -253
  192. package/skills/algorithmic-thinking/original-texts.md +0 -256
  193. package/skills/axiomatization/SKILL.en.md +0 -144
  194. package/skills/axiomatization/SKILL.md +0 -151
  195. package/skills/axiomatization/original-texts.en.md +0 -154
  196. package/skills/axiomatization/original-texts.md +0 -160
  197. package/skills/causal-inference/SKILL.en.md +0 -147
  198. package/skills/causal-inference/SKILL.md +0 -151
  199. package/skills/causal-inference/original-texts.en.md +0 -136
  200. package/skills/causal-inference/original-texts.md +0 -167
  201. package/skills/discrete-combinatorial/SKILL.en.md +0 -124
  202. package/skills/discrete-combinatorial/SKILL.md +0 -131
  203. package/skills/discrete-combinatorial/original-texts.en.md +0 -184
  204. package/skills/discrete-combinatorial/original-texts.md +0 -185
  205. package/skills/game-theory/SKILL.en.md +0 -117
  206. package/skills/game-theory/SKILL.md +0 -123
  207. package/skills/game-theory/original-texts.en.md +0 -131
  208. package/skills/game-theory/original-texts.md +0 -131
  209. package/skills/induction-analogy/SKILL.en.md +0 -145
  210. package/skills/induction-analogy/SKILL.md +0 -152
  211. package/skills/induction-analogy/original-texts.en.md +0 -140
  212. package/skills/induction-analogy/original-texts.md +0 -154
  213. package/skills/information-theory/SKILL.en.md +0 -134
  214. package/skills/information-theory/SKILL.md +0 -140
  215. package/skills/information-theory/original-texts.en.md +0 -127
  216. package/skills/information-theory/original-texts.md +0 -127
  217. package/skills/logic-deduction/SKILL.en.md +0 -130
  218. package/skills/logic-deduction/SKILL.md +0 -135
  219. package/skills/logic-deduction/original-texts.en.md +0 -160
  220. package/skills/logic-deduction/original-texts.md +0 -173
  221. package/skills/modeling/SKILL.en.md +0 -135
  222. package/skills/modeling/SKILL.md +0 -139
  223. package/skills/modeling/original-texts.en.md +0 -162
  224. package/skills/modeling/original-texts.md +0 -165
  225. package/skills/optimization/SKILL.en.md +0 -129
  226. package/skills/optimization/SKILL.md +0 -135
  227. package/skills/optimization/original-texts.en.md +0 -167
  228. package/skills/optimization/original-texts.md +0 -168
  229. package/skills/probability-statistics/SKILL.en.md +0 -146
  230. package/skills/probability-statistics/SKILL.md +0 -151
  231. package/skills/probability-statistics/original-texts.en.md +0 -191
  232. package/skills/probability-statistics/original-texts.md +0 -193
  233. package/skills/symmetry-invariance/SKILL.en.md +0 -135
  234. package/skills/symmetry-invariance/SKILL.md +0 -139
  235. package/skills/symmetry-invariance/original-texts.en.md +0 -206
  236. package/skills/symmetry-invariance/original-texts.md +0 -221
  237. package/skills/topological-thinking/SKILL.en.md +0 -124
  238. package/skills/topological-thinking/SKILL.md +0 -128
  239. package/skills/topological-thinking/original-texts.en.md +0 -134
  240. package/skills/topological-thinking/original-texts.md +0 -164
  241. package/skills/transformation/SKILL.en.md +0 -120
  242. package/skills/transformation/SKILL.md +0 -124
  243. package/skills/transformation/original-texts.en.md +0 -204
  244. package/skills/transformation/original-texts.md +0 -216
@@ -0,0 +1,146 @@
1
+ # Matrix Analysis
2
+
3
+ > Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013 (ISBN 978-0-521-83940-2). A graduate-level classic of matrix theory unified by the theme of **canonical forms**.
4
+
5
+ ## Overview
6
+
7
+ This is the authoritative reference for upgrading "linear algebra" to "matrix analysis": not just computing with matrices, but studying invariants under **similarity / unitary equivalence / congruence** transformations, canonical forms, eigenvalue location and perturbation, norm geometry, and positive-definite/nonnegative structures. For AI/ML/GPU, it is the **backbone closest to the hardware-level operators** in the v2 reading list -- GEMM, numerical stability, low-rank compression, and second-order optimization all trace their roots here.
8
+
9
+ Actual chapter map (from the table of contents):
10
+
11
+ - **Ch 0 Review and Miscellanea**: rank, nonsingularity, inner products, block matrices -- quick-reference foundation.
12
+ - **Ch 1 Eigenvalues, Eigenvectors, and Similarity**: characteristic equations, characteristic polynomials, algebraic/geometric multiplicity, similarity (Sec. 1.1-1.4).
13
+ - **Ch 2 Unitary Similarity and Unitary Equivalence**: QR decomposition (Sec. 2.1), Schur triangularization (Sec. 2.4), normal matrices (Sec. 2.5), **SVD (Sec. 2.6)**, CS decomposition (Sec. 2.7).
14
+ - **Ch 3 Canonical Forms for Similarity and Triangular Factorizations**: Jordan canonical form (Sec. 3.1), minimal polynomials and companion matrices (Sec. 3.3), real Jordan and Weyr forms (Sec. 3.4), triangular factorization LU (Sec. 3.5).
15
+ - **Ch 4 Hermitian, Symmetric Matrices, and Congruences**: variational characterization Courant-Fischer (Sec. 4.2), eigenvalue inequalities Weyl/interlacing (Sec. 4.3), congruences and Sylvester's law of inertia (Sec. 4.5).
16
+ - **Ch 5 Norms for Vectors and Matrices**: norms and inner products, dual norms (Sec. 5.5), **matrix norms (Sec. 5.6-5.7)**, **condition numbers (Sec. 5.8)**.
17
+ - **Ch 6 Location and Perturbation of Eigenvalues**: Gershgorin discs (Sec. 6.1-6.2), eigenvalue perturbation theorems (Sec. 6.3).
18
+ - **Ch 7 Positive Definite and Semidefinite Matrices**: polar decomposition and SVD (Sec. 7.3-7.4), **Schur product theorem (Sec. 7.5)**, simultaneous diagonalization (Sec. 7.6), Loewner partial order and block matrices (Sec. 7.7), positive-definite inequalities (Sec. 7.8).
19
+ - **Ch 8 Positive and Nonnegative Matrices**: Perron-Frobenius (Sec. 8.2-8.5), stochastic and doubly stochastic matrices (Sec. 8.7).
20
+ - Appendices A-F: complex numbers, **convex sets and functions (B)**, fundamental theorem of algebra, eigenvalue continuity, compactness, canonical pairs (F).
21
+
22
+ **Boundary reminder for activation**: this book is **theory-first** -- addressing existence, characterizations, inequalities, and canonical forms, **not numerical algorithm recipes**. Specific algorithm implementations, convergence constants, and stability details (e.g., communication lower bounds for blocked QR, actual complexity coefficients for SVD) require a companion numerical linear algebra textbook (Golub-Van Loan / Trefethen-Bau). What is provided here is an **activation index** for "which structure to use + why + can the GPU compute it"; for implementation details, consult those books.
23
+
24
+ ## Core Structures Transferable to AI/Infra
25
+
26
+ | Mathematical structure (chapter) | Transfer to ML / algorithms / Infra |
27
+ |---|---|
28
+ | **SVD / low-rank (Sec. 2.6, 7.4)** | The foundation of all low-rank compression: LoRA, PCA/whitening, Eckart-Young optimal low-rank approximation, KV-Cache low-rank reduction, weight compression |
29
+ | **Spectrum and similarity invariants (Ch 1)** | Hessian/gradient covariance spectra, spectral radius determines stability of linear attention / SSM / RNN, trace = parameter counting / regularization |
30
+ | **Schur triangularization + normal matrices (Sec. 2.4-2.5)** | Foundation for numerical EVD algorithms (QR algorithm); normal <=> unitarily diagonalizable, the criterion for "well-behaved spectra" |
31
+ | **Variational characterization Courant-Fischer (Sec. 4.2)** | Rayleigh quotients, spectral normalization, spectral clustering, PCA as min-max; largest singular value = operator norm |
32
+ | **Eigenvalue perturbation Weyl/Bauer-Fike (Sec. 4.3, 6.3)** | Spectral shift bounds under quantization/low-precision/pruning, training perturbation robustness, stability certificates |
33
+ | **Matrix norms + duality (Sec. 5.5-5.7)** | Spectral norm (gradient clipping / Lipschitz), Frobenius (weight decay), **nuclear norm = dual of spectral norm** (low-rank regularization) |
34
+ | **Condition numbers (Sec. 5.8)** | Numerical stability diagnostics, preconditioning, why bf16 training diverges |
35
+ | **Polar decomposition + Newton-Schulz (Sec. 7.3)** | Orthogonalizing gradients/weights (Muon optimizer, orthogonal initialization), computable with pure GEMM |
36
+ | **Positive definiteness / PSD (Ch 7)** | Kernel methods, covariances, attention Gram matrices, second-order method preconditioners, Loewner partial order for matrix inequalities |
37
+ | **Schur product theorem (Sec. 7.5)** | Hadamard products preserve PSD -- learnable kernel engineering, gating that does not destroy positive-definite structure |
38
+ | **Perron-Frobenius / stochastic matrices (Ch 8)** | Row-stochastic attention mixing and collapse (over-smoothing), PageRank, graph propagation, spectral gap = expressivity |
39
+
40
+ The table above is organized into four **activation families** for convenient retrieval:
41
+
42
+ - **Spectral family (Ch 1-3)**: eigenvalues / similarity / canonical forms -- answering "is the dynamics stable, what does the spectrum look like." Note that Jordan/Weyr forms are theoretical tools; numerically one turns to Schur/SVD.
43
+ - **Norm family (Ch 5-6)**: norms / duality / condition numbers / perturbation -- answering "how do errors propagate, is low precision stable, should we precondition."
44
+ - **Positive-definite family (Ch 4, 7)**: Hermitian / PSD / polar decomposition / Loewner -- answering "second-order structure, kernels, covariances, nearest orthogonal matrix."
45
+ - **Nonnegative family (Ch 8)**: Perron-Frobenius / stochastic matrices -- answering "propagation, mixing, collapse, stationary distributions."
46
+
47
+ ## Key Bridging Facts (Activation Shorthand)
48
+
49
+ When "activating" this book into algorithms, these are the most frequently used connecting facts -- memorizing them enables rapid navigation between structures:
50
+
51
+ - **Condition number kappa_2(A) = sigma_max / sigma_min (Sec. 5.8)**: directly predicts how many orders of magnitude errors are amplified under bf16/fp8.
52
+ - **SVD <=> eigendecomposition of A^H A and A A^H, sigma = sqrt(lambda) (Sec. 2.6, 7.4)**: singular values are the square roots of the Gram matrix eigenvalues.
53
+ - **Spectral norm = sigma_max, Frobenius = sqrt(Sum sigma^2), nuclear norm = Sum sigma (Sec. 5.6)**: all three major matrix norms are determined entirely by singular values; spectral norm and nuclear norm are dual to each other.
54
+ - **Normal matrices <=> unitarily diagonalizable (Sec. 2.5)**: the only class where "eigenvalue = singular value structure is well-conditioned"; for non-normal matrices one must look at pseudospectra.
55
+ - **Positive definite <=> all eigenvalues > 0 <=> all leading principal minors > 0 (Sec. 7.1)**: the latter is a computable positive-definiteness test (Sylvester's criterion).
56
+ - **Polar decomposition A = UP, P = (A^H A)^{1/2} (Sec. 7.3)**: Newton-Schulz iteration converges to the orthogonal factor U.
57
+ - **Weyl perturbation bound |lambda_i(A+E) - lambda_i(A)| <= ||E||_2 (Sec. 4.3)**: one line gives the spectral shift upper bound for quantization/pruning.
58
+ - **Row-stochastic matrix spectral radius = 1 (Sec. 8.7)**: the Perron root of attention is always 1; the spectral gap determines the collapse rate.
59
+
60
+ ## Problem Types Suited for Activation
61
+
62
+ - **Low-rank / compression**: where is the redundancy in attention, KV-Cache, weights, gradients? How low can the rank go? How to estimate the optimal approximation error from truncation (Eckart-Young)? Should low-rank regularization use the nuclear norm or explicit parameterization?
63
+ - **Numerical stability**: why does low-precision (bf16/fp8) training diverge? How to monitor condition numbers and spectral radii online during training? Are there bounds on spectral shifts from quantization/pruning (Weyl, Bauer-Fike)? Which operators need reparameterization for stability?
64
+ - **Spectral design**: the operator norms behind normalization (spectral normalization / BatchNorm); spectral radius constraints for recurrent / state-space models (SSM); spectral gap determines expressivity and separability.
65
+ - **Second-order optimization**: PSD structure and negative curvature of Hessian / Fisher (inertia law for detecting saddle points); condition number improvement via preconditioners; Kronecker-factor approximations (K-FAC / Shampoo).
66
+ - **Graphs / propagation**: stability and over-smoothing of message passing; mixing time of row-stochastic operators; Markov chain stationary distributions and spectral gaps.
67
+
68
+ ## Possible Algorithmic Inspirations
69
+
70
+ > Each item is tagged with the **eight-dimension touchpoint** (corresponding to the dimension numbers in `../gpu-friendly-math.md`) for direct entry into the GPU acceptance gate.
71
+
72
+ 1. **Randomized numerical linear algebra (randomized NLA)**: using random projections + QR (Sec. 2.1) for randomized SVD, reducing the O(n^3) full decomposition to sub-quadratic, producing low-rank sketches of very large weights/activations. *Touchpoint: D2/D3 -- all GEMM, manageable complexity.*
73
+ 2. **Low-rank attention / KV compression**: using Eckart-Young (Sec. 7.4) to guarantee truncated SVD is the optimal low-rank approximation; using the **nuclear norm (dual of spectral norm, Sec. 5.5)** as low-rank regularization, projecting the KV-Cache into a low-dimensional subspace. *Touchpoint: D2/D4 -- GEMM chains + memory compression.*
74
+ 3. **Spectral normalization**: power iteration to estimate the largest singular value (operator norm, Sec. 5.6), constraining per-layer Lipschitz constants -- GANs/diffusion/stable training. *Touchpoint: D1/D6 -- matvec, but serial iteration requires blocking.*
75
+ 4. **Newton-Schulz orthogonalization (Muon-style)**: polar decomposition (Sec. 7.3) projects gradient matrices onto the nearest orthogonal matrix, with iterations involving only matrix multiplications -- currently the most GPU-friendly "second-order-flavored" update. *Touchpoint: D2/D6/D8 -- pure GEMM, fusible, bf16-stable.*
76
+ 5. **Preconditioning / Shampoo / K-FAC**: condition numbers (Sec. 5.8) diagnose ill-conditioning, using PSD Kronecker factors (Ch 7) to approximate the Hessian for preconditioning, rounding out ill-conditioned loss landscapes. *Touchpoint: D2/D5 -- small-matrix GEMM, watch precision for inverse operations.*
77
+ 6. **Gershgorin cheap spectral radius gate (Sec. 6.1)**: using the disc bound O(n^2) in the training loop to quickly estimate the spectral radius as a low-cost stability gate, without running a full EVD. *Touchpoint: D1/D3 -- per-row summation, extremely cheap.*
78
+ 7. **PSD kernel engineering (Schur product theorem, Sec. 7.5)**: composing multiple PSD kernels via Hadamard products, guaranteeing that learnable similarity matrices remain positive semidefinite. *Touchpoint: D1 -- element-wise tensor products, naturally friendly.*
79
+ 8. **Perron-Frobenius diagnostics (Sec. 8.2-8.5)**: treating row-stochastic attention as a Markov operator, using the spectral gap to quantify over-smoothing / rank collapse, guiding residual and temperature design. *Touchpoint: D1/D3 -- cheap spectral estimation, avoids deep-layer collapse.*
80
+ 9. **Blocked / communication-avoiding decompositions**: writing QR, Cholesky (Sec. 3.5) in blocked versions, replacing column-by-column elimination with GEMM, reducing communication rounds across devices. *Touchpoint: D2/D6 -- reforming serial recurrences into parallelism + overlap.*
81
+
82
+ ## GPU Friendliness Warning
83
+
84
+ > The scoring dimensions reference the **eight-dimension checklist** in `../gpu-friendly-math.md` (Tensorization / GEMM-mappability / Complexity / Memory / Low-precision / Parallelism / Sparsity / Operator fusion); definitions are not repeated here.
85
+
86
+ **Natively friendly (math beautiful x GPU friendly):**
87
+ - **Truncated SVD / low-rank**: expressed as GEMM chains (D2), compressing KV-Cache/weights (D4).
88
+ - **Frobenius / spectral norms, Gram matrices, Hadamard products**: batched tensor algebra (D1, D2).
89
+ - **Polar decomposition Newton-Schulz**: pure matrix-multiplication iteration (D2, D6, D8 fusible), robust under bf16.
90
+ - **Gershgorin discs**: O(n^2) per-row summation (D1), cheap stability estimation.
91
+ - **Well-conditioned PSD blocked Cholesky / Gram construction**: blocked form yields GEMM chains (D2), commonly used in kernel methods and covariance preconditioning.
92
+
93
+ **Beautiful but not computable:**
94
+ - **Jordan canonical form (Sec. 3.1)** -- the classic counter-example: eigenvalue multiplicities are extremely sensitive to perturbation, fundamentally unreliable under floating-point, **never use as a numerical tool** (violates D5 low-precision stability). Weyr form has the same issue.
95
+ - **Full EVD / SVD at O(n^3)** -- blows up for large matrices (violates D3), must switch to randomized/iterative methods.
96
+ - **Non-normal matrices (Sec. 2.5 and beyond)** -- eigenvalues do not reflect true behavior, pseudospectra are needed; spectral distortion under low precision (D5).
97
+ - **Ill-conditioned / high condition number (Sec. 5.8)** -- catastrophic cancellation occurs, requiring fp64 for correctness, conflicting with bf16/fp8 training (D5).
98
+ - **Serial dependencies in QR / Cholesky (Sec. 2.1, 3.5)** -- naive implementations are long serial recurrences (violates D6), requiring blocked / communication-avoiding variants.
99
+ - **Serial iteration in power iteration** -- single-vector iteration has low parallelism; must be blocked (block / subspace iteration) to saturate SMs (D6).
100
+
101
+ **Reform strategies (echoing the Make-It-Computable Toolkit in `../gpu-friendly-math.md`):**
102
+ - Full EVD/SVD -> **randomized + truncated** to reduce complexity (D3);
103
+ - Exact decompositions -> **blocked / GEMM-ified** to eliminate serial dependencies (D2/D6);
104
+ - Ill-conditioned/non-normal -> **reparameterization + spectral normalization** to stabilize low precision (D5);
105
+ - Non-computable canonical forms like Jordan -> retain only for **theoretical proofs**, numerically switch to Schur/SVD.
106
+
107
+ ## Which Design Lens to Invoke
108
+
109
+ Used in conjunction with the design lenses in `../../lenses/`:
110
+
111
+ - **`duality`**: similarity / unitary equivalence / congruence, SVD, diagonalization -- the soul of this book is "change coordinates to reveal structure."
112
+ - **`algorithmic`**: power iteration, Newton-Schulz, QR algorithm, randomized NLA -- turning theorems into runnable kernels.
113
+ - **`variational`**: variational characterizations (Sec. 4.2), condition numbers and preconditioning, second-order methods, matrix inequalities under the Loewner partial order.
114
+ - **`symmetry`**: unitary invariance, similarity invariants (eigenvalues/trace/determinant), well-conditioned spectra of normal matrices.
115
+ - **`categorical`**: canonical forms as "representatives of equivalence classes" -- capturing essence through the simplest morphology, ignoring coordinate details.
116
+ - **`probabilistic`**: randomized NLA, random matrix spectra, Perron-Frobenius / Markov chain stationary distributions.
117
+
118
+ ## Anti-patterns
119
+
120
+ - **Using Jordan form as a numerical algorithm**: it is not computable under floating-point, only useful for theoretical analysis; do not put it into a kernel.
121
+ - **Defaulting to full SVD/EVD**: in large-scale settings one should use randomized/truncated/iterative methods, otherwise O(n^3) will bog everything down.
122
+ - **Looking only at eigenvalues while ignoring non-normality**: eigenvalues of non-normal matrices do not predict transient behavior; look at singular values / pseudospectra instead.
123
+ - **Assuming all matrices are well-conditioned**: deploying bf16/fp8 without monitoring condition numbers, then debugging after divergence.
124
+ - **Using the nuclear norm while forgetting it requires SVD**: the nuclear norm is an elegant low-rank regularizer, but its computation depends on SVD, requiring proximal/randomized techniques.
125
+ - **Assuming exact positive definiteness numerically**: under floating-point, Gram/covariance matrices can lose positive definiteness; add jitter (diagonal perturbation) or use pivoted Cholesky.
126
+ - **Using Frobenius norm as a low-rank regularizer**: Frobenius / weight decay suppresses "energy" not "rank"; for low rank, use the nuclear norm or explicit low-rank parameterization (e.g., LoRA).
127
+ - **Discussing "eigenvalue magnitudes" for non-symmetric matrices**: when measuring energy/norm/stability margins, look at **singular values**; the modulus of eigenvalues of non-normal matrices is seriously misleading (transient growth far exceeds what the spectral radius predicts).
128
+ - **Materializing the full O(n^2) Gram matrix**: attention/kernel matrices without blocking will blow up memory; use FlashAttention-style fusion + blocking (echoing GPU dimensions D4/D8).
129
+ - **Stacking theorems without diagnosing the bottleneck**: first ask "is the algorithmic bottleneck spectral, low-rank, or stability," then select the structure; do not dump matrix theory upfront.
130
+
131
+ ## Deep Dive Entry
132
+
133
+ > **Bibliographic info**: Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
134
+ >
135
+ > **Activation method**: Place `Matrix Analysis.pdf` in the `math_book/` folder at the project root; the Agent can then automatically search the original text. The PDF is not distributed via npm/git (copyright reasons); obtain it independently.
136
+
137
+ **Full-fidelity lookup = have the Agent automatically search the local PDF `math_book/Matrix Analysis.pdf`**: extract with `pdftotext` -> `grep` to locate keywords/theorem names -> `Read` the relevant pages for close study. This file is an "activation index," not a substitute; when precise statements, proofs, or constants are needed, go back to the original book.
138
+
139
+ Actual chapters worth deep reading:
140
+
141
+ - **Sec. 2.6 The singular value decomposition** -- the origin of all low-rank compression / LoRA / PCA.
142
+ - **Sec. 4.2-4.3 Variational characterizations & eigenvalue inequalities** -- Courant-Fischer min-max and Weyl inequalities, the theoretical roots of spectral normalization and perturbation bounds.
143
+ - **Sec. 5.6-5.8 Matrix norms & condition numbers** -- all the criteria for numerical stability, gradient clipping, and preconditioning are here.
144
+ - **Sec. 7.3-7.5 Polar/SVD & the Schur product theorem** -- the direct source for Muon orthogonalization and PSD kernel engineering.
145
+ - **Sec. 6.1-6.3 Gershgorin discs & perturbation theorems** -- cheap spectral localization and perturbation robustness.
146
+ - **Sec. 8.2-8.5 Perron-Frobenius theory** -- row-stochastic attention, graph propagation, over-smoothing analysis.
@@ -1,4 +1,4 @@
1
- # 🧮 矩阵分析 / Matrix Analysis
1
+ # 矩阵分析 / Matrix Analysis
2
2
 
3
3
  > Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013(ISBN 978-0-521-83940-2)。以**标准型(canonical forms)作为统一主题**的研究生级矩阵理论经典。
4
4
 
@@ -104,16 +104,16 @@
104
104
  - 病态/非正规 → **重参数化 + 谱归一化**稳低精度(维度 5);
105
105
  - Jordan 等不可算标准型 → 只留作**理论证明**,数值上换 Schur/SVD。
106
106
 
107
- ## 该调用哪个思想武器
107
+ ## 该调用哪个思想透镜
108
108
 
109
- 配合 `skills/` 下的现有武器使用:
109
+ 配合 `../../lenses/` 下的思想透镜使用:
110
110
 
111
- - **`transformation`(变换)**:相似 / 酉等价 / 合同、SVD、对角化——本书的灵魂就是"换坐标让结构显形"。
112
- - **`algorithmic-thinking`(算法与计算)**:power iteration、Newton–Schulz、QR algorithm、随机化 NLA——把定理变成可跑的 kernel。
113
- - **`optimization`(优化)**:变分刻画(§4.2)、条件数与预条件、二阶法、Loewner 偏序下的矩阵不等式。
114
- - **`symmetry-invariance`(对称与不变性)**:酉不变性、相似不变量(特征值/迹/行列式)、正规矩阵的良态谱。
115
- - **`abstraction`(抽象化)**:标准型即"等价类的代表元"——用最简形态抓住本质、忽略坐标细节。
116
- - **`probability-statistics`(概率与统计)**:随机化 NLA、随机矩阵谱、Perron–Frobenius/Markov 链平稳分布。
111
+ - **`duality`(对偶)**:相似 / 酉等价 / 合同、SVD、对角化——本书的灵魂就是"换坐标让结构显形"。
112
+ - **`algorithmic`(算法)**:power iteration、Newton–Schulz、QR algorithm、随机化 NLA——把定理变成可跑的 kernel。
113
+ - **`variational`(变分)**:变分刻画(§4.2)、条件数与预条件、二阶法、Loewner 偏序下的矩阵不等式。
114
+ - **`symmetry`(对称与不变性)**:酉不变性、相似不变量(特征值/迹/行列式)、正规矩阵的良态谱。
115
+ - **`categorical`(范畴化)**:标准型即"等价类的代表元"——用最简形态抓住本质、忽略坐标细节。
116
+ - **`probabilistic`(概率统计)**:随机化 NLA、随机矩阵谱、Perron–Frobenius/Markov 链平稳分布。
117
117
 
118
118
  ## 反模式
119
119
 
@@ -130,7 +130,7 @@
130
130
 
131
131
  ## 深挖入口
132
132
 
133
- > **📖 书目信息**:Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
133
+ > **书目信息**:Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
134
134
  >
135
135
  > **启用方式**:将 `Matrix Analysis.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
136
136
 
@@ -0,0 +1,116 @@
1
+ # A Micro Lie Theory
2
+
3
+ > **A micro Lie theory for state estimation in robotics** -- Joan Solà, Jeremie Deray, Dinesh Atchuthan.
4
+ > arXiv:1812.01537v9 [cs.RO], 2021-12-08, main text approx. 17 pages + appendix formula handbook. Companion open-source C++ header library **manif** (<https://github.com/artivis/manif>, implementing SO(2)/SO(3)/SE(2)/SE(3) with analytic Jacobians).
5
+ > This file is an "activation" distillation, **not a restatement of the original**; for full fidelity, consult the local PDF (see (Deep Dive Entry)).
6
+
7
+ ## Overview
8
+
9
+ This paper **deliberately "amputates"** the vast edifice of Lie theory down to the minimal subset needed for robotic state estimation: it does not even introduce the Lie bracket, instead reducing the Lie algebra directly to the isomorphic vector space R^n, so that the "curved, nonlinear" Lie group becomes "flat, linear" vector algebra in the tangent space. The one-sentence thesis: **virtually every operation on the group (curved) has an exact counterpart in the Lie algebra (flat)** (Fig. 1) -- this is the modern use of Sophus Lie's "dragon-slaying sword" from inspiration.md: the dragon (solving differential equations) was never slain, yet the sword became a supreme tool for chopping vegetables (linearizing nonlinearities), carving (describing symmetries), and building houses (robotic state estimation).
10
+
11
+ Actual structure map:
12
+ - **II. A micro Lie theory (core)**: A Lie groups (group axioms + manifold) -> B group actions -> C tangent space and Lie algebra (hat `^wedge` / vee `^vee` operators) -> D **exponential map** exp/log and capital Exp/Log (Eq. 23-24) -> E **addition/subtraction operators** oplus/ominus (Eq. 25-28, left and right versions) -> F **adjoint** Ad_X and adjoint matrix (Eq. 30-35) -> G **derivatives on Lie groups**: right Jacobian (Eq. 41a-c) / left Jacobian (Eq. 44) -> H **uncertainty on manifolds and covariance propagation** (Eq. 52) -> I discrete integration on manifolds.
13
+ - **III. Manifold differentiation rules**: A chain rule, B elementary Jacobian blocks, C derived Jacobian blocks.
14
+ - **IV. Composite manifolds / bundles**: assembling heterogeneous large states into non-interacting manifold blocks, differentiating block by block (Eq. 84-90, Ex. 7 comparing SE(n) vs T(n)xSO(n) vs (R^n, SO(n))).
15
+ - **V. Applications**: landmark-based localization and mapping -- error-state Kalman filter on manifolds (Eq. 92-96), graph-optimization SLAM, sensor self-calibration.
16
+ - **VI. Conclusion + Appendix**: complete closed-form formulas for S^1/SO(2)/SE(2), S^3/SO(3), SE(3) (including right/left Jacobians, e.g. SO(3) Eq. 143-145).
17
+
18
+ ## Core Structures Transferable to AI/Infra
19
+
20
+ The paper welds together the "curved nonlinear group" and the "flat linear vector space" using five tools, each of which can be directly ported into differentiable algorithms.
21
+
22
+ ### 1. exp/log Maps -> Manifold Parameterization (Eq. 23-24, Fig. 1)
23
+
24
+ `Exp: R^n -> M`, `Log: M -> R^n` are the bijective bridges between the manifold and its tangent space (isomorphic to linear R^n). Transfer usage: **let the network freely predict in the unconstrained tangent space R^n, then map back to the valid manifold via Exp**. Rotations, poses, and unit quaternions thus naturally satisfy constraints (orthogonality, unit norm), eliminating the need for various ad-hoc post-hoc orthogonalization or normalization fixes on regressed matrices/quaternions.
25
+
26
+ ### 2. oplus/ominus Addition/Subtraction Operators -> "Vector Algebra" on Manifolds (Eq. 25-28)
27
+
28
+ `oplus` (one Exp + one group composition) makes "adding an increment to a manifold state" look like ordinary vector addition; `ominus` computes the difference between two elements (geodesic residual). **Key pitfall**: because group composition is non-commutative, oplus/ominus come in **right versions** (increment in local frame / tangent at X) and **left versions** (increment in global frame / tangent at identity E); the paper defaults to the right version -- in engineering, one must stay consistent throughout; mixing conventions leads to errors.
29
+
30
+ ### 3. Right/Left Jacobians -> Geometrically Correct Backpropagation (Eq. 41a-c, 44)
31
+
32
+ The linearization of a manifold function with respect to tangent-space perturbations is the Jacobian; the chain rule on manifolds takes the form `D(g o f)/DX = J_g . J_f` (Sec. III-A), isomorphic to the Euclidean chain rule, so it plugs directly into automatic differentiation. The **right Jacobian** (Eq. 41) and **left Jacobian** (Eq. 44) describe the same derivative in local vs. global tangent spaces, related to each other through the adjoint Ad.
33
+
34
+ ### 4. Adjoint Matrix Ad_X -> Transporting Tangent Vectors Across Frames (Eq. 30-35)
35
+
36
+ `Ad_X` transports the same tangent vector between different points and left/right frames (Eq. 32: `X oplus tau = (Ad_X tau) oplus X`). It is the **algebraic realization of equivariance**, and also the transformation matrix for propagating perturbations/covariances across frames; Ex. 6 gives the closed-form adjoint matrix for SE(3).
37
+
38
+ ### 5. Covariance Propagation -> Uncertainty on Manifolds (Eq. 52)
39
+
40
+ `Sigma = E[(X om Xbar)(X om Xbar)^T] in R^{m x m}` -- **the covariance lives in the tangent space R^n, not on the group**. Defining variance directly on the group is ill-posed; the tangent-space representation brings the uncertainty computations of Kalman filters / factor graphs back to familiar linear algebra.
41
+
42
+ Two additional directly usable "components":
43
+ - **SE(3) / SO(3)**: rigid body motion group / rotation group -- the unified differentiable representation of pose = rotation + translation, the standard language for cameras, point clouds, and robotic arm joints.
44
+ - **Composite manifolds (bundles, Eq. 84-90)**: assembling multi-pose + feature + calibration heterogeneous large states into non-interacting manifold blocks, with Jacobians **assembled block by block** (Eq. 89 is block-structured sparse), i.e., "assemble the Jacobian matrix block by block" in engineering practice.
45
+
46
+ ## Problem Types Suited for Activation
47
+
48
+ - Prediction/regression targets carry **geometric constraints**: rotations, poses, unit vectors, SPD matrices -- forcing them into Euclidean MLPs breaks the constraints.
49
+ - Need **equivariance / invariance**: when the input undergoes rigid body transformations, the output should covary or remain invariant (point clouds, molecules, multi-view geometry).
50
+ - Need **explicit uncertainty**: pose estimation, sensor fusion, SLAM, visual odometry covariance propagation.
51
+ - **Iterative geometric optimization**: camera/point cloud registration, bundle adjustment, inverse kinematics, requiring gradient/Gauss-Newton on manifolds rather than in Euclidean space.
52
+ - States **evolve on Lie groups**: inertial pre-integration, motion models, differentiable physics/control.
53
+
54
+ ## Possible Algorithmic Inspirations
55
+
56
+ - **SE(3)/SO(3) equivariant networks**: using group elements as hidden states, updating between layers via Exp/opus, transporting features via Ad; equivariance comes from group actions rather than data augmentation.
57
+ - **Manifold loss for pose regression**: using ominus (geodesic error) as the loss, rather than Euclidean MSE on rotation matrices/quaternions; naturally handles manifold topology (e.g., quaternion double cover).
58
+ - **Lie group optimizers**: rewriting Adam/Gauss-Newton in the retraction form "compute gradient in tangent space -> map back via Exp" (error-state approach, corresponding to the manifold EKF in Sec. V-A).
59
+ - **Differentiable registration / alignment**: camera pose, point cloud ICP, multi-view BA formulated as differentiable optimization layers on SE(3), trained end to end.
60
+ - **Manifold-parameterized output heads**: the network outputs an R^n tangent vector, mapped back to SO(3)/SE(3) via Exp, replacing the various ad-hoc orthogonalization schemes for 6D/9D rotation representations.
61
+ - **Uncertainty-aware fusion**: using the tangent-space covariance from Eq. 52 + Ad propagation to build learnable Kalman/factor-graph layers.
62
+
63
+ ## GPU Friendliness Warning
64
+
65
+ > The sole authority for the acceptance gate: [`../gpu-friendly-math.md`](../gpu-friendly-math.md) (eight dimensions: D1 Tensorization, D2 GEMM-mappability, D3 Complexity, D4 Memory/KV, D5 Low-precision stability, D6 Parallelism & communication, D7 Sparse structure, D8 Operator fusion). Dimension-by-dimension scoring follows.
66
+
67
+ | # | Dimension | Rating | Notes |
68
+ |---|---|---|---|
69
+ | D1 | Tensorization | [v] | SO(3)/SE(3) exp/log have **closed forms** (Rodrigues), 3x3/4x4 small matrices, batched as `[B,3,3]` / `[B,4,4]` tensors, sample-independent |
70
+ | D2 | GEMM-mappability | [~] | 3x3/4x4 are too small to **saturate Tensor Cores**, bmm/batched small GEMM has low utilization and is easily memory-bandwidth-bound; fix: stack the batch dimension large, use specialized small kernels or einsum fusion |
71
+ | D3 | Complexity | [v] | O(1) per element, linear in batch |
72
+ | D4 | Memory | [v] | Elements are tiny; however, Jacobians/covariance matrices for high-DOF composite states can grow large (block-structured, still manageable) |
73
+ | D5 | Low-precision stability | [x] **critical** | exp/log contain terms like `sin(theta)/theta`, `(1-cos(theta))/theta^2`, which cause catastrophic cancellation at **theta->0** (division by zero) and **theta->pi** (log singularity); fp16/bf16 are highly prone to NaN. **Must** switch to Taylor expansion for small angles -- branching introduces warp divergence (hurts D1, D8) |
74
+ | D6 | Parallelism & communication | [~] | Per-sample exp/log is embarrassingly parallel [v]; however **discrete integration / motion chains on manifolds** (Sec. II-I, chained Exp products) are **serial recurrences**, long sequences must be rewritten as parallel scans to achieve parallelism |
75
+ | D7 | Sparse structure | [v] | Composite manifold Jacobians are **block-structured sparse** (Eq. 89), GPU-friendly |
76
+ | D8 | Operator fusion | [v] | Closed-form exp/log/Jacobians can be fused into a **single kernel**, avoiding materialization of intermediate small matrices |
77
+
78
+ **Expanded notes (closed-form vs. series / batching / whether small-matrix exponentials can be tensorized)**:
79
+
80
+ The GPU fate of `exp/log` in Lie theory depends entirely on "whether one is working with a low-dimensional group that admits a closed form."
81
+
82
+ - **Closed-form vs. series (Conclusion 1)**: The exponential map for SO(3) is precisely the **Rodrigues formula** `exp([theta]_x) = I + (sin(theta)/theta)[theta]_x + ((1-cos(theta))/theta^2)[theta]_x^2` (Ex. 4); SE(3) is similar with an additional left-Jacobian factor V(theta) -- both are **finite-term closed forms**, pure tensor algebra, per-sample independent, no data-dependent loops. The opposite case is the **general matrix exponential**: for arbitrary Lie groups there is no Rodrigues-style closed form, only Taylor series + scaling-and-squaring **iterative** approximation, with data-dependent step counts, divergent control flow, and difficult tensorization -- a classic "beautiful but not computable" case. Closed forms exist only for the small set SO(3)/SE(3)/SE(2)/S^1/S^3; **do not treat the general matrix exp as a cheap O(1) operator**.
83
+ - **Batching (Conclusion 2)**: stacking N rotations/poses into `[B,3,3]` / `[B,4,4]` for batched Exp/Log is clean element-wise + small bmm, which can be **fused with downstream operators into a single kernel**. Small-matrix exponentials **can** be tensorized -- batched stacking gives per-sample parallelism; but 3x3/4x4 are too small for bmm to saturate Tensor Cores, the value lies in "batchable and fusible" rather than "maxing out compute," and to improve utilization one should stack the batch large or use specialized small kernels.
84
+ - **Low-precision singularities (Conclusion 3, top risk)**: theta->0 (`sin(theta)/theta` division by zero) and theta->pi (log is non-unique) cause catastrophic cancellation, fp16/bf16 produce NaN directly. Before low-precision training, one **must** implement Taylor-expansion fallbacks for small angles and run deterministic reproducibility tests; the fallback branches introduce warp divergence, requiring `where`/mask implementations rather than data-dependent jumps.
85
+ - **Serial recurrence**: motion chains / discrete integration on manifolds (Sec. II-I) are serial recurrences of chained Exp products; long sequences must be rewritten as parallel scans to saturate the GPU.
86
+
87
+ ## Which Design Lens to Invoke
88
+
89
+ - **symmetry (primary)**: Lie groups are by definition **continuous symmetry transformation groups**; this paper is the most direct mathematical ammunition for "symmetry/invariance -> equivariant networks."
90
+ - **duality (primary)**: exp/log equivalently transforms "curved nonlinear manifold" to "flat linear tangent space" -- a paradigmatic example of transforming a hard problem into an easy one (the dragon-slaying sword used for "chopping vegetables").
91
+ - **variational**: optimization on manifolds, retractions, error-state filtering (Sec. V-A).
92
+ - **geometric**: the modeling closed loop from reality (robotic/camera state + noise) to mathematics (manifold + covariance) to interpretation.
93
+ - **categorical**: abstracting from concrete matrices/quaternions to the unified "group" interface (the paper's own writing style -- generic formulation + grounded examples -- is itself an abstraction demonstration).
94
+
95
+ ## Anti-patterns
96
+
97
+ - **Adding/subtracting rotations/poses directly in Euclidean space**: doing Euclidean MSE or linear interpolation on rotation matrices/quaternions -- breaks manifold constraints; use oplus/ominus and geodesic error instead.
98
+ - **Mixing left and right perturbations**: inconsistent conventions for right/left Jacobians, local/global frames, causing misalignment of covariances and gradients (the paper repeatedly emphasizes defaulting to the right version).
99
+ - **Assuming matrix exp is cheap and closed-form everywhere**: closed forms exist only for SO(3)/SE(3) and a few other groups; general groups require iterative series and cannot be treated as O(1) operators.
100
+ - **Not handling singularities in low precision**: failing to implement Taylor fallbacks for theta->0/pi causes fp16 training to produce NaN immediately.
101
+ - **Treating SE(3) as T(3)xSO(3)**: their tangent-space parameterizations differ (Ex. 7); whether translation and rotation are coupled changes the Jacobian, and misuse leads to systematic bias.
102
+ - **Over-application**: forcing Lie theory onto tasks that do not need uncertainty propagation or geometric constraints, adding complexity and singularity risk for no gain -- mathematical beauty does not mean it should be used.
103
+
104
+ ## Deep Dive Entry
105
+
106
+ > **Bibliographic info**: Joan Sola, Jeremie Deray, Dinesh Atchuthan, *A micro Lie theory for state estimation in robotics*, arXiv:1812.01537v9, 2021. Companion open-source C++ library [manif](https://github.com/artivis/manif).
107
+ >
108
+ > **Activation method**: Place `A micro Lie theory.pdf` in the `math_book/` folder at the project root; the Agent can then automatically search the original text. The PDF is not distributed via npm/git (copyright reasons); obtain it independently.
109
+
110
+ > Full-fidelity lookup = have the Agent automatically retrieve the local PDF: `math_book/A micro Lie theory.pdf` (using `pdftotext` or Read PDF pages). The following are actual section/equation-block locations within that PDF:
111
+
112
+ 1. **Sec. II-D Exponential map + Fig. 1**: exp/log and capital Exp/Log operators (Eq. 23-24) -- the manifold-to-tangent-space bridge and closed-form source; with Ex. 3 (SO(3) Lie algebra `[omega]_x`), Ex. 4 (SO(3) exp = Rodrigues).
113
+ 2. **Sec. II-E Addition/subtraction operators (Eq. 25-28) + Sec. II-F Adjoint Ad_X (Eq. 30-35)**: "addition/subtraction" on manifolds and left/right perturbation conversions; Ex. 6 (SE(3) adjoint matrix).
114
+ 3. **Sec. II-G Derivatives on Lie groups + Sec. III-A Chain rule**: right Jacobian (Eq. 41a-c), left Jacobian (Eq. 44), related through the adjoint -- the geometrically correct form for backpropagation/gradients.
115
+ 4. **Sec. II-H Uncertainty on manifolds and covariance propagation (Eq. 52)**: Sigma defined on the tangent space; Sec. V-A manifold error-state EKF (Eq. 92-96) is the applied example.
116
+ 5. **Appendix formula handbook**: SO(3) right/left Jacobian closed forms (Eq. 143-145), SE(3) Jacobians (citing Barfoot), and Sec. IV composite manifold block-wise Jacobians (Eq. 84-90, Ex. 7) -- direct lookup tables for engineering implementation, cross-referenced with the manif library.
@@ -1,4 +1,4 @@
1
- # 🌀 李理论速成 / A micro Lie theory
1
+ # 李理论速成 / A micro Lie theory
2
2
 
3
3
  > **A micro Lie theory for state estimation in robotics** — Joan Solà, Jeremie Deray, Dinesh Atchuthan.
4
4
  > arXiv:1812.01537v9 [cs.RO],2021-12-08,正文约 17 页 + 附录公式手册。配套开源 C++ 头文件库 **manif**(<https://github.com/artivis/manif>,实现 SO(2)/SO(3)/SE(2)/SE(3) 及解析雅可比)。
@@ -66,14 +66,14 @@
66
66
 
67
67
  | # | 维度 | 评级 | 说明 |
68
68
  |---|---|---|---|
69
- | ① | 张量化 | | SO(3)/SE(3) 的 exp/log 有**闭式**(Rodrigues),3×3/4×4 小矩阵,批量化为 `[B,3,3]` / `[B,4,4]` 张量逐样本独立 |
70
- | ② | GEMM 可映射 | ⚠️ | 3×3/4×4 太小,**吃不满 Tensor Core**,bmm/批量小 GEMM 利用率低、易受访存带宽限制;改造:把 batch 维堆大、用专用小核或 einsum 融合 |
71
- | ③ | 复杂度 | | 每元素 O(1),随 batch 线性 |
72
- | ④ | 显存 | | 元素极小;但高自由度复合状态的雅可比/协方差矩阵会变大(块结构,仍可控) |
73
- | ⑤ | 低精度稳定 | **重点** | exp/log 含 `sinθ/θ`、`(1−cosθ)/θ²` 等项,在 **θ→0**(除零)与 **θ→π**(log 奇异)处灾难性抵消;fp16/bf16 极易 NaN。**必须**对小角做 Taylor 展开切换——而分支会带来 warp divergence(伤①⑧) |
74
- | ⑥ | 并行与通信 | ⚠️ | 逐样本 exp/log 是 embarrassingly parallel ✅;但**流形上的离散积分/运动链**(§II-I,连乘 Exp)是**串行递推**,长序列需写成并行扫描(parallel scan)才能并行 |
75
- | ⑦ | 稀疏结构 | | 复合流形的雅可比是**块结构化稀疏**(式 89),对 GPU 友好 |
76
- | ⑧ | 算子融合 | | 闭式 exp/log/雅可比可融进**单 kernel**,避免物化中间小矩阵 |
69
+ | ① | 张量化 | [v] | SO(3)/SE(3) 的 exp/log 有**闭式**(Rodrigues),3×3/4×4 小矩阵,批量化为 `[B,3,3]` / `[B,4,4]` 张量逐样本独立 |
70
+ | ② | GEMM 可映射 | [~] | 3×3/4×4 太小,**吃不满 Tensor Core**,bmm/批量小 GEMM 利用率低、易受访存带宽限制;改造:把 batch 维堆大、用专用小核或 einsum 融合 |
71
+ | ③ | 复杂度 | [v] | 每元素 O(1),随 batch 线性 |
72
+ | ④ | 显存 | [v] | 元素极小;但高自由度复合状态的雅可比/协方差矩阵会变大(块结构,仍可控) |
73
+ | ⑤ | 低精度稳定 | [x] **重点** | exp/log 含 `sinθ/θ`、`(1−cosθ)/θ²` 等项,在 **θ→0**(除零)与 **θ→π**(log 奇异)处灾难性抵消;fp16/bf16 极易 NaN。**必须**对小角做 Taylor 展开切换——而分支会带来 warp divergence(伤①⑧) |
74
+ | ⑥ | 并行与通信 | [~] | 逐样本 exp/log 是 embarrassingly parallel [v];但**流形上的离散积分/运动链**(§II-I,连乘 Exp)是**串行递推**,长序列需写成并行扫描(parallel scan)才能并行 |
75
+ | ⑦ | 稀疏结构 | [v] | 复合流形的雅可比是**块结构化稀疏**(式 89),对 GPU 友好 |
76
+ | ⑧ | 算子融合 | [v] | 闭式 exp/log/雅可比可融进**单 kernel**,避免物化中间小矩阵 |
77
77
 
78
78
  **展开说明(闭式 vs 级数 / 批量化 / 小矩阵指数能否张量化)**:
79
79
 
@@ -84,13 +84,13 @@
84
84
  - **低精度奇异点(结论 3,头号风险)**:θ→0(`sinθ/θ` 除零)与 θ→π(log 不唯一)会灾难性抵消,fp16/bf16 直接 NaN。低精度训练前**必须**对小角做 Taylor 兜底并做确定性复现测试;兜底分支又会引入 warp divergence,需用 `where`/掩码而非数据相关跳转实现。
85
85
  - **串行递推**:流形上的运动链/离散积分(§II-I)是连乘 Exp 的串行递推,长序列要改写成并行扫描(parallel scan)才能喂满 GPU。
86
86
 
87
- ## 该调用哪个思想武器
87
+ ## 该调用哪个思想透镜
88
88
 
89
- - **⚛️ symmetry-invariance(首选)**:李群本就是**连续对称变换群**,本文是"对称/不变性→等变网络"最直接的数学弹药。
90
- - **🔄 transformation(首选)**:exp/log 把"曲的非线性流形"等价变换到"平的线性切空间"——把难问题变换成易问题的范式样板(屠龙刀"切菜")。
91
- - **⚖️ optimization**:流形上的优化、retraction、误差状态滤波(§V-A)。
92
- - **🌉 modeling**:现实(机器人/相机状态+噪声)→数学(流形+协方差)→解释的建模闭环。
93
- - **🧩 abstraction**:从具体矩阵/四元数抽象出"群"的统一接口(论文正文泛型 + 例子接地的写法本身就是抽象示范)。
89
+ - **symmetry(首选)**:李群本就是**连续对称变换群**,本文是"对称/不变性→等变网络"最直接的数学弹药。
90
+ - **duality(首选)**:exp/log 把"曲的非线性流形"等价变换到"平的线性切空间"——把难问题变换成易问题的范式样板(屠龙刀"切菜")。
91
+ - **variational**:流形上的优化、retraction、误差状态滤波(§V-A)。
92
+ - **geometric**:现实(机器人/相机状态+噪声)→数学(流形+协方差)→解释的建模闭环。
93
+ - **categorical**:从具体矩阵/四元数抽象出"群"的统一接口(论文正文泛型 + 例子接地的写法本身就是抽象示范)。
94
94
 
95
95
  ## 反模式
96
96
 
@@ -103,13 +103,13 @@
103
103
 
104
104
  ## 深挖入口
105
105
 
106
- > **📖 书目信息**:Joan Solà, Jérémie Deray, Dinesh Atchuthan, *A micro Lie theory for state estimation in robotics*, arXiv:1812.01537v9, 2021. 配套开源 C++ 库 [manif](https://github.com/artivis/manif)。
106
+ > **书目信息**:Joan Solà, Jérémie Deray, Dinesh Atchuthan, *A micro Lie theory for state estimation in robotics*, arXiv:1812.01537v9, 2021. 配套开源 C++ 库 [manif](https://github.com/artivis/manif)。
107
107
  >
108
108
  > **启用方式**:将 `A micro Lie theory.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
109
109
 
110
110
  > 全保真回查 = 让 Agent 自动检索本地 PDF:`math_book/A micro Lie theory.pdf`(用 `pdftotext` 或 Read PDF pages)。下列为该 PDF 内的真实章节/公式块定位:
111
111
 
112
- 1. **§II-D 指数映射 + Fig. 1**:exp/log 与大写 Exp/Log 算子(式 23–24)——流形↔切空间桥梁与闭式来源;配 Ex. 3(SO(3) 的李代数 `[ω]×`)、Ex. 4(SO(3) 的 exp = Rodrigues)。
112
+ 1. **§II-D 指数映射 + Fig. 1**:exp/log 与大写 Exp/Log 算子(式 23–24)——流形-> 切空间桥梁与闭式来源;配 Ex. 3(SO(3) 的李代数 `[ω]×`)、Ex. 4(SO(3) 的 exp = Rodrigues)。
113
113
  2. **§II-E 加减算子(式 25–28)+ §II-F 伴随 Ad_X(式 30–35)**:流形上的"加/减"与左右扰动互转;Ex. 6(SE(3) 的伴随矩阵)。
114
114
  3. **§II-G 李群上的导数 + §III-A 链式法则**:右雅可比(式 41a–c)、左雅可比(式 44),二者由伴随相联——反传/梯度的几何正确形式。
115
115
  4. **§II-H 流形上的不确定性与协方差传播(式 52)**:Σ 定义在切空间;§V-A 流形误差状态 EKF(式 92–96)是落地范例。
@@ -0,0 +1,163 @@
1
+ # Optimization (Including ML Applications)
2
+
3
+ > **An Introduction to Optimization, With Applications to Machine Learning** (5th Edition, 2024)
4
+ > Edwin K. P. Chong, Wu-Sheng Lu, Stanislaw H. Zak -- John Wiley & Sons (Hardback ISBN 9781119877639)
5
+ >
6
+ > This file is an "activation reference": synthesized distillation, engineering-oriented, not a verbatim excerpt.
7
+ > Goal -- extract the structures from this classic optimization textbook that **can be applied to algorithms / GPU / training Infra**.
8
+
9
+ ## Overview
10
+
11
+ The fifth edition of a classic continuous optimization textbook. Compared to earlier editions, the largest addition is a completely new **Part V "Optimization in Machine Learning"**, which fully integrates first-order/second-order optimality, duality, KKT, and convergence theory with training practices such as SGD/SVM/PCA. The book has 31 chapters organized into five parts.
12
+
13
+ Actual chapter map:
14
+
15
+ - **Part I -- Mathematical Review (Ch 1-5)**
16
+ - Ch 1 Proof methods and notation; Ch 2 Vector spaces and matrices (rank, inner products and norms).
17
+ - Ch 3 Transformations: eigenvalues/eigenvectors, orthogonal projections, quadratic forms S3.4, matrix norms S3.5.
18
+ - Ch 4 Geometry: hyperplanes, **convex sets S4.3**, polytopes and polyhedra.
19
+ - Ch 5 Calculus: derivative matrices S5.3, **level sets and gradients S5.5**, Taylor series S5.6.
20
+ - **Part II -- Unconstrained Optimization (Ch 6-14)**
21
+ - Ch 6 First-order/second-order necessary and sufficient conditions for local minima.
22
+ - Ch 7 One-dimensional search: golden section, Fibonacci, bisection, Newton, secant, line search.
23
+ - **Ch 8 Gradient methods** (steepest descent S8.2, convergence analysis S8.3).
24
+ - **Ch 9 Newton's method** (Levenberg-Marquardt S9.3, nonlinear least squares).
25
+ - Ch 10 Conjugate direction/conjugate gradient methods; **Ch 11 Quasi-Newton methods** (inverse Hessian approximation, DFP S11.4, **BFGS S11.5**).
26
+ - Ch 12 Solving linear equations (least squares, RLS, Kaczmarz, minimum-norm solutions).
27
+ - **Ch 13 Neural networks and backpropagation** (single-neuron training S13.2, Backprop S13.3).
28
+ - Ch 14 Global search: Nelder-Mead, simulated annealing, PSO, genetic algorithms.
29
+ - **Part III -- Linear Programming (Ch 15-19)**
30
+ - Ch 15 LP fundamentals and geometry; Ch 16 Simplex method.
31
+ - **Ch 17 LP duality** (dual LP, matrix games).
32
+ - Ch 18 Non-simplex/interior-point methods (Khachiyan, affine scaling, Karmarkar); Ch 19 Integer programming.
33
+ - **Part IV -- Nonlinear Constrained Optimization (Ch 20-25)**
34
+ - Ch 20 Equality constraints: tangent/normal spaces S20.3, **Lagrange conditions S20.4**, second-order conditions.
35
+ - **Ch 21 Inequality constraints and KKT** (KKT S21.1, second-order conditions S21.2).
36
+ - **Ch 22 Convex optimization** (convex functions S22.2, convex problems S22.3, SDP/LMI S22.4).
37
+ - **Ch 23 Lagrangian duality** (weak/strong duality, duality gap S23.4.6, Slater S23.6.3, saddle points).
38
+ - Ch 24 Constrained optimization algorithms (projection S24.2, **projected gradient S24.3**, Armijo S24.4.4, augmented Lagrangian S24.5, penalty methods S24.6).
39
+ - Ch 25 Multi-objective / robust LP (Pareto, uncertainty).
40
+ - **Part V -- Optimization in ML (Ch 26-31)**
41
+ - Ch 26 Feature engineering, PCA, SVD, linear autoencoders.
42
+ - **Ch 27 SGD algorithms** (SGD S27.1, variance reduction **SVRG S27.2**, **distributed SVRG and communication/computation tradeoffs S27.3**).
43
+ - Ch 28 Linear regression (regularization S28.3, cross-validation); Ch 29 Logistic regression / Softmax.
44
+ - **Ch 30 SVM** (hinge loss, hard/soft margin); **Ch 31 Kernel methods and K-Means**.
45
+
46
+ ## Core Structures Transferable to AI/Infra
47
+
48
+ - **First-order optimality + gradient geometry (Ch 6, S5.5)**
49
+ - Gradient is perpendicular to level sets and is the steepest ascent direction -- the axiomatic root of all training optimizers.
50
+ - `nabla f = 0` is the stopping criterion; saddle points / non-convexity are the central pain points of modern deep learning.
51
+ - **Convergence analysis framework (Ch 8 S8.3)**
52
+ - Uses the condition number kappa = lambda_max/lambda_min to characterize the convergence rate of steepest descent.
53
+ - Explains "why ill-conditioned networks are hard to train, why normalization / preconditioning is needed."
54
+ - **Second-order curvature and damping (Ch 9)**
55
+ - Newton's method uses the Hessian to provide affine-invariant step sizes and directions.
56
+ - Levenberg-Marquardt's `(H+mu I)` damping = trust-region idea, the ancestor of Adam's `epsilon` and second-order optimizers.
57
+ - **Quasi-Newton low-rank updates (Ch 11)**
58
+ - BFGS/DFP uses only gradient differences, maintaining an inverse Hessian approximation via rank-1/rank-2 updates.
59
+ - Direct intellectual ancestor of L-BFGS, K-FAC, and Shampoo.
60
+ - **Matrix-free second-order methods (Ch 10)**
61
+ - Conjugate gradient requires only Hessian-vector products without storing the full Hessian; corresponds to autodiff HVP (Hessian-free).
62
+ - **Constraint geometry (Ch 20-21, 24)**
63
+ - Tangent/normal spaces -> Lagrange/KKT -> projected gradient + penalty / augmented Lagrangian.
64
+ - Forms a complete toolkit for "training with constraints."
65
+ - **Duality and saddle points (Ch 17, 23)**
66
+ - Strong duality <=> minimax = maximin; KKT, complementary slackness, Slater conditions.
67
+ - Min-max training (GAN / adversarial robustness) and SVM duality both fall here.
68
+ - **Stochastic and distributed methods (Ch 27)**
69
+ - SGD's unbiased gradient estimation, SVRG variance reduction.
70
+ - **Explicit "communication vs. computation" tradeoff in distributed settings** -- the theoretical root of data-parallel training.
71
+ - **Low-rank / spectral methods (Ch 26, S3.4)**
72
+ - SVD/PCA/linear autoencoders, quadratic forms and spectra -- the mathematical foundation of LoRA, KV compression, and spectral normalization.
73
+
74
+ ## Problem Types Suited for Activation
75
+
76
+ - Selecting / designing optimizers, or explaining training dynamics (why divergence, oscillation, or stagnation at saddle points occurs).
77
+ - Diagnosing ill-conditioning and slow convergence: quantifying "hard to train" via the condition number kappa.
78
+ - Training with constraints: weight-norm balls, spectral norms, safety / budget constraints, requiring projection or penalty methods.
79
+ - Min-max / adversarial / dual perspectives: replacing a hard primal with an easier dual (e.g., kernel Gram matrix).
80
+ - Communication-computation tradeoffs, gradient compression, and variance reduction in distributed training.
81
+ - Scenarios requiring second-order information but unable to compute the full Hessian (curvature-adaptive preconditioning).
82
+
83
+ ## Possible Algorithmic Inspirations
84
+
85
+ - **Adaptive optimizers**
86
+ - Levenberg-Marquardt's `(H+mu I)` damping -> Adam's `epsilon`, trust regions, adaptive learning rates.
87
+ - Making "curvature / damping" explicit rather than staying with purely heuristic hyperparameter tuning.
88
+ - **Feasible second-order for large models**
89
+ - L-BFGS: Store only the most recent m gradient pairs (low-rank history, memory O(md)).
90
+ - Hessian-free: Autodiff HVP + CG (matrix-free, no need to materialize the Hessian).
91
+ - K-FAC / Shampoo: Approximate the Hessian as **block-diagonal / Kronecker factors**, reducing each block to a small GEMM.
92
+ - **Efficient solving via the dual perspective**
93
+ - SVM converts a high-dimensional primal into a dual that depends only on the kernel Gram matrix (Ch 30-31), a big win when sample count << dimensionality.
94
+ - Dual decomposition of constrained problems is naturally parallelizable.
95
+ - **Constrained training**
96
+ - Projected gradient (S24.3) for norm-ball / spectral-norm constraints (weight clipping, spectral normalization).
97
+ - Augmented Lagrangian / penalty methods (S24.5-S24.6) soften hard constraints into differentiable regularization.
98
+ - **Variance reduction / large batch**
99
+ - SVRG's (S27.2) control variate idea -> gradient accumulation, stability analysis of large-batch training.
100
+ - **Distributed training**
101
+ - S27.3 "Communication vs. Computation" directly corresponds to all-reduce and computation overlap, gradient compression, federated / data security.
102
+
103
+ ## GPU Friendliness Warning
104
+
105
+ > The following item-by-item evaluation uses the **eight-dimension scorecard** from `../gpu-friendly-math.md` (read that first).
106
+ > Conclusion: The book's first-order / stochastic / low-rank content is naturally GPU-friendly; second-order methods and search-based methods require heavy adaptation or elimination.
107
+
108
+ - **Full Hessian in second-order methods (Ch 9, 11)**
109
+ - Violates **Dimension 4 (Memory)**: Dense Hessian is O(d^2), impossible to materialize for hundreds of millions of parameters.
110
+ - Violates **Dimension 2 (GEMM-mappability)**: Inversion / factorization is not batched-GEMM friendly.
111
+ - Violates **Dimension 5 (Low-precision stability)**: Ill-conditioned inversion causes catastrophic cancellation under bf16/fp16.
112
+ - Adaptation: Matrix-free HVP + CG, L-BFGS low-rank, K-FAC block-diagonal -> restores **Dimension 2/4** friendliness.
113
+ - **Line search (Ch 7 golden section / Armijo S24.4.4)**
114
+ - Violates **Dimension 1 (Tensorization)**: Essentially a scalar loop + data-dependent branching (step-by-step comparison of function values).
115
+ - Violates **Dimension 8 (Operator fusion)**: Frequent small kernels, control-flow divergence.
116
+ - Adaptation: Large models almost universally use scheduled step sizes (warmup + cosine) instead of step-by-step line search.
117
+ - **First-order / SGD (Ch 8, 27)**
118
+ - **Dimension 1/2 friendly**: Gradients = tensor algebra, expressible as GEMM.
119
+ - **Dimension 6 (Parallelism and communication)** is good: Data-parallel all-reduce can overlap with backprop -- the fundamental reason this is the default approach for large models.
120
+ - **Global search (Ch 14: GA/SA/PSO)**
121
+ - Violates **Dimension 1**: Non-differentiable, discrete stochastic search, blocks end-to-end gradient training.
122
+ - **Dimension 6** is also poor: Inter-population dependencies, hard to parallelize. Only suitable for black-box hyperparameter search, not for the training inner loop.
123
+ - **LP simplex / interior-point methods (Ch 16, 18)**
124
+ - Simplex row operations are acceptable; interior-point methods require solving a linear system at each step, **Dimension 2/6** limited by factorization and communication.
125
+ - Suitable for medium-scale constrained subproblems, not for placement inside every training step.
126
+ - **Projections (S24.2)**
127
+ - Norm-ball / box projections are cheap elementwise operations (**Dimension 1/8** friendly).
128
+ - General polyhedral projections require solving a QP (**Dimension 2** degrades).
129
+ - **Convergence depends on condition number kappa**
130
+ - Large kappa -> **Dimension 5** is further amplified at low precision (ill-conditioned gradients).
131
+ - Must pair with normalization / preconditioning; otherwise bf16 training diverges.
132
+
133
+ ## Which Thinking Lens to Invoke
134
+
135
+ - **variational** (primary): The complete objective-constraint-optimality-convergence framework; this book is its core source; translate real-world tasks (classification / regression / constraints) into solvable optimization problems.
136
+ - **algorithmic**: Convergence properties, complexity, step size / stopping criteria for iterative algorithms.
137
+ - **duality**: Duality, kernel methods, variable substitution, SVD/PCA -- "equivalence transformations to simplify problems."
138
+ - **probabilistic**: SGD stochastic gradients, SVRG variance reduction, cross-validation / regularization.
139
+
140
+ ## Anti-patterns
141
+
142
+ - Applying **full-Hessian Newton** directly to large models -- O(d^2) memory and inversion blow up immediately (must use matrix-free / low-rank / block-diagonal).
143
+ - Using **line search** to tune step sizes at every step of a large model -- scalar serial, control-flow divergence, burns through compute; should switch to scheduled learning rates.
144
+ - Using **GA/SA/PSO to train neural networks** -- non-differentiable, cannot parallelize, extremely sample-inefficient; limited to black-box hyperparameter search only.
145
+ - Discussing convergence while **ignoring the condition number kappa** -- expecting low-precision convergence without normalization / preconditioning is wishful thinking.
146
+ - Forcing **LP simplex thinking** onto continuously differentiable problems.
147
+ - Treating **duality / KKT as universal** -- non-convex problems typically lack strong duality and have duality gaps (S23.4.6); KKT is only a necessary condition.
148
+ - Treating this "activation reference" as a source of rigorous proofs -- details and theorem conditions must be verified against the original book.
149
+
150
+ ## Deep-dive Entry
151
+
152
+ > **Bibliographic information**: Edwin K. P. Chong, Wu-Sheng Lu, Stanislaw H. Zak, *An Introduction to Optimization, With Applications to Machine Learning*, 5th Edition, John Wiley & Sons, 2024. ISBN 978-1-119-87763-9.
153
+ >
154
+ > **Activation method**: Place `An Introduction to Optimization With Applications to Machine Learning.pdf` in the `math_book/` folder at the project root; the Agent can then automatically search the original text. The PDF is not distributed via npm/git (copyright reasons) and must be obtained separately.
155
+
156
+ Full-fidelity lookup = have the Agent directly search the local PDF
157
+ `math_book/An Introduction to Optimization With Applications to Machine Learning.pdf`, locating by actual chapter numbers:
158
+
159
+ - **Ch 8 Gradient Methods** (S8.3 convergence analysis, condition numbers) + **Ch 11 Quasi-Newton Methods** (S11.5 BFGS) -- Optimizers and feasible second-order methods.
160
+ - **Ch 22 Convex Optimization Problems** (S22.2 convex functions, S22.4 SDP/LMI) -- Convexity criteria and semidefinite programming.
161
+ - **Ch 23 Lagrangian Duality** (S23.5 strong duality, S23.6.3 Slater conditions) + **Ch 21 KKT Conditions** -- Duality / KKT / saddle points.
162
+ - **Ch 24 Algorithms for Constrained Optimization** (S24.3 projected gradient, S24.5 augmented Lagrangian, S24.6 penalty methods) -- Constrained training algorithms.
163
+ - **Ch 27 Stochastic Gradient Descent Algorithms** (S27.1 SGD, S27.2 SVRG, S27.3 distributed and communication/computation) -- Large-scale training core.
@@ -1,4 +1,4 @@
1
- # ⚙️ 最优化(含 ML 应用)/ Optimization with ML
1
+ # 最优化(含 ML 应用)/ Optimization with ML
2
2
 
3
3
  > **An Introduction to Optimization, With Applications to Machine Learning** (5th Edition, 2024)
4
4
  > Edwin K. P. Chong, Wu-Sheng Lu, Stanisław H. Żak — John Wiley & Sons(Hardback ISBN 9781119877639)
@@ -130,13 +130,12 @@
130
130
  - κ 大 → **维度 5** 在低精度下被进一步放大(病态梯度)。
131
131
  - 必须配归一化 / 预条件,否则 bf16 训练发散。
132
132
 
133
- ## 该调用哪个思想武器
133
+ ## 该调用哪个思想透镜
134
134
 
135
- - **optimization**(主):目标-约束-最优性-收敛的完整框架,本书是其核心出处。
136
- - **algorithmic-thinking**:迭代算法的收敛性、复杂度、步长 / 停机判据。
137
- - **transformation**:对偶、核技巧、变量替换、SVD/PCA——"等价转换简化问题"。
138
- - **modeling**:把现实任务(分类 / 回归 / 约束)翻译成可解的优化问题。
139
- - **probability-statistics**:SGD 随机梯度、SVRG 方差缩减、交叉验证 / 正则化。
135
+ - **variational**(主):目标-约束-最优性-收敛的完整框架,本书是其核心出处;把现实任务(分类 / 回归 / 约束)翻译成可解的优化问题。
136
+ - **algorithmic**:迭代算法的收敛性、复杂度、步长 / 停机判据。
137
+ - **duality**:对偶、核技巧、变量替换、SVD/PCA——"等价转换简化问题"。
138
+ - **probabilistic**:SGD 随机梯度、SVRG 方差缩减、交叉验证 / 正则化。
140
139
 
141
140
  ## 反模式
142
141
 
@@ -150,7 +149,7 @@
150
149
 
151
150
  ## 深挖入口
152
151
 
153
- > **📖 书目信息**:Edwin K. P. Chong, Wu-Sheng Lu, Stanisław H. Żak, *An Introduction to Optimization, With Applications to Machine Learning*, 5th Edition, John Wiley & Sons, 2024. ISBN 978-1-119-87763-9.
152
+ > **书目信息**:Edwin K. P. Chong, Wu-Sheng Lu, Stanisław H. Żak, *An Introduction to Optimization, With Applications to Machine Learning*, 5th Edition, John Wiley & Sons, 2024. ISBN 978-1-119-87763-9.
154
153
  >
155
154
  > **启用方式**:将 `An Introduction to Optimization With Applications to Machine Learning.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
156
155