Python 计算三角函数
时间: 2024-04-10 20:25:33 浏览: 130
以下是Python计算三角函数的例子:
1. 计算正弦值[^1]
```python
import math
x = 0.5
sin_value = math.sin(x)
print("Sin value of", x, "is", sin_value) # 输出:Sin value of 0.5 is 0.479425538604203
```
2. 计算余弦值
```python
import math
x = 0.5
cos_value = math.cos(x)
print("Cos value of", x, "is", cos_value) # 输出:Cos value of 0.5 is 0.8775825618903728
```
3. 计算正切值
```python
import math
x = 0.5
tan_value = math.tan(x)
print("Tan value of", x, "is", tan_value) # 输出:Tan value of 0.5 is 0.5463024898437905
```
4. 计算反正弦弧度值
```python
import math
x = 0.5
asin_value = math.asin(x)
print("Arcsin value of", x, "is", asin_value) # 输出:Arcsin value of 0.5 is 0.5235987755982989
```
5. 计算反余弦弧度值
```python
import math
x = 0.5
acos_value = math.acos(x)
print("Arccos value of", x, "is", acos_value) # 输出:Arccos value of 0.5 is 1.0471975511965979
```
6. 计算反正切弧度值
```python
import math
x = 0.5
atan_value = math.atan(x)
print("Arctan value of", x, "is", atan_value) # 输出:Arctan value of 0.5 is 0.4636476090008061
```
7. 弧度转换为角度
```python
import math
radians = 1.57
degrees = math.degrees(radians)
print("Degrees value of", radians, "radians is", degrees) # 输出:Degrees value of 1.57 radians is 89.95437383553924
```
8. 角度转换为弧度
```python
import math
degrees = 90
radians = math.radians(degrees)
print("Radians value of", degrees, "degrees is", radians) # 输出:Radians value of 90 degrees is 1.5707963267948966
```
阅读全文