Learning Scientific Programming with Python (2nd edition)

P3.1.1: Plotting functions with singularities

Question P3.1.1

Plot the functions

$$ \begin{align*} f_1(x) &= \ln \left( \frac{1}{\sin^2x} \right)\\ f_2(x) &= \ln \left( \frac{1}{\cos^2x} \right) \end{align*} $$

on 1000 points across the range $-20 \le x \le 20$. What happens to these functions at $x = n\pi/2$ for $n=0,\pm 1, \pm 2,\cdots$? What happens in your plot of them?