top of page
  • Writer's pictureRevanth Reddy Tondapu

Part 6: Understanding Sine, Cosine, and Tangent: Real-Life Applications in Math and Data Science


Math and Statistics for AI
Math and Statistics for AI

Mathematics often seems abstract, but it becomes much more relatable when we connect it to real-life scenarios. In this post, we'll explore the concepts of sine, cosine, and tangent using everyday examples. These trigonometric functions are not just academic exercises; they have practical applications, especially in fields like data science. Let's dive in!


Measuring the Height of a Tree

Imagine a forest officer who wants to measure the height of a very tall tree. Climbing the tree is not an option because it's too much work. Instead, the officer can use the principles of trigonometry—specifically, sine, cosine, and tangent—to find the height easily.


Step-by-Step Approach

  1. Measure the Distance: First, the officer measures the distance from where he is standing to the base of the tree. Let's say this distance is 50 feet.

  2. Measure the Angle: Using a simple instrument, the officer measures the angle between the ground and the top of the tree. Let's assume this angle is 30 degrees.


Representing as a Right-Angle Triangle

To solve the problem, we represent the scenario as a right-angle triangle:

  • The base of the triangle is the distance from the officer to the tree (50 feet).

  • The height of the tree is the vertical side of the triangle, which we need to find.

  • The angle between the base and the hypotenuse (the line of sight to the top of the tree) is 30 degrees.


Understanding Tangent (Tan)

In a right-angle triangle, the tangent of an angle (θ) is the ratio of the length of the opposite side to the length of the adjacent side. Mathematically, it’s expressed as:

[ \text{tan}(\theta) = \frac{\text{Opposite Side}}{\text{Adjacent Side}} ]

For our example:

  • θ = 30 degrees

  • Opposite side = height of the tree (let's call it ( h ))

  • Adjacent side = 50 feet

So, the equation becomes:

[ \text{tan}(30^\circ) = \frac{h}{50} ]

We know from trigonometric tables that:

[ \text{tan}(30^\circ) = 0.577 ]

Therefore:

[ 0.577 = \frac{h}{50} ]

Solving for ( h ):

[ h = 0.577 \times 50 = 28.85 \text{ feet} ]

Thus, the height of the tree is approximately 28.85 feet.


Real-Life Applications of Sine and Cosine

Pythagoras' Theorem

Before we dive into sine and cosine, let's recall Pythagoras' theorem, which states:

[ \text{Hypotenuse}^2 = \text{Opposite Side}^2 + \text{Adjacent Side}^2 ]

For a right-angle triangle with sides 3 and 4, the hypotenuse will be:

[ \text{Hypotenuse} = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = 5 ]

Sine and Cosine

Let's take another example to understand sine and cosine. Imagine you have a heavy package you want to drag into your room. By attaching a rope and pulling it at an angle, part of the force goes horizontally (x-direction) and part goes vertically (y-direction).

If you apply a 10 Newton force at a 30-degree angle, we can find the force components using sine and cosine.

Sine (Sin)

The sine of an angle (θ) is the ratio of the length of the opposite side to the hypotenuse:

[ \text{sin}(\theta) = \frac{\text{Opposite Side}}{\text{Hypotenuse}} ]

For our example:

[ \text{sin}(30^\circ) = \frac{y}{10} ]

We know:

[ \text{sin}(30^\circ) = 0.5 ]

Therefore:

[ 0.5 = \frac{y}{10} ]

Solving for ( y ):

[ y = 0.5 \times 10 = 5 \text{ Newtons} ]

Cosine (Cos)

The cosine of an angle (θ) is the ratio of the length of the adjacent side to the hypotenuse:

[ \text{cos}(\theta) = \frac{\text{Adjacent Side}}{\text{Hypotenuse}} ]

For our example:

[ \text{cos}(30^\circ) = \frac{x}{10} ]

We know:

[ \text{cos}(30^\circ) = 0.866 ]

Therefore:

[ 0.866 = \frac{x}{10} ]

Solving for ( x ):

[ x = 0.866 \times 10 = 8.66 \text{ Newtons} ]

So, the components of the force are 5 Newtons vertically and 8.66 Newtons horizontally.


Trigonometry in Data Science: Cosine Similarity

Now, let's connect these trigonometric concepts to data science. One important application is cosine similarity, used in natural language processing (NLP) to measure the similarity between two vectors.


Cosine Similarity

Cosine similarity measures the cosine of the angle between two vectors in a multi-dimensional space. It’s particularly useful for comparing text data, as it helps determine how similar two documents are, regardless of their size.

The formula for cosine similarity is:

[ \text{cosine_similarity} = \frac{A \cdot B}{|A| |B|} ]

Where:

  • ( A \cdot B ) is the dot product of vectors A and B.

  • ( |A| ) and ( |B| ) are the magnitudes of vectors A and B.


Example in Python

Here's a simple example of calculating cosine similarity in Python:

import numpy as np

# Define two vectors
A = np.array([1, 2, 3])
B = np.array([4, 5, 6])

# Calculate the dot product
dot_product = np.dot(A, B)

# Calculate the magnitudes
magnitude_A = np.linalg.norm(A)
magnitude_B = np.linalg.norm(B)

# Calculate cosine similarity
cosine_similarity = dot_product / (magnitude_A * magnitude_B)

print("Cosine Similarity:", cosine_similarity)

In this example, we use the numpy library to calculate the dot product and magnitudes of two vectors, and then find their cosine similarity.


Conclusion

Sine, cosine, and tangent are not just concepts you study in school; they have real-life applications. Whether it's measuring the height of a tree, determining the force needed to move an object, or comparing text data in data science, understanding these trigonometric functions can be incredibly useful.

By grasping these basic principles, you'll be better equipped to tackle more complex problems in various fields, including mathematics, engineering, physics, and data science.

If you found this explanation helpful, share it with your friends and leave a comment below if you have any questions. Happy learning!

0 views0 comments

Comments


bottom of page