# CSCD-2552015-02-06

## Math Libraries (Ch. 20) — and Errors in the Text

Our authors have several errors in Chapter 20.

• On page 183, they misrepresent the pow function.  x = pow(4, 6) is what a mathematician would write as x = 46 — not what they give in their table
• Their treatment of the arc sine, arc cosine, and arc tangent is completely off.  The definition of those mathematical functions is to return the angle that has the corresponding sine, cosine, or tangent.  In other words, acos(cos(angle)) is that angle itself.
• On page 187 they use the wrong modulus for rolling a die:  (rand() % 5) can never return a 5, since by definition 5%5 is zero.  You need (rand()%6) to get the range 0 through 5.

A reminder:  C follows the mathematician's preference and represents angles in radians, not degrees.  This is why back on 16 Jan. we developed the functions double deg_to_rad(double degrees) and double rad_to_deg(double radians).

```double rad_to_deg(double radians)
{
double degrees = radians * (45 / atan(1.0));  // Degrees per radian

return degrees;;
}

{
double radians = degrees * (atan(1.0) / 45);  // Radians per degree