Math for programming Learn the math, write better code

Ronald T. Kneusel

Book - 2025

"A one-stop-shop for all the math you should have learned for your programming career. Every great programming challenge has mathematical principles at its heart. Whether you're optimizing search algorithms, building physics engines for games, or training neural networks, success depends on your grasp of core mathematical concepts. In Math for Programming, you'll master the essential mathematics that will take you from basic coding to serious software development. You'll discover how vectors and matrices give you the power to handle complex data, how calculus drives optimization and machine learning, and how graph theory leads to advanced search algorithms." --

Saved in:
1 being processed
Coming Soon
Subjects
Published
San Francisco : No Starch Press [2025]
Language
English
Main Author
Ronald T. Kneusel (author)
Physical Description
xxv, 475 pages : illustrations ; 24 cm
Bibliography
Include index.
ISBN
9781718503588
  • Foreword
  • Acknowledgments
  • Introduction
  • Who Is This Book For?
  • What I Expect You to Know Already
  • What Can You Expect to Learn?
  • How to Use This Book
  • 1. Computers and Numbers
  • Numbers and Number Bases
  • Binary, Octal, and Hexadecimal Numbers
  • Conversions Between Number Bases
  • How Computers Represent Numbers
  • Integers
  • Floating-Point Numbers
  • What You Need to Know About Floating-Point Arithmetic
  • Round-Off Error
  • Unrepresentable Numbers
  • Summary
  • 2. Sets and Abstract Algebra
  • Concerning Sets
  • Special Sets
  • Set Operations
  • Set Operations in Python
  • Venn Diagrams
  • Subsets and Supersets
  • Power Sets
  • The Laws of Set Theory
  • Experimenting with Number Sets in Python
  • Abstract Algebra and Groups
  • Examples of Groups, Magmas, and Monoids
  • Special Groups
  • Cantor: To Infinity and Beyond
  • The Cardinality of Infinite Sets
  • The Continuum Hypothesis and Infinities Without End
  • Computable and Uncomputable Numbers
  • Uncomputable Python
  • Summary
  • 3. Boolean Algebra
  • Definition and Laws
  • Boolean Algebra Leads to Digital Logic
  • Set Theory as a Boolean Algebra
  • Propositional Logic as a Boolean Algebra
  • The Set {{0, 1}} as a Boolean Algebra
  • The Truth Tables of Digital Logic
  • Boolean Functions
  • Duals and Complements
  • Boolean Functions in Code
  • Canonical Normal Forms
  • Sum of Products
  • Product of Sums
  • Karnaugh Maps
  • Algebraic Simplification of Boolean Expressions
  • Digital Circuits
  • Boolean Functions as Digital Circuits
  • All You Need Is NAND (or NOR)
  • A Binary Adder
  • Logic Gate Construction
  • Summary
  • 4. Functions and Relations
  • Functions
  • Visualization of Functions
  • Onto, One-to-One, and Inverse Functions
  • Composition of Functions
  • Binary Relations
  • Cartesian Products
  • Definition
  • Relations as Matrices
  • Counting Relations
  • Relations on Infinite Sets
  • Composition
  • Converse and Complement
  • Binary Relations as Graphs
  • n-ary Relations
  • Binary Relations in Code
  • Equivalence Relations and Classes
  • Equivalence Classes
  • Number Sets
  • Partial Orderings
  • Summary
  • 5. Induction
  • Weak Induction
  • Strong Induction
  • The Chicken Nuggets Problem
  • The Fundamental Theorem of Arithmetic
  • Cautionary Tales
  • Forgetting the Base Case
  • Reversing the Implication
  • Showing the Inductive Hypothesis Holds for All m
  • Proving with Loop Invariants
  • Integer Square Root
  • Bubble Sort
  • Binary Search
  • Gnome Sort
  • Summary
  • 6. Recurrence and Recursion
  • Recurrence Relations
  • Linear Recurrence Relations
  • The Collatz Sequence
  • Nonlinear Recurrence Relations
  • Logistic Map
  • Mandelbrot Set
  • Solving Recurrence Relations
  • First-Order Relations
  • Second-Order Relations
  • Recursion
  • Powers
  • Factorials
  • Fibonacci Sequence
  • Quicksort
  • Towers of Hanoi
  • Summary
  • 7. Number Theory
  • Primes
  • Proving Euclid's Theorem
  • Locating Primes
  • Identifying Prime Subsets
  • Exploring Quirky Primes
  • Running the Primality Test
  • Investigating the Goldbach Conjecture
  • Divisibility
  • Divisibility Properties
  • The Least Common Multiple and the Greatest Common Divisor
  • Modular Arithmetic
  • Congruences
  • Modular Equations
  • Diophantine Equations
  • Linear
  • Nonlinear
  • Integer Sequences
  • Euler's Totient Function
  • Aliquot Sum and Sequence
  • Harshad Numbers
  • Narayana's Cows
  • Deranged Subfactorials
  • Smith and Ruth-Aaron Numbers
  • Sequence Audio
  • Summary
  • 8. Counting and Combinatorics
  • The Principles of Counting
  • An Example: Hats in the Park
  • Women Without Hats
  • Men with (and Without) Hats
  • Loose Ends
  • Sum and Product Rules
  • Inclusion-Exclusion
  • The Pigeonhole Principle
  • Permutations and Combinations
  • Permutations
  • Combinations
  • The Binomial Theorem
  • Summary
  • 9. Graphs
  • Basic Graph Concepts
  • Complete Graphs
  • Graph Isomorphisms
  • Representing Graphs in Code
  • Adjacency Lists
  • Adjacency Matrices
  • Breadth-First and Depth-First Traversal and Searching
  • Breadth-First Traversal
  • Depth-First Traversal
  • Traversals as Searches
  • The Shortest Path Between Nodes
  • Unweighted Shortest Path
  • Dijkstra's Algorithm for Weighted Graphs
  • Directed Acyclic Graphs and Topological Sort
  • Working Through an Example
  • Coding Topological Sort
  • Summary
  • 10. Trees
  • Defining Trees
  • Spanning Trees
  • Locating Spanning Trees
  • Finding Minimum Spanning Trees
  • Rooted and Ordered Trees
  • Binary Trees
  • Binary Tree Traversals and Searches
  • Using Breadth-First Tree Traversal
  • Using Depth-First Tree Traversal
  • Searching a Tree
  • Binary Trees in Code
  • Creating Traversals in Code
  • Usinq the Code
  • The Animals Game
  • Summary
  • 11. Probability
  • Events and Random Variables
  • The Rules of Probability
  • Probability of an Event
  • Sum Rule
  • Product Rule
  • Sum Rule Update
  • Conditional Probability
  • Total Probability
  • Joint and Marginal Probabilities
  • Joint Probability Tables
  • Chain Rule for Probability
  • Probability Distributions
  • Histograms
  • Discrete Distributions
  • Continuous Distributions
  • The Central Limit Theorem and the Law of Large Numbers
  • Bayes' Theorem
  • Summary
  • 12. Statistics
  • Types of Data
  • Nominal
  • Ordinal
  • Interval
  • Ratio
  • Summary Statistics
  • Means, Median, and Mode
  • Measures of Variation
  • Quantiles and Box Plots
  • Quantiles and Percentiles
  • Box Plots
  • Robustness and Sensitivity to Outliers
  • Correlation
  • Pearson Correlation
  • Spearman Correlation
  • A Cautionary Tale: Anscombe's Quartet
  • Hypothesis Testing
  • A Gedankenexperiment
  • Independent Samples
  • Paired Samples
  • Confidence Intervals
  • Confidence Intervals and Hypothesis Tests
  • Confidence Intervals and Sample Size
  • Summary
  • 13. Linear Algebra
  • Vectors and Vector Spaces
  • Definitions
  • Vectors as Geometric Objects
  • Vectors in R n
  • Row and Column Vectors
  • Vector Operations
  • Treasure Island Redux
  • Vector Space Concepts
  • Subspaces, Linear Combinations, and Spanning Sets
  • Linear Independence and Basis Sets
  • Matrices
  • Exploring Matrix Examples
  • Forming Vector Spaces
  • Solving Systems of Linear Equations
  • Gauss-Jordan Elimination
  • Linear Vector Equations
  • Square Matrices
  • Properties of Square Matrices
  • Matrix Rank
  • Determinants
  • Linear Transformations
  • Affine Transformations
  • Iterated Function Systems
  • Eigenvalues and Eigenvectors
  • Finding Eigenvalues
  • Finding Eigenvectors
  • Summary
  • 14. Differential Calculus
  • Derivatives
  • Basic Rules
  • Rules for Trigonometric Functions
  • The Chain Rule
  • Rules for Exponentials and Logarithms
  • Minima and Maxima of Functions
  • Using the Second Derivative Test
  • Locating Stationary Points with Newton's Method
  • Partial Derivatives
  • Mixed Partial Derivatives
  • The Chain Rule for Partial Derivatives
  • Derivatives in Code
  • Numeric Differentiation
  • Automatic Differentiation
  • Symbolic Differentiation
  • Optimization with Gradient Descent
  • Summary
  • 15. Integral Calculus
  • Curves and Areas
  • Indefinite Integrals
  • A Few Indefinite Integrals
  • Antiderivatives
  • A Fistful of Integration Tricks
  • Definite Integrals
  • The Throwing Darts Metaphor
  • Monte Carlo Integration
  • Trapezoidal Rule
  • Simpson's Rule
  • Definite Integrals with Sympy
  • Adaptive Numerical Integration
  • Summary
  • 16. Differential Equations
  • Ordinary Differential Equations
  • First-Order
  • Second-Order
  • Solving Odes Numerically
  • Euler's Method
  • Runge-Kutta Method
  • Worked Examples
  • Simple Pendulum
  • Projectile Motion with Drag
  • SIR Epidemic Model
  • Lorenz Attractor
  • Summary
  • Final Words
  • Index