Skip to main content
Contents
Dark Mode Prev Up Next
\(\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\dimens}{\operatorname{dim}}
\DeclareMathOperator{\row}{\operatorname{row}}
\DeclareMathOperator{\col}{\operatorname{col}}
\newcommand{\im}{\operatorname{im}}
\newcommand{\nulls}{\operatorname{null}}
\newcommand{\minor}{\operatorname{minor}}
\newcommand{\spans}{\operatorname{span}}
\newcommand{\nullity}{\operatorname{nullity}}
\newcommand{\kers}{\operatorname{ker}}
\newcommand{\proj}{\operatorname{proj}}
\newcommand{\diag}{\operatorname{diag}}
\newcommand{\Tr}{\operatorname{Tr}}
\newcommand{\rank}{\operatorname{rank}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Appendix B NumPy and SymPy Quick Reference for the Labs
This appendix explains the computational notation used in the Applications and Computation sections and linked notebooks. It assumes familiarity with basic Python variables, arithmetic, functions, and loops, but it does not assume prior experience with NumPy arrays, array slicing, matrix products, numerical linear algebra, or SymPy symbolic matrices.
The goal is not to teach all of Python. The goal is to help you read short computational snapshots as mathematical notation.
Arrays, shapes, and slicing
Use
B.1 ,
B.2 , and
B.3 when code imports libraries, creates arrays, checks shapes, or selects rows and columns.
Products and vector comparisons
Use
B.4 ,
B.5 , and
B.6 when code uses
*,
@, norms, distances, cosine similarity, or rankings.
Row-wise computations and constructors
Use
B.7 and
B.8 when code uses axes, sums, maxima, design matrices, or common arrays.
Numerical checks
Use
B.9 when code checks approximate equality, residual orthogonality, or rounded output.
Linear algebra commands
Use
B.10 for rank, determinants, solves, least squares, factorizations, eigenvalue commands, and outer products.
Symbolic computation
Use
B.11 for SymPy matrices, row reduction, null spaces, Jacobians, substitution, and conversion to NumPy.
Small Python patterns
Use
B.12 for helper functions, loops, comprehensions, and assertions.
Optional code
Use
B.13 and
B.14 for optional attention masks and plotting.
B.1 How to Read Computational Cells
B.2 NumPy Arrays, Vectors, Matrices, and Shapes
B.3 Indexing and Slicing
B.4 Elementwise Arithmetic Versus Linear Algebra
B.5 Dot Products, Norms, Distances, and Cosine Similarity
B.6 Sorting and Rankings
B.7 Reductions, Axes, and Row-Wise Computations
B.8 Constructing Common Arrays and Design Matrices
B.9 Numerical Checks and Roundoff
B.10 NumPy Linear Algebra Commands
B.11 SymPy Symbolic Computation
B.12 Small Python Patterns Used in the Labs
B.13 Boolean Masks, Copying, and Attention Helpers
B.14 Optional Plotting
B.15 Quick Reference