Linear algebra describes objects such as vectors and matrices and the operations we perform on them. Python lets us carry out those operations, test conjectures, and work with examples too large to compute by hand.
This chapter is a pre-course bootcamp. It does not assume prior programming experience, and it introduces only the Python needed for the rest of this book.
Learning objectives¶
By the end of this chapter, you will be able to:
work in a Jupyter notebook and restart a notebook safely;
use Python variables, expressions, functions, conditionals, and loops;
create NumPy arrays and inspect their shape and data type;
select and reshape array data with indexing, slicing, and masks;
explain and use vectorized operations and broadcasting;
distinguish elementwise multiplication from matrix multiplication;
use
numpy.linalg.solveto solve a square linear system;explain why explicitly computing an inverse is usually not the best way to solve a system; and
create labeled plots of scalar and vector data with Matplotlib.
Chapter map¶
| Section | Main ideas | Suggested time |
|---|---|---|
| 0.1 Getting started | Jupyter workflow, kernels, Markdown, imports | 30–45 min |
| 0.2 Python basics | Values, functions, control flow | 60–75 min |
| 0.3 NumPy arrays | Shapes, indexing, slicing, broadcasting | 75–90 min |
| 0.4 Linear algebra tools | Matrix multiplication, solve, inverse | 60–75 min |
| 0.5 Visualization | Line, scatter, and vector plots | 45–60 min |
| Lab 0 | Integrated readiness practice | 90–120 min |
Conventions used in this book¶
x,y, andvusually name vectors.A,B, andMusually name matrices.Python uses zero-based indexing: the first item has index
0.A code comment begins with
#.The symbol
=assigns a value in Python; it does not assert a mathematical equation.The operator
@performs matrix multiplication for NumPy arrays.