# CSCD-255

2015-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 = 4^{6} — 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 d`ouble 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 deg_to_rad(double degrees)
{
double radians = degrees * (atan(1.0) / 45); // Radians per degree
return radians;
}

__You will NOT be responsible for the material in Chapter 20.__

## Preview of the Second Half of CSCD-255

We will be spending the rest of the quarter on the following topics:

- Arrays, beyond character arrays and examining several operations dealing
with arrays. Initially these will be "static" arrays, explicitly
dimensioned in the code.
- Pointers and pointer arithmetic. To this point we have already used
pointers unknowingly — the name of a character array is actually a
pointer, and the operation of subscripting in the array is actually short-hand
for pointer arithmetic.
- Dynamic allocation of computer memory by means of pointers. Rather
than declaring a "static" array of sufficient size to cover the largest case,
we can use a pointer to allocate the array space while the program is running,
getting just the amount of memory we need.
- Accessing data files in C programs.
- We
*may* cover the `struct` or structure. This is a
mechanism by which we can have one name for a collection of values of various
data types.