首页 > 解决方案 > 正切方程提供错误的输出

问题描述

我似乎无法在 Python 中找到我的数学问题的解决方案,没有文章适合这个问题。确实相信它可能存在于结构设置中,但坦率地说,根据我的知识,我没有选择。已尝试阅读该库,但它也没有提供解决方案。

简单来说就是这样:

代码运行良好,除了输出错误。

import math

descent_speed = float(150 * (1/60) * 6080 * (math.tan(3.0)))
print(descent_speed)

结果:-2166.7074547290226

现在计算的正确答案

150 = 以节为单位的地面速度 3.0 = 以度为单位的下降路径角度

150 * 1/60 * 6080 * 棕褐色(3.0) = 796.5982451

这是根据计算器计算的,等于每分钟 797 英尺。

现在我确实尝试使用 math.degrees 将 3.0 添加为学位,但这不起作用。

import math

GS = 150
slope = math.degrees(3.0)
descent_speed = float((GS) * (1/60) * 6080 * (math.tan(slope))) #code to calculate descent speed based on descent angle
print(descent_speed)

结果:-19164.534008140585

所以请帮忙,我没有想法?

标签: pythonmath

解决方案


三角函数以弧度为单位进行输入。更改math.degreesmath.radians

>>> help(math.tan)
Help on built-in function tan in module math:

tan(x, /)
    Return the tangent of x (measured in radians).

>>> angle_in_degrees = 3.0
>>> 150 * (1/60) * 6080 * math.tan(math.radians(angle_in_degrees))
796.5982451022264

推荐阅读