Hello everybody,
Michael here, and in today’s post, I’ll show you to how to plot some inverse trigonometric functions with R!
In the previous post, we explored how to create R plots of the three basic trigonometric functions-sine, cosine and tangent. This time, we’ll explore how to create R plots of the three basic inverse trigonometric functions-arcsine, arccosine and arctangent. Let’s begin!
First off, the arcsine:
To start off our exploration of plotting inverse trigonometric functions, let’s explore how we can plot the arcsine:
> x <- seq(-3*pi, 3*pi, length.out=100)
> y <- asin(x)
Warning message:
In asin(x) : NaNs produced
> plot(x, y, type='l')

As you can see, we can’t quite use the same approach to plotting the arcsine function that we used to plot the sine function since our sequence of 100 values from -3pi to 3pi yielded all nulls when trying to calculate the arcsine of each value. Let’s try a slightly different approach to plotting the arcsine function, shall we?
> x <- seq(-1, 1, length.out=100)
> y <- asin(x)
> plot(x, y, type='l')
The only modification I made from the previous example was to use a sequence from -1 to 1 (still maintaining 100 equally spaced variables).
Why did I stick with the (-1, 1) sequence? Simply put, the arcsine function is only defined within the range (-1, 1). In other words, it’s not possible to calculate the arcsine of any value outside of the range (-1, 1)-trying to do so will give you an NaN or not a number in R.
Next up, the arccosine
And for our next R plot, let’s graph the arccosine function! Here’s the code to use for a sample arccosine function:
> x <- seq(-1, 1, length.out=100)
> y <- acos(x)
> plot(x, y, type='l')
Aside from using the acos() function, we used the same logic to create this plot that we used for the arcsine plot. Both the arcsine and arccosine functions are only defined for the range (-1, 1), meaning that you will get an NaN in R if you try calculating the arcsine or arccosine for any value outside of this range.
Now, you may have noticed that our arccosine plot looks like a vertical reflection of the arcsine plot. How could that be? The range of x-axis values is the same for both plots, but notice the difference in the range of y-axis values between the two plots. The arcsine plot’s y-axis value range is (-1.5, 1.5) while the arccosine plot’s y-axis value range is (0, 3).
Why do the y-axes in both plots have different value ranges? An easy explanation would be that the arccosine plot is the vertical reflection of the arcsine plot shifted pi/2 radians (or 90 degrees) upward, hence why the arccosine’s y-axis value ranges are higher.
Last but not least, the arctangent
Saving the best for last, let’s plot an arctangent function in R! Here’s the code for a sample arctangent plot:
> x <- seq(-30, 30, length.out=100)
> y <- atan(x)
> plot(x, y, type='l')
For creating the arctangent plot, we used similar logic (aside from the atan() function) that we used to create the arcsine and arccosine plots. However, notice that I didn’t use the (-1, 1) sequence range but rather the range of (-30, 30).
You might be thinking, wouldn’t using a sequence outside of the (-1, 1) range give you a bunch of NaNs? In the case of the arctangent function, no. This is because arctangent, unlike arcsine and arccosine, is defined for the range (-infinity, +infinity). In other words, arctangent functions have no finite range, so you could use any sequence of values you want when creating an arctangent plot (I kept it simple with the -30, 30 range).
However, one interesting thing you’ll notice with the arctangent plot is that its y-axis has a range from (-1.5, 1.5). How is that possible? Even though you could a sequence of literally any two numbers, the range of possible arctangent values will range from approximately -1.5 to 1.5.
Another interesting thing about the arctangent function is that the lower part of the function (the part pointing towards -1.5) represents -infinity in the arctangent function while the upper part of the function (the part pointing away from 1.5) represents +infinity.
Thanks for reading,
Michael