% Plotting Inverse Trigonometric Functions
% MATH266A Exercise 6
\documentclass[12pt]{article}
\usepackage{times}
%%%\pagestyle{empty}
\pagestyle{myheadings}%%%
\markright{MATH266A \hfill Plotting Inverse Trigonometric Functions\hfill}
\thispagestyle{empty}
\addtolength{\textwidth}{1.2in}
\addtolength{\textheight}{1.2in}
\addtolength{\oddsidemargin}{-.58in}
\addtolength{\evensidemargin}{-.58in}
\renewcommand{\baselinestretch}{1.0}
\parindent = 0cm
\parskip = .1cm
\begin{document}
\begin{center}
{\Large Plotting Inverse Trigonometric Functions
\footnote{Copyright \copyright 2002 Winfried Just, Department of Mathematics,
Ohio University. All rights reserved.}}
\end{center}
\bigskip
In this exercise, you will learn a new command for plotting
two-dimensional graphs, and you will use it to plot the graphs of the
inverse trig functions.
If this \textsc{MatLab} exercise is being counted in your grade,
then be sure to print the figures for submission.
\medskip
Open \textsc{MatLab}. We want to plot the graph of the function $y = \sin x$ for $x$-values ranging from $-{\pi \over 2}$ to $\pi \over 2$. You know already how to do this using \verb$ezplot$. But now let us look at the problem a little differently. The graph you want to plot consists of all points of the form $(x, \sin x)$, where $x$ ranges from $-{\pi \over 2}$ to $\pi \over 2$. You can think of plotting the graph as a process in time: at time $t$, you would plot a point with coordinates $(t, \sin t)$. When you do this for sufficiently many time points $t$ from the interval $[-{\pi \over 2}, {\pi \over 2}]$, your picture will resemble the graph of the function you want. This is exactly how \textsc{MatLab's} \verb$plot$ command works.
Enter the following command. Don't forget the semicolon at the end, or you will get zillions of numbers on your screen!
\smallskip
\verb$>> t = -pi/2:0.005:pi/2;$
\smallskip
The number in front of the first colon is the lowest value of $t$, the number between colons tells \textsc{MatLab} to increment $t$ by $0.005$ at a time, and the number after the second colon is the highest value of $t$. Now enter:
\smallskip
\verb$>> plot(t, sin(t))$
\smallskip
This command tells \textsc{MatLab} to plot points with coordinates $(t, \sin t)$ for each of the values of $t$ that you have just specified. Look at the graph. It does resemble the graph of the sine function between $-{\pi \over 2}$ and $\pi \over 2$, but it is difficult to see what is going on near the boundaries of the interval. To find out, let us change the axes:
\smallskip
\verb$>> axis([-2 2 -1.2 1.2])$
\smallskip
Now the picture looks more or less like you would expect, doesn't it?
\medskip
How can we use the \verb$plot$ command to produce a graph of the function $\arcsin(x)$? We can think of the graph of the function $\arcsin(x)$ as consisting of all pairs $(\sin(x), x)$, where $x$ ranges from $-{\pi \over 2}$ to $\pi \over 2$. The only difference between it and the graph of the sine function is that the roles of the axes are reversed. This can be easily done with the \verb$plot$ command:
\smallskip
\verb$>> plot(sin(t), t)$
\verb$>> axis([-1.2 1.2 -2 2])$
\smallskip
We got a graph that looks more or less like the graph we had drawn in class.
Put the title "Graph of the function arcsin(x)" on your picture, and print it
%%%for possible submission.
if submission is required.
\medskip
Now let us plot the graph of the function $\arccos x$. The part of the cosine function that will be inverted is the part where $x$ ranges from $0$ to $\pi$. So let your $t$-values be taken from this interval. Enter:
\smallskip
\verb$>> t = 0:0.002:pi;$
\verb$>> plot(cos(t), t)$
\verb$>> axis([-1.2 1.2 -0.1 3.5])$
\smallskip
Add the title "Graph of the function arccos(x)" to your picture, and print it
%%%%for possible submission.
if submission is required.
\medskip
Now let us work on the graph of $\arctan x$. The $x$-values for the part of the function that is being inverted range from $-{\pi \over 2}$ to $\pi \over 2$. So you may try the following:
\smallskip
\verb$>> t = -pi/2:0.005:pi/2;$
\verb$>> plot(tan(t), t)$
\smallskip
Look at your picture. What happened here? The problem is that we chose our $t$-values in such a way that for most of the $\tan t$ is either very large or very small (a negative number with a large absolute value). The part of the $\arctan x$ function where it increases from values close to $-{\pi \over 2}$ to values close to $\pi \over 2$ looks almost vertical. We can concentrate on the interesting part of the function by choosing appropriate units for our axes:
\smallskip
\verb$>> axis([-5 5 -2 2])$
\smallskip
Now the picture looks more reasonable; doesn't it? Put a suitable title on your picture and print it
%%%for possible submission.
if submission is required.
\medskip
Now produce a nice graph of the inverse function of $\cot x$ and print it
%%%for possible submission.
if submission is required.
Remember that the $x$-values of the part of $\cot x$ that get inverted range from $0$ to $\pi$.
\emph{Hint:} \textsc{MatLab} may give you an error message, complaining that it cannot divide by zero. If this happens to you, remind yourself for which values of $t$ such division would occur and change the range of your $t$-values to avoid division by $0$.
\medskip
Now let us graph the inverse functions of the secant and cosecant functions. The part of the secant function that is being inverted is defined for $x$-values in the intervals $[0, {\pi\over 2})$ and $[\pi, {3\pi \over 2})$. Thus we can produce the first part of the graph of the inverse function of the secant function as follows:
\smallskip
\verb$>> t = 0:0.005:pi/2;$
\verb$>> plot(sec(t), t)$
\smallskip
We want to plot the second part of the graph on the same picture, so enter:
\smallskip
\verb$>> hold on$
\smallskip
Now we plot:
\smallskip
\verb$>> t = pi:0.005:3*pi/2;$
\verb$>> plot(sec(t), t)$
\smallskip
Look at the graph. Why does it look so ugly? You should be able to come up with an answer to the last question by now. Improve the look of your graph by putting appropriate units on your axes; add a suitable title to your picture, and print it
%%% for possible submission.
if submission is required.
\medskip
Now enter:
\smallskip
\verb$>> hold off$
\smallskip
to get ready for producing the last picture of this exercise, the graph of the cosecant function. Remember that the part of the function $\csc x$ that is inverted is restricted to $x$-values from the intervals $(0, {\pi\over 2}]$ and $(\pi, {3\pi \over 2}]$. Plot a nice graph; add a suitable title to it, and print it
%%%%for possible submission.
if submission is required.
\emph{Hint:} Note that the left endpoints $0$ and $\pi$ are not part of the intervals where the invertible part of $\csc x$ is defined. (Why not?) To avoid problems with your plotting, set the lower bounds for $t$ to $0.005$ and $\pi + 0.005$ respectively.
\medskip
Finally, let us see how \textsc{MatLab} handles inverse trig functions. The function names are \verb$asin(x)$, \verb$acos(x)$, \verb$atan(x)$, \verb$acot(x)$, \verb$asec(x)$, \verb$acsc(x)$. You could use the \verb$ezplot$ command to plot \textsc{MatLab's} version of the inverse trig functions. In some cases, you will get graphs of different functions from the ones you produced with \verb$plot$. The reason is that not all mathematicians use the same parts of the trig functions for defining inverse trig functions.
The choices we made in
%our handout
class may
lead to very nice formulas for derivatives, but \textsc{MatLab's} authors made different choices in some cases. Let us see which of our definitions agree with \textsc{MatLab's}:
\smallskip
\verb$>> hold off$
\verb$>> ezplot('asin(x)')$
\smallskip
Look at the picture. Does it depict the same function as your printout of the function $\arcsin x$? If yes, write this down on your printout. If not, write "Different from \textsc{MatLab's} version of this function" on your printout. Now repeat the procedure for the other five inverse trig functions.
\end{document}