python中内置数学函数详解和实例应用之三角函数_初级阶段(二)

本文介绍了Python中用于三角函数运算的内置函数,包括sin、cos、tan及其反函数,还有atan2、hypot、degrees和radians等,详细解释了它们的功能和使用方法,并提供了相关示例。
摘要由CSDN通过智能技术生成

学习目标:

利用python进行三角函数运算


学习内容:

python中的三角函数合集和应用实例

转载请注明出处!


学习产出:

环境:python 3.7, 利用shell进行实例操作。

Note: 使用三角函数前需要import math

1.1, math.sin() 输出的x弧度的正弦值,数值在 -1 到 1 之间。

>>> math.sin(0)
0.0
>>> math.sin(math.pi / 2)
1.0
>>> round(math.sin(math.pi / 4), 2)
0.71
>>> bool(round(math.sin(math.pi / 4), 2) == round((pow(2, 1 / 2)) / 2, 2))
True

1.2,math.cos()输出x的弧度的余弦值,数值在-1 到 1 之间。

>>> math.cos(0)
1.0
>>> math.cos(math.sin(math.pi))
1.0
>>>math.cos(math.pi / 3)
0.5000000000000001
>>> bool(math.cos(math.sin(math.pi)) == math.cos(math.sin(0)))
True
>>> math.sin(10) ** 2 + math.cos(10) ** 2
1.0  		# 即sin(x) * sin(x) + cos(x) * cos(x) = 1

1.3 math.tan()输出x弧度的正切值,数值在 -1 到 1 之间。
Note: python中没有math.cot()函数.

>>> math.tan(math.pi / 2)
1.633123935319537e+16
>>> math.tan(math.pi / 4)
0.9999999999999999
>>> math.sin(math.pi / 4) / math.cos(math.pi / 4)
1.0
>>> bool(math.tan(math.pi / 4) == math.sin(math.pi / 4) 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值