The asin() function computes the arc sine (inverse sine) of a number. Given a sine value between −1 and 1, it returns the angle in radians whose sine equals that value—the mirror image of acos() for opposite-over-hypotenuse ratios.
01
Inverse sin
Angle from ratio.
02
math.h
Link with -lm.
03
Domain
[−1, 1].
04
Range
[−π/2, π/2].
05
Radians
Not degrees.
06
NaN
|x| > 1.
Fundamentals
Definition and Usage
asin (arc sine) answers: “What angle has this sine?” If sin(θ) = x and x is between −1 and 1, then asin(x) = θ (in radians, principal value).
On a right triangle, sine is opposite ÷ hypotenuse. If you know those two side lengths, their ratio is a valid input to asin(), and the result is the angle at the vertex between the hypotenuse and the adjacent side.
💡
Beginner Tip
acos uses adjacent ÷ hypotenuse; asin uses opposite ÷ hypotenuse. Pick the function that matches the sides you know.
If |x| > 1, returns NaN and may set errno to EDOM.
Headers and linking
#include <math.h>
Compile: gcc asin.c -std=c11 -o asin -lm
Cheat Sheet
⚡ Quick Reference
Call
Meaning
Result (approx.)
asin(0)
sin(0°) = 0
0 radians
asin(0.5)
sin(30°) = 0.5
0.5236 (π/6)
asin(1)
sin(90°) = 1
1.5708 (π/2)
asin(-1)
sin(−90°) = −1
-1.5708 (−π/2)
asin(x) * 180 / M_PI
Convert to degrees
Angle in °
Inverse
asin(x)
Angle from sin
Forward
sin(angle)
Sin from angle
To degrees
rad * 180 / M_PI
Convert
Triangle
asin(opp/hyp)
Geometry
Hands-On
Examples Gallery
Compile every example with gcc file.c -std=c11 -o out -lm. The -lm flag links the math library on Linux and macOS.
📚 Getting Started
Compute arc sine and print the result in radians.
Example 1 — Basic Arc Sine
Find the angle whose sine is 0.5 (30° in radians).
C
#include <stdio.h>
#include <math.h>
int main(void) {
double x = 0.5;
double result = asin(x);
printf("The arc sine of %.1f is: %.6f radians\n", x, result);
return 0;
}
📤 Output:
The arc sine of 0.5 is: 0.523599 radians
How It Works
asin(0.5) returns π/6 radians because sin(π/6) = 0.5. This matches the reference example with cleaner formatting.
sin(asin(x)) should equal x when x is in [−1, 1]. Small floating-point differences may appear beyond six decimal places.
Applications
🚀 Common Use Cases
Geometry — find an angle from opposite and hypotenuse side lengths.
2D graphics — compute elevation or pitch angles from normalized vectors.
Game development — aim angles and projectile trajectories from sine components.
Signal processing — recover phase angles from sine values.
Pair with sin() — use sin forward and asin to reverse it.
🧠 How asin() Works
1
Validate input
Check that x is in [−1, 1]; otherwise return NaN.
Domain
2
Invert sine
Find θ such that sin(θ) = x using the math library.
Compute
3
Pick principal value
Return the angle in [−π/2, π/2] radians.
Range
=
📐
Angle in radians
Ready for sin(), rotation code, or degree conversion.
Important
📝 Notes
Input must be in [−1, 1]; values outside that range produce NaN.
Output is in [−π/2, π/2] radians—can be negative unlike acos().
Link with -lm when using GCC/Clang on Unix-like systems.
Use asinf or asinl for float or long double data.
For quadrant-aware angles from (x, y), prefer atan2(y, x) over asin.
Performance
⚡ Optimization
asin() is implemented in the platform math library and is already optimized. Cache results when the same ratio is computed repeatedly. For 2D direction vectors, atan2 often avoids separate quadrant logic that a naive asin(y/hyp) approach might need.
Wrap Up
Conclusion
asin() turns a sine value into an angle in radians. Keep the input between −1 and 1, remember to link -lm, and convert to degrees when your users expect them.
Next up: asinh() for inverse hyperbolic sine, or explore sin() for the forward circular sine.
Assume output is always non-negative (unlike acos)
Forget -lm on Linux builds
Ignore NaN when input comes from user data
Use asin when atan2 fits better
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about asin()
Inverse sine in C, explained simply.
5
Core concepts
📐01
Inverse sin
Angle from x.
Basics
📚02
math.h
Link -lm.
Setup
🔢03
[−1, 1]
Valid input.
Domain
🎯04
[−π/2, π/2]
Output range.
Range
💰05
Radians
Not degrees.
Units
❓ Frequently Asked Questions
asin() returns the arc sine (inverse sine) of x—the angle in radians whose sine equals x. For example, asin(0.5) is about 0.524 radians (30 degrees) because sin(30°) = 0.5.
Include <math.h> and link with -lm on many systems: gcc program.c -o program -lm. The function is declared as double asin(double x).
x must be in the range [-1, 1]. That matches any valid sine ratio (opposite ÷ hypotenuse on a right triangle). If |x| > 1, asin() returns NaN.
Radians. Multiply by 180.0 / M_PI to convert to degrees. Define _USE_MATH_DEFINES before math.h on MSVC for M_PI.
The result is always between -pi/2 and pi/2 radians (about -1.5708 to 1.5708). asin(1) is pi/2; asin(-1) is -pi/2; asin(0) is 0.
sin() takes an angle in radians and returns its sine. asin() does the reverse: it takes a sine value and returns the angle. They are inverse operations on [-1, 1].
Did you know?
Because sine is not one-to-one over all angles, asin() returns only the principal value between −π/2 and π/2. That is why asin(0.5) gives π/6 (30°) and not 150° or other angles that also have sine 0.5.