C asin() Function
The asin()
function computes the inverse sine of a given value and returns the result in radians. It is a fundamental function in trigonometry, serving as the inverse operation of the sine function.
Syntax of asin()
double asin(double x);
Parameters
Parameter | Description |
---|---|
x | Input value in the interval [-1, +1]. Values outside this range will result in a domain error. |
Additional Points: The function returns the principal value of the arc sine in the interval [-π/2, +π/2] radians. Note that one radian is equivalent to 180/π degrees. The function expects a value within the specified range; providing a value outside [-1, +1] will trigger a domain error.
Examples for asin()
Example 1: Calculating the Arc Sine of a Positive Value
This example demonstrates how to compute the inverse sine of a positive number within the valid input range.
Program
#include <stdio.h>
#include <math.h>
int main() {
double value = 0.5;
double result = asin(value);
printf("The arc sine of %.2f is %.2f radians\n", value, result);
return 0;
}
Explanation:
- The program initializes a positive value within the valid range for
asin()
. - The
asin()
function calculates the inverse sine of the value, returning the result in radians. - The resulting value is printed to the console.
Program Output:
The arc sine of 0.50 is 0.52 radians
Example 2: Calculating the Arc Sine of a Negative Value
This example demonstrates how to compute the inverse sine of a negative value within the acceptable range.
Program
#include <stdio.h>
#include <math.h>
int main() {
double value = -0.5;
double result = asin(value);
printf("The arc sine of %.2f is %.2f radians\n", value, result);
return 0;
}
Explanation:
- The program initializes a negative value within the valid input range.
- The
asin()
function computes the arc sine of the negative value, returning the result in radians. - The calculated value is displayed using
printf()
.
Program Output:
The arc sine of -0.50 is -0.52 radians
Example 3: Handling the Edge Case with Maximum Valid Input
This example demonstrates the function’s behavior when the input is at the upper limit of the valid range.
Program
#include <stdio.h>
#include <math.h>
int main() {
double value = 1.0;
double result = asin(value);
printf("The arc sine of %.2f is %.2f radians\n", value, result);
return 0;
}
Explanation:
- The program sets the input value to the maximum valid number, 1.0.
- The
asin()
function computes the arc sine, which should return π/2 radians (approximately 1.57 radians). - The result is printed to verify the output.
Program Output:
The arc sine of 1.00 is 1.57 radians