简体   繁体   English

使用 Python 的数学库计算公式

[英]Calculation of a formula with Python's math library

图片
According to the picture that contains the formula, I wrote the following code根据包含公式的图片,我写了下面的代码
But the numbers I give in the input are wrong但是我输入的数字是错误的

import math as m
x = int(input())
r=m.ceil(m.pow(x,(5/3))+m.tan(x))
y = m.floor(m.pow(m.pi, 2+m.atan(m.pow(m.sin(m.radians(x)), 2))))
print(m.gcd(r,y))

You need to convert to radians when using math.tan() , as well as the rest of the trigonometric functions:使用math.tan()时需要转换为弧度,以及三角函数的 rest:

import math as m
x = int(input())
r=m.ceil(m.pow(x,(5/3))+m.tan(m.radians(x)))
y = m.floor(m.pow(m.pi, 2+m.atan(m.pow(m.sin(m.radians(x)), 2))))
print(m.gcd(r,y))

Also, if the input is in radians, you must remove m.radians() then此外,如果输入以弧度为单位,则必须删除m.radians()然后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM