Game Development Reference
In-Depth Information
Notice that the power rule works for negative exponents as well:
d
dt (3t 5 − 4t) = 15t 4 − 4,
t 100
100 +
d
dt
= t 99 ,
π
t
d
dt
1
t +
4
t 3
= d
dt
−1
t 2
12
−1 + 4t
−3
−2 − 12t
−4 =
= −t
t 4 .
11.4.6
Derivatives of Some Special Functions
with Taylor Series
This section looks at some very special examples of differentiating polyno-
mials. Given any arbitrary function f(x), the Taylor series of f is a way to
express f as a polynomial. Each successive term in the polynomial is deter-
mined by taking a higher order derivative of the function, which is perhaps
the main point of Taylor series that you should learn when you take a real
calculus class, but right now we're not interested in where Taylor series
come from, just that they exist. The Taylor series is a very useful tool
in video games because it provides polynomial approximations, which are
“easy” to evaluate in a computer, for functions that are otherwise “hard”
to evaluate. We don't have the space to discuss much of anything about
Taylor series in general, but we would like to look at a few important exam-
ples of Taylor series. The Taylor series for the sine and cosine functions are
sinx = x − x 3
3! + x 5
x 7
7! + x 9
Taylor series for sin(x)
and cos(x)
9! + ,
5!
cosx = 1 − x 2
2! + x 4
x 6
6! + x 8
8! + .
(11.10)
4!
This pattern continues forever; in other words, to compute the exact value
of sinx would require us to evaluate an infinite number of terms. However,
notice that the denominators of the terms are growing very rapidly, which
means we can approximate sinx simply by stopping after a certain number
of terms, and ignore the rest.
This is exactly the process by which trigonometric functions are com-
puted inside a computer. First, trig identities are used to get the argument
into a restricted range (since the functions are periodic). This is done be-
cause when the Taylor series is truncated, its accuracy is highest near a
particular value of x, and in the case of the trig functions, this point is
 
Search WWH ::




Custom Search