The sin() function computes the sine of an angle. In C, the angle must be in radians. The result is always between −1 and 1—the building block for waves, oscillations, and circular motion.
01
Sine
Trig function.
02
math.h
Link with -lm.
03
Radians in
Not degrees.
04
Range
[−1, 1].
05
Unit circle
y-coordinate.
06
vs sinh
Different fn.
Fundamentals
Definition and Usage
Sine relates an angle to a ratio on a right triangle: opposite ÷ hypotenuse. On the unit circle (radius 1), sin(θ) is the y-coordinate at angle θ.
In C, sin(x) expects x in radians. One full turn is 2π radians (360°). A quarter turn is π/2 radians (90°).
💡
Beginner Tip
60° is M_PI / 3.0 radians, and sin(M_PI / 3.0) is about 0.866. Do not pass 60 directly—that is 60 radians, not 60 degrees. C has no built-in deg2rad; use degrees * M_PI / 180.0.
At 0°, sine is 0 and cosine is 1. At 90°, they swap. Remember: sin = y, cos = x on the unit circle.
Applications
🚀 Common Use Cases
Graphics and games — bobbing motion, pendulums, circular paths (y = r * sin(θ)).
Audio synthesis — pure tones are sine waves at a given frequency.
Physics — simple harmonic motion, springs, and pendulums.
Signal processing — model periodic AC voltage and vibrations.
Pair with cos() — full 2D position from angle and radius.
🧠 How sin() Works
1
Receive radians
Angle x in radians (convert from degrees if needed).
Input
2
Evaluate sine
Library computes sin using optimized polynomial or hardware instructions.
Compute
3
Return in [−1, 1]
Result is a double representing the y-component on a unit circle.
Output
=
🔢
Sine value
Multiply by radius for real-world distances: y = r * sin(θ).
Important
📝 Notes
Input is radians, not degrees—convert with degrees * M_PI / 180.0.
Output is always in [−1, 1].
sin() is an odd function: sin(-x) == -sin(x).
Link with -lm when using GCC/Clang on Unix-like systems.
Do not confuse sin() with sinh() (hyperbolic sine).
For very large angles, floating-point precision can affect results—consider reducing the angle modulo 2π if needed.
Performance
⚡ Optimization
sin() is implemented in the platform math library and is typically fast enough for most applications. If you call it thousands of times per frame in a game loop, profile first—often the bottleneck is elsewhere. For fixed small angle sets, a lookup table can help, but prefer the library function until profiling proves otherwise.
Wrap Up
Conclusion
sin() computes the sine of an angle in radians and returns a value between −1 and 1. Convert degrees before calling, pair it with cos() for circular motion, and remember it is not the same as sinh().
Continue with sinh() for hyperbolic math, or explore cos() for the horizontal component on the unit circle.
sin() returns the sine of an angle given in radians. On a unit circle, sin(theta) is the y-coordinate at angle theta. For example, sin(0) is 0.0 and sin(pi/2) is 1.0 (90 degrees).
Include <math.h> and link with -lm on many systems: gcc program.c -o program -lm. The function is declared as double sin(double x).
Radians. Convert degrees first: radians = degrees * (M_PI / 180.0). Passing 60 directly to sin() is 60 radians, not 60 degrees.
The result is always between -1 and 1 inclusive. sin(0) is 0, sin(pi/2) is 1, and sin(3*pi/2) is -1.
sin() is a trigonometric sine (angles in radians, result in [-1, 1]). sinh() is the hyperbolic sine (uses exponential math, unbounded). They are different functions despite similar names.
Both take radians. sin(theta) gives the vertical (y) component on a unit circle; cos(theta) gives the horizontal (x) component. sin(pi/2) is 1 while cos(pi/2) is 0.
Did you know?
sin() is an odd function: sin(-x) equals -sin(x). That is why a sine wave is symmetric when flipped vertically—unlike cos(), which is even and unchanged for negative angles.