liveBook · Manning

NumPy

As explained in Geometry for Programmers

NumPy is a Python library for numerical computing with multidimensional arrays and mathematical operations.

NumPy is a Python library for efficient numeric computation. It provides operable arrays and matrices, making familiar arithmetic work across collections of values as well as individual numbers. section 6.3.5 section 10.1.2

Use NumPy to:

  • Declare matrices and column vectors. section 6.3.5
  • Solve systems of linear equations with np.linalg.solve. section 6.3.5
  • Create coordinate grids with linspace and meshgrid for numeric calculations over a region. section 10.1.2
  • Adapt scalar functions for array inputs with @np.vectorize when conditional branching makes direct array processing ambiguous. section 10.1.2

Solving a small linear system

Represent the coefficient matrix and right-hand side as NumPy arrays, then call np.linalg.solve(a, b) to obtain the solution vector. section 6.3.5

N = 100
x = np.linspace(-1.4, 1.4, N)   #1
y = np.linspace(-1.4, 1.4, N)   #1
 
X, Y = np.meshgrid(x, y)        #2
 
SDF = (X*X + Y*Y)**0.5  - 1

Inspect how linspace and meshgrid turn coordinate ranges into arrays suitable for evaluating a circle’s signed distance function. section 10.1.2

How Geometry for Programmers covers it

How deep it goes
Demonstrates matrix solving, coordinate grids, and vectorization, while stopping short of detailed numerical-method internals.
Examples
Uses interpolating data, matrices, linear systems, circle signed distance functions, linspace, meshgrid, and vectorized branching.
What it assumes
Assumes basic equations, coordinate planes, functions, and Python-reading skills, but introduces NumPy without requiring prior library familiarity.
What you can do after
Apply NumPy to construct arrays, solve linear systems, evaluate functions over grids, and process scalar logic across arrays.
How it connects
Connects numerical computation with SymPy, Matplotlib, interpolation, signed distance functions, and linear algebra.

Also explained in

Compare how 7 books explain NumPy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.