## 15. Mathematics

It's your favorite subject: Mathematics! Hello, I'm Doctor Math, and I'll be making math FUN and EASY!

[vomiting sounds]

Ok, I know math isn't the grandest thing for some of you out there, but these are merely functions that quickly and easily do math you either know, want, or just don't care about. That pretty much covers it.

For you trig fans out there, we've got all manner of things, including sine, cosine, tangent, and, conversely, arc sine, arc cosine, and arc tangent. That's very exciting.

And for normal people, there is a slurry of your run-of-the-mill functions that will serve your general purpose mathematical needs, including absolute value, hypotenuse length, square root, cube root, and power.

In short, you're a fricking MATHEMATICAL GOD!

Oh wait, before then, I should tell you that the trig functions have three variants with different suffixes. The "f" suffix (e.g. sinf()) returns a float, while the "l" suffix (e.g. sinl()) returns a massive and nicely accurate long double. Normal sin() just returns a double. These are extensions to ANSI C, but they should be supported by modern compilers.

Also, there are several values that are defined in the math.h header file.

M_E

e

M_LOG2E

log_2 e

M_LOG10E

log_10 e

M_LN2

log_e 2

M_LN10

log_e 10

M_PI

pi

M_PI_2

pi/2

M_PI_4

pi/4

M_1_PI

1/pi

M_2_PI

2/pi

M_2_SQRTPI

2/sqrt(pi)

M_SQRT2

sqrt(2)

M_SQRT1_2

1/sqrt(2)