R Lesson 33: Inverse Trigonometric Ratios in R

Hello everybody,

Michael here, and in today’s post, we’ll be expanding our knowledge of R trigonometry by learning inverse trigonometric ratios in R!

In the previous post, we learned some basics of R trigonomtery (and trigonometry in general). However, let’s explore some more advanced R trigonometrical concepts!

Inverse Trigonometric Functions

In the previous post R Lesson 32: Basic Trigonometry, R Style, we learned about the three basic trigonometric concepts-sine, cosine and tangent. Today, we’ll explore inverse trigonometric functions such as the arc-sine, arc-cosine and arc-tangent.

What do these trigonometric concepts represent? Well, let’s go back to our triangle illustration from the previous post:

This illustration gives a visual representation of the three most basic trigonometric concepts-sine, cosine, and tangent with the classic SOHCAHTOA mnemonic.

Now, I did mention that the sine of an angle in a right triangle is the ratio of the opposite side’s length to the hypotenuse’s length. With that said, arcsine is simply the inverse of sine-meaning arcsine is the ratio of the hypotenuse’s length to the opposite side’s length.

The same logic applies for arccosine and arctangent, as these ratios are simply the inverse of the cosine and tangent ratios, respectively. Arccosine would be the ratio of the hypotenuse’s length to the adjacent side’s length while arctangent would be the ratio of the adjacent side’s length to the opposite side’s length.

How would these inverse trigonometric ratios affect our calculations in this triangle? Let’s find out using the 38 degree angle as an example:

RATIONUMERIC FORM
sine7/12.2~0.57
arcsine12.2/7~1.74
cosine10/12.2~0.82
arccosine12.2/10=1.22
tangent7/10=0.7
arctangent10/7~1.43

As you can see here, the three regular trigonometric ratios yielded values less than 1 while the three inverse trigonometric ratios yiedled values greater than 1. Interesting, isn’t it?

And now, let’s explore how to work with more advanced trigonometry in R!

Advanced Trigonometry, R style

Now that we’ve seen how to use the basic trigonometric ratios in R, let’s see how we can utilize these more advanced trigonometric ratios!

> asin(31)
[1] NaN
Warning message:
In asin(31) : NaNs produced
> acos(54)
[1] NaN
Warning message:
In acos(54) : NaNs produced
> atan(14)
[1] 1.499489

As I did when first testing out the sine, cosine, and tangent functions in R, I tested the three inverse trigonometric functions (arcsine, arccosine and arctangent) in R using whole numbers as parameters. However, you can see that for the arcsine and arccosine functions (asin() and acos() respectively), that didn’t quite work out. Interestingly, using a whole number for the atan() function worked just fine.

How can that be? Well, just like the regular trigonometric functions in R, these inverse trigonometric functions calculate the ratios using radians (more on those here: R Lesson 32: Basic Trigonometry, R Style). However, the asin() and acos() functions only take input values ranging from -1 to 1 because they only work with a limited range of angles. Arcsine only works with angles ranging from -π/2 to π/2 radians (-90 to 90 degrees) while arccosine only works with angles ranging from 0 to π radians (or 0 to 180 degrees). Arctangent, on the other hand, can take a wider range of numerical inputs since it works with angles of any length (in fact, the angle lengths arctangent works with encompass negative infinity to positive infinity).

Let’s try executing our inverse trigonometric functions in R with the new inverse trigonometric ratio information that we learned!

> asin(0.5)
[1] 0.5235988
> acos(0.43)
[1] 1.126304
> atan(22)
[1] 1.525373

As you can see, with the rules we discussed above, we’re now able to obtain valid outputs for the asin(), acos() and atan() functions!

Thanks for reading,

Michael

Michael’s Lost Posts

Hello readers,

Michael here, and boy do I have some exciting news for you!

So, as you all may know, I’ve been writing this blog for nearly 6 years now, having covered 8 different programming tools over the course of 161 posts (that’s a lot when you think about it)

However, today I have a new exiciting announcement! Look, I know you were all expecting another post on R trigonometry or Python game-design, but I thought today would be the perfect time to announce the release of Michael’s Lost Posts.

What is Michael’s Lost Posts you ask? It’s a collection of never-before-seen-or-finished posts, straight from the Drafts folder of this great blog.

What kinds of posts might you see in Michael’s Lost Posts? Let’s preview this great collection, shall we?

First off, have you ever wanted to learn more about the wonders of the Raspberry Pi mini-computer? Now you can with Michael’s Lost Posts:

I mean, look at this well-written post-it’s certainly been kept in pristine condition in the Drafts folder since March 2022. After all, if you know me, you know I only release quality content to you all.

Learn about how to build your own Raspberry PI, up until the point where you hook up all the cords and cables. After that, well…good luck:

But wait, there’s more! Ever wonder if you could build a neural-network machine learning translator that’s BETTER than Google Translate? This Lost Post on Seq2Seq neural-network machine learning models will teach you to do just that…

…up until the point of actually implementing the model:

A post so nice, I didn’t even have a dataset for it.

If you really want to see some gems from Michael’s Lost Posts, check out this lesson on Image Arithmetic (with Python):

Now this post takes the cake. One of the finer posts in Michael’s Lost Posts, and unlike many of the other posts in this collection, it’s so amazing that I didn’t even finish writing the introductory paragraph. In fact, I even ended the introductory paragraph mid-sentence.

Now that you’ve seen a preview of Michael’s Lost Posts, you can find them along with other Lost Posts at the following link:

APRIL FOOL’S!