Math for Programming: Learn the Math, Write Better Code
Book information
Description
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. Through clear explanations and practical examples, you’ll learn to: • Harness linear algebra to manipulate data with unprecedented efficiency • Apply calculus concepts to optimize algorithms and drive simulations • Use probability and statistics to model uncertainty and analyze data • Master the discrete mathematics that powers modern data structures • Solve dynamic problems through differential equations Whether you’re seeking to fill gaps in your mathematical foundation or looking to refresh your understanding of core concepts, Math for Programming will turn complex math into a practical tool you’ll use every day. About the Author Brief Contents Contents in Detail 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 1Computers 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 2Sets 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 3Boolean 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 4Functions 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 5Induction 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 6Recurrence 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 7Number 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 8Counting 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 9Graphs 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 10Trees 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 Using the Code The Animals Game Summary 11Probability 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 12Statistics 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 13Linear Algebra Vectors and Vector Spaces Definitions Vectors as Geometric Objects Vectors in Rn 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 14Differential 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 15Integral 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 16Differential 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
Similar books
The Art of Randomness: Randomized Algorithms in the Real World
2024 · EPUB
Math for Programming: Learn the Math, Write Better Code
2025 · MOBI
Math for Programming: Learn the Math, Write Better Code
2025 · EPUB
How AI Works
2024 · EPUB
Math for Programming : Learn the Math, Write Better Code
2025 · EPUB
Numbers and Computers
2024 · EPUB
Numbers and Computers
2024 · PDF
Math for Programming (Early Access)
2025 · PDF