ABSTRACT

When you're working with problems that involve trigonometry, you'll find that about 80 percent of your work will be occupied with computing the fundamental functions sine, cosine, and tangent of various angles. You'll find the infinite series that give these transformations in almost any handbook. From my totally unbiased point of view, one of the more comprehensive treatments for the first two functions was just given in Chapter 5. The third function, the tangent, is relatively easy because it's related to the first two by the simple relation

This function works for all angles except those for which the cosine is zero. At that point, the definition blows up, and the magnitude of the tangent goes to infinity. Note that this problem cannot be solved with tricky coding; the function itself blows up, so there's no way fancy coding will stop it. However, you can keep the "explosion" within bounds, which is what I did in Listing 3.2 (see the section "Is It Safe?").