Ref Math Asin
## Python math.asin() Method
The `math.asin()` method is a built-in function in Python's standard `math` module. It returns the arc sine (inverse sine) of a given number.
Mathematically, if $y = \sin(x)$, then $\arcsin(y) = x$. The `math.asin()` method performs this inverse operation, returning the angle in radians.
---
### Syntax
```python
import math
math.asin(x)
```
### Parameters
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `x` | `float` or `int` | **Required.** A numeric value between `-1` and `1` (inclusive). |
### Return Value
* **Type:** `float`
* **Description:** Returns the arc sine of `x` as a float value expressed in **radians**.
* **Range:** The returned value is always in the range $[-\pi/2, \pi/2]$ (approximately `-1.57079` to `1.57079` radians).
---
### Code Examples
The following example demonstrates how to use `math.asin()` with various positive, negative, and boundary values.
```python
import math
# Calculate arc sine for different values
print("asin(0.55): ", math.asin(0.55))
print("asin(-0.55):", math.asin(-0.55))
print("asin(0): ", math.asin(0))
print("asin(1): ", math.asin(1)) # Equivalent to pi/2
print("asin(-1): ", math.asin(-1)) # Equivalent to -pi/2
```
**Output:**
```text
asin(0.55): 0.5823642378687435
asin(-0.55): -0.5823642378687435
asin(0): 0.0
asin(1): 1.5707963267948966
asin(-1): -1.5707963267948966
```
---
### Considerations & Exceptions
#### 1. Out of Range Error (`ValueError`)
The domain of the arc sine function is strictly $[-1, 1]$. If you pass a value outside this range, Python will raise a `ValueError`.
```python
import math
try:
# This will raise a ValueError because 1.5 is greater than 1
math.asin(1.5)
except ValueError as e:
print("Error:", e)
```
**Output:**
```text
Error: math domain error
```
#### 2. Non-Numeric Input (`TypeError`)
If you pass a non-numeric value (such as a string or a list) to `math.asin()`, Python will raise a `TypeError`.
```python
import math
try:
math.asin("0.5")
except TypeError as e:
print("Error:", e)
```
**Output:**
```text
Error: must be real number, not str
```
#### 3. Converting Radians to Degrees
Because `math.asin()` returns the angle in radians, you might want to convert it to degrees for human-readable output. You can easily do this using `math.degrees()`.
```python
import math
radians_val = math.asin(0.5)
degrees_val = math.degrees(radians_val)
print(f"Radians: {radians_val}")
print(f"Degrees: {degrees_val}Β°")
```
**Output:**
```text
Radians: 0.5235987755982989
Degrees: 30.000000000000004Β°
```
YouTip