Trigonometric Functions – Sine

The sine function is one of the most fundamental concepts in mathematics, connecting geometry, trigonometry, and real-world applications. In its simplest form, sine is defined in a right triangle as the ratio of the length of the side opposite an angle to the hypotenuse. This simple ratio has far-reaching implications.

Opposite to Hpyotenuse is 1:2 with 30 degrees angle.

To understand sine more deeply, we can use the unit circle. The unit circle is a circle with a radius of one, centered at the origin. In this context, sine represents the y-coordinate of a point where the terminal side of an angle intersects the circle. As the angle increases, the sine value oscillates smoothly between negative one and positive one.

A:C is obviously equal to 0.53:1. The code for the animation of the unit circle is below.

Key angles like 30 degrees, 45 degrees, and 60 degrees provide exact values for sine. For 30 degrees, sine equals one-half. For 45 degrees, sine is approximately 0.71, which is the square root of two divided by two. For 60 degrees, sine equals 0.87, which is the square root of three divided by two. These values arise from special triangles, such as the 30-60-90 and 45-45-90 triangles.

By combining geometric and unit circle visualizations, sine becomes more than a mathematical concept. It transforms into a tool for solving problems in physics, engineering, and beyond. Mastering sine is not just about numbers; it is about seeing how mathematics describes the world. The sine function itself looks like this:

This is what happens, if we follow the animation of the unit circle in the YouTube video. The code is below.

This is the code, generating the unit circle:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Generate unit circle points
theta = np.linspace(0, 2 * np.pi, 1000)
x_circle = np.cos(theta)
y_circle = np.sin(theta)

# Initialize figure
fig, ax = plt.subplots(figsize=(8, 8))
ax.plot(x_circle, y_circle, 'b-', label="Unit Circle")  # Unit circle
ax.axhline(0, color="gray", linestyle="dotted")
ax.axvline(0, color="gray", linestyle="dotted")

# Add dynamic triangle components
triangle_line, = ax.plot([], [], 'r-', linewidth=2, label="Triangle Sides")
point, = ax.plot([], [], 'ro')  # Moving point on the circle

# Text for dynamic values
dynamic_text = ax.text(0.03, 0.03, "", fontsize=12, color="black", ha="left", transform=ax.transAxes)

# Set up axis limits and labels
ax.set_xlim(-1.2, 1.2)
ax.set_ylim(-1.2, 1.2)
ax.set_title("Sine as a Triangle on the Unit Circle", fontsize=14)
ax.set_xlabel("cos(θ)", fontsize=12)
ax.set_ylabel("sin(θ)", fontsize=12)
ax.legend(loc="upper left")

# Animation update function
def update(frame):
    angle = theta[frame]
    x_point = np.cos(angle)
    y_point = np.sin(angle)
    degrees = np.degrees(angle) % 360  # Convert radians to degrees
    
    # Update triangle
    triangle_line.set_data([0, x_point, x_point, 0], [0, y_point, 0, 0])
    
    # Update point on the circle
    point.set_data([x_point], [y_point])  # Fixed this line to avoid the warning
    
    # Update text for angle, opposite side length, and sin(θ)
    dynamic_text.set_text(f"Angle: {degrees:.1f}°\nOpposite Side Length: {y_point:.2f}\nsin(θ): {y_point:.2f}")
    return triangle_line, point, dynamic_text

# Create animation
ani = animation.FuncAnimation(fig, update, frames=len(theta), interval=20, blit=True)
plt.show()

And this is the simple code, making the sine function itself:

# Generate x values from -2π to 2π
x = np.linspace(-2 * np.pi, 2 * np.pi, 1000)
y = np.sin(x)

# Plot the sine function
plt.figure(figsize=(10, 5))
plt.plot(x, y, label="sin(x)", linewidth=2)

# Customize x-axis with π labels
xticks = [-2 * np.pi, -3 * np.pi / 2, -np.pi, -np.pi / 2, 0, np.pi / 2, np.pi, 3 * np.pi / 2, 2 * np.pi]
xtick_labels = [r"$-2\pi$", r"$-\frac{3\pi}{2}$", r"$-\pi$", r"$-\frac{\pi}{2}$", r"$0$", 
                r"$\frac{\pi}{2}$", r"$\pi$", r"$\frac{3\pi}{2}$", r"$2\pi$"]
plt.xticks(xticks, xtick_labels)

# Add grid, title, and labels
plt.axhline(0, color="black", linewidth=0.8, linestyle="dotted")
plt.axvline(0, color="black", linewidth=0.8, linestyle="dotted")
plt.title("Sine Function", fontsize=16)
plt.xlabel("x (radians)", fontsize=12)
plt.ylabel("sin(x)", fontsize=12)
plt.grid(alpha=0.3)
plt.legend()
plt.show()
Trigonometric Functions - Sine (with Python)

GitHub code – https://github.com/Vitosh/Python_personal/tree/master/YouTube/025-Trigonometric-Functions-Sine

Enjoy 🙂