Math for Programmers
3D graphics, machine learning, and simulations with Python
Paul Orland
  • MEAP began December 2018
  • Publication in Spring 2020 (estimated)
  • ISBN 9781617295355
  • 550 pages (estimated)
  • printed in black & white

It feels like you're learning exactly what you need to know to get stuff done.

Jens Christian Bredahl Madsen
To score a job in data science, machine learning, computer graphics, and cryptography, you need to bring strong math skills to the party. Math for Programmers teaches the math you need for these hot careers, concentrating on what you need to know as a developer. Filled with lots of helpful graphics and more than 200 exercises and mini-projects, this book unlocks the door to interesting–and lucrative!–careers in some of today’s hottest programming fields.
Table of Contents detailed table of contents

1 Learning Math in Code

1.1 Solving lucrative problems with math and software

1.1.1 Predicting financial market movements

1.1.2 Finding a good deal

1.1.3 Building 3D graphics and animations

1.1.4 Modeling the physical world

1.2 How not to learn math

1.2.1 Jane wants to learn some math

1.2.2 Slogging through math textbooks

1.3 Using your well-trained left brain

1.3.1 Using a formal language

1.3.2 Build your own calculator

1.3.3 Building abstractions with functions

1.4 Summary

Part I: Vectors and Graphics

2 Drawing with 2D Vectors

2.1 Drawing with 2D Vectors

2.1.1 Representing 2D vectors

2.1.2 2D Drawing in Python

2.1.3 Exercises

2.2 Plane vector arithmetic

2.2.1 Vector components and lengths

2.2.2 Multiplying Vectors by Numbers

2.2.3 Subtraction, displacement, and distance

2.2.4 Exercises

2.3 Angles and Trigonometry in the Plane

2.3.1 From angles to components

2.3.2 Radians and trigonometry in Python

2.3.3 From components back to angles

2.3.4 Exercises

2.4 Transforming collections of vectors

2.4.1 Combining vector transformations

2.4.2 Exercises

2.5 Drawing with Matplotlib

2.6 Summary

3 Ascending to the 3D World

3.1 Picturing vectors in three-dimensional space

3.1.1 Representing 3D vectors with coordinates

3.1.2 3D Drawing in Python

3.1.3 Exercises

3.2 Vector arithmetic in 3D

3.2.1 Adding 3D vectors

3.2.2 Scalar Multiplication in 3D

3.2.3 Subtracting 3D vectors

3.2.4 Computing lengths and distances

3.2.5 Computing angles and directions

3.2.6 Exercises

3.3 The dot product: measuring alignment of vectors

3.3.1 Picturing the dot product

3.3.2 Computing the dot product

3.3.3 Dot products by example

3.3.4 Measuring angles with the dot product

3.3.5 Exercises

3.4 The cross product: measuring oriented area

3.4.1 Orienting ourselves in 3D

3.4.2 Finding the direction of the cross product

3.4.3 Finding the length of the cross product

3.4.4 Computing the cross product of 3D vectors

3.4.5 Exercises

3.5 Rendering a 3D object in 2D

3.5.1 Defining a 3D object with vectors

3.5.2 Projecting to 2D

3.5.3 Orienting faces and shading

3.5.4 Exercises

3.6 Summary

4 Transforming Vectors and Graphics

4.1 Transforming 3D objects

4.1.1 Drawing a transformed object

4.1.2 Composing vector transformations

4.1.3 Rotating an object about an axis

4.1.4 Inventing your own geometric transformations

4.1.5 Exercises

4.2 Linear transformations

4.2.1 Preserving vector arithmetic

4.2.2 Picturing linear transformations

4.2.3 Why linear transformations?

4.2.4 Computing linear transformations

4.2.5 Exercises

4.3 Summary

5 Computing Transformations with Matrices

5.1 Representing linear transformations with matrices

5.1.1 Writing vectors and linear transformations as matrices

5.1.2 Multiplying a matrix with a vector

5.1.3 Composing linear transformations by matrix multiplication

5.1.4 Implementing matrix multiplication

5.1.5 3D Animation with matrix transformations

5.1.6 Exercises

5.2 Interpreting matrices of different shapes

5.2.1 Column vectors as matrices

5.2.2 What pairs of matrices can be multiplied?

5.2.3 Viewing square and non-square matrices as vector functions

5.2.4 Projection as a linear map from 3D to 2D

5.2.5 Composing linear maps

5.2.6 Exercises

5.3 Translating vectors with matrices

5.3.1 Making plane translations linear

5.3.2 Finding a 3D matrix for a 2D translation

5.3.3 Combining translation with other linear transformations

5.3.4 Translating 3D objects in a 4D world

5.3.5 Exercises

5.4 Summary

6 Generalizing to Higher Dimensions

6.1 Generalizing our definition of vectors

6.1.1 Creating a class for 2D coordinate vectors

6.1.2 Improving the Vec2 class

6.1.3 Repeating the process with 3D vectors

6.1.4 Building a Vector base class

6.1.5 Defining vector spaces

6.1.6 Unit testing vector space classes

6.1.7 Exercises

6.2 Exploring different vector spaces

6.2.1 Enumerating all coordinate vector spaces

6.2.2 Identifying vector spaces in the wild

6.2.3 Treating functions as vectors

6.2.4 Treating matrices as vectors

6.2.5 Manipulating images with vector operations

6.2.6 Exercises

6.3 Looking for smaller vector spaces

6.3.1 Identifying subspaces

6.3.2 Starting with a single vector

6.3.3 Spanning a bigger space

6.3.4 Defining the word “dimension”

6.3.5 Finding subspaces of the vector space of functions

6.3.6 Subspaces of images

6.3.7 Exercises

6.4 Summary

7 Solving Systems of Linear Equations

7.1 Designing an arcade game

7.1.1 Modeling the game

7.1.2 Rendering the game

7.1.3 Shooting the laser

7.1.4 Exercises

7.2 Finding intersection points of lines

7.2.1 Choosing the right formula for a line

7.2.2 Finding the standard form equation for a line

7.2.3 Linear equations in matrix notation

7.2.4 Solving linear equations with numpy

7.2.5 Deciding whether the laser hits an asteroid

7.2.6 Identifying unsolvable systems

7.2.7 Exercises

7.3 Generalizing linear equations to higher dimensions

7.3.1 Representing planes in 3D

7.3.2 Solving linear equations in 3D

7.3.3 Studying hyperplanes algebraically

7.3.4 Counting dimensions, equations, and solutions

7.3.5 Exercises

7.4 Changing basis by solving linear equations

7.4.1 Solving a 3D example

7.4.2 Exercises

7.5 Summary

Part 2: Calculus and Physical Simulation

8 Understanding Rates of Change

8.1 Calculating average flow rates from volumes

8.1.1 Implementing an average_flow_rate function

8.1.2 Picturing the average flow rate with a secant line

8.1.3 Negative rates of change

8.1.4 Exercises

8.2 Plotting the average flow rate over time

8.2.1 Finding the average flow rate in different time intervals

8.2.2 Plotting the interval flow rates alongside the flow rate function

8.2.3 Exercises

8.3 Approximating instantaneous flow rates

8.3.1 Finding the slope of very small secant lines

8.3.2 Building the instantaneous flow rate function

8.3.3 Currying and plotting the instantaneous flow rate function

8.3.4 Exercises

8.4 Approximating the change in volume

8.4.1 Finding the change in volume on a short time interval

8.4.2 Breaking up time into small intervals

8.4.3 Picturing the volume change on the flow rate graph

8.4.4 Exercises

8.5 Plotting the volume over time

8.5.1 Finding the volume over time

8.5.2 Picturing Riemann sums for the volume function

8.5.3 Improving the approximation

8.5.4 Definite and indefinite integrals

8.6 Summary

9 Simulating Moving Objects

9.1 Simulating constant-speed motion

9.1.1 Intuiting speed

9.1.2 Thinking of velocity as a vector

9.1.3 Animating the asteroids

9.1.4 Exercises

9.2 Simulating acceleration

9.2.1 Picturing acceleration in various directions

9.2.2 Quantifying Acceleration

9.2.3 Accelerating the spaceship

9.2.4 Exercises

9.3 Digging deeper into Euler’s method

9.3.1 Stepping through Euler’s method

9.3.2 Implementing the algorithm in Python

9.3.3 Picturing the approximation

9.3.4 Applying Euler’s method to other problems

9.3.5 Exercises

9.4 Calculating exact trajectories

9.4.1 Writing position, velocity, and acceleration as functions of time

9.4.2 Using the terminology of integration

9.4.3 Calculating integrals

9.4.4 Exercises

9.5 Summary

10 Working with Symbolic Expressions

10.1 Modeling algebraic expressions

10.1.1 Breaking an expression into pieces

10.1.2 Building an expression tree

10.1.3 Translating the expression tree to Python

10.1.4 Exercises

10.2 Putting a symbolic expression to work

10.2.1 Finding all the variables in an expression

10.2.2 Evaluating an expression

10.2.3 Expanding an expression

10.2.4 Exercises

10.3 Finding the derivative of a function

10.3.1 Derivatives of powers

10.3.2 Derivatives of transformed functions

10.3.3 Derivatives of some special functions

10.3.4 Derivatives of products and compositions

10.3.5 Exercises

10.4 Taking derivatives automatically

10.4.1 Implementing a derivative method for expressions

10.4.2 Implementing the product rule and chain rule

10.4.3 Implementing the power rule

10.4.4 Exercises

10.5 Integrating functions symbolically

10.5.1 Integrals as antiderivatives

10.5.2 Introducing the SymPy library

10.5.3 Exercises

10.6 Summary

11 Simulating Force Fields

12 Optimizing a physical system

13 Approximating functions with Fourier series

Part 3: Machine Learning Applications

14 Quantifying uncertainty

15 Fitting functions to data

16 Classifying data

17 Training neural networks


Appendix A: A Loading and Rendering 3D Models with OpenGL and PyGame

A.1 Recreating the octahedron from Chapter 3

A.2 Changing our perspective

A.3 Loading and rendering the Utah teapot

A.4 Exercises

Appendix B: Getting set up with Python

B.1 Checking for an existing Python installation

B.2 Downloading and installing Anaconda

B.3 Using Python in interactive mode

B.4 Creating and running a Python script file

B.5 Using Jupyter notebooks

About the Technology

Most businesses realize they need to apply data science and effective machine learning to gain and maintain a competitive edge. To build these applications, they need developers comfortable writing code and using tools steeped in statistics, linear algebra, and calculus. Math also plays an integral role in other modern applications like game development, computer graphics and animation, image and signal processing, pricing engines, and stock market analysis. Whether you’re a self-taught programmer without a core university math foundation or you just need to rekindle the glowing math embers, this book is a great way to fire up your skills.

About the book

Math for Programmers teaches you to solve mathematical problems in code. Thanks to the author’s fun and engaging style, you’ll enjoy thinking about math like a programmer. With accessible examples, scenarios, and exercises perfect for the working developer, you’ll start by exploring functions and geometry in 2D and 3D. With those basic building blocks behind you, you’ll move into the bread and butter math for machine learning and game programming, including matrices and linear transformations, derivatives and integrals, differential equations, probability, classification algorithms, and more. Don’t worry if it sounds intimidating or, worse yet, boring! Coder and mathematician Paul Orland makes learning these vital concepts painless, relevant, and fun!

Real-world examples in this practical tutorial include building and rendering 3D models, animations with matrix transformations, manipulating images and sound waves, and building a physics engine for a video game. Along the way, you’ll test yourself with lots of exercises to ensure you’ve got a firm grasp of the concepts. Hands-on mini-projects throughout lock in all you’ve learned. When you’re done, you’ll have a solid foundation of the math skills essential in today’s most popular tech trends.

What's inside

  • 2D and 3D vector math
  • Matrices and linear transformations
  • Core concepts from linear algebra
  • Calculus with one or more variables
  • Algorithms for regression, classification, and clustering
  • Interesting real-world examples
  • More than 200 exercises and mini-projects

About the reader

Written for programmers with solid algebra skills (even if they need some dusting off). No formal coursework in linear algebra or calculus is required.

About the author

Paul Orland is CEO of Tachyus, a Silicon Valley startup building predictive analytics software to optimize energy production in the oil and gas industry. As founding CTO, he led the engineering team to productize hybrid machine learning and physics models, distributed optimization algorithms, and custom web-based data visualizations. He has a B.S. in mathematics from Yale University and a M.S. in physics from the University of Washington.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook
Prices displayed in rupees will be charged in USD when you check out.

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks