## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Chapter 1
A Math and Physics Primer
T
here’s no hiding from it — if you want to learn AI, it helps to know
some mathematics and physics. Sure, you can use many AI techniques
in a “cut and paste” fashion, but that’s not doing yourself any favors; the
moment you have to solve a problem slightly different from the one you’ve
borrowed the code from you’re going to run into difficulties. If you under
-
stand the theory behind the techniques, however, you will stand a much
better chance of figuring out an alternative solution. Besides, it feels good
to understand the tools you’re working with. What better reason do you
need to learn this stuff but that?
I’m going to write this chapter assuming you know hardly anything at
all about math or physics. So forgive me if you already know most of it,
but I figure this way I’ll catch everyone, no matter what your experience is.
Skim through the chapter until you come to something you don’t know or
you find a topic where you think your memory needs to be refreshed. At
that point, start reading. If you are already comfortable with vector math
and the physics of motion, I suggest you skip this chapter entirely and
come back later if you find something you don’t understand.
Mathematics
is like trying to fly without wings.
Cartesian Coordinates
You are probably already familiar with the Cartesian coordinate system. If
you’ve ever written a program that draws images to the screen then you
will almost certainly have used the Cartesian coordinate system to describe
the positions of the points, lines, and bitmaps that make up the image.
In two dimensions, the coordinate system is defined by two axes posi
-
tioned at right angles to each other and marked off in unit lengths. The
horizontal axis is called the x-axis and the vertical axis, the y-axis. The
point where the axes cross is called the origin. See Figure 1.1.
1
The arrowheads at each end of the axes in Figure 1.1 indicate they extend
in each direction infinitely. If you imagine yourself holding an infinitely
large sheet of paper with the x and y axes drawn on it, the paper represents
the xy plane — the plane on which all points in the two-dimensional Carte-
sian coordinate system can be plotted. A point in 2D space is represented
by a coordinate pair (x, y). The x and y values represent the distances along
each of the respective axes. Nowadays, a series of points or lines plotted on
the Cartesian coordinate system is usually referred to as a graph, which
saves a lot of typing for sure. :o)
Ü
NOTE To represent three-dimensional space, another axis is needed — the