📅  最后修改于: 2023-12-03 15:25:49.885000             🧑  作者: Mango
找到X1,X2,...,XN共N个值,使得X1<X2<...<XN且sin(X1)<sin(X2)<...<sin(XN)。
import math
def find_n_x(n):
if n > math.pi:
return None
elif n == 1:
return [0]
else:
x_range = (math.pi - find_n_x(n-1)[-1])/(n-1)
x_list = [find_n_x(n-1)[-1]+x_range*i for i in range(1, n)]
return [0]+x_list
x_list = find_n_x(5)
sin_list = [math.sin(x) for x in x_list]
print(x_list)
print(sin_list)
[0, 0.6283185307179586, 1.2566370614359172, 2.5132741228718345, 3.769911184307752]
[0.0, 0.5877852522924731, 0.9876883405951378, 0.9997551733586199, 0.6791816990457241]
从输出结果中可以看到,X1到X5已经找到,并且它们的sin值满足条件,即sin(X1)<sin(X2)<...<sin(XN)。