m为≥0的整数,有方程y=(10m^2-18m+16650)÷(60m+43),当m为何值时y值是整数?要求不得用遍历m值方法来求。
用matplotlib做图,可以看到基本(0,20)单调递减,(20,~)单调递增
整数值的解肯定是有的,那就找一下图里 y=整数与x轴的交点
红色*号处是其中俩个解。
其中一个准确解:(13,22),另一个(120.8,22)
# y=(10m^2-18m+16650)÷(60m+43)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import ticker
x = np.arange(0, 20, 0.1) # 1个解
x = np.arange(0, 150, 0.001) # 2个
fig, ax = plt.subplots() # 创建一个图标和轴
y = (10 * x ** 2 - 18 * x + 16650) / (60 * x + 43)
# print(len(y))
ax.plot(x, y, label='y=(10 * x ** 2 - 18 * x + 16650) / (60 * x + 43)')
x2 = [(x1, int(y1)) for x1, y1 in zip(x, y) if y1 % 1 == 0]
# print(len(x2))
for (x0, y0) in x2:
print('scatter: ', x0, y0)
ax.scatter(x0, y0, s=120, marker='*', c='r')
ax.yaxis.set_major_locator(ticker.MultipleLocator(100)) # y轴刻度
ax.yaxis.set_minor_locator(ticker.MultipleLocator(10)) # y最小刻度精度
# ax.xaxis.set_major_locator(ticker.MultipleLocator(0.002)) # x轴刻度
# ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.0002)) # x最小刻度精度
ax.set_xlabel('x label') # 添加x轴的标签
ax.set_ylabel('y label') # 添加y轴的标签
ax.set_title("Simple Plot") # 添加图表的标题
# 设置y轴刻度及范围
y_ticks = np.linspace(min(y), max(y), 10)
plt.yticks(y_ticks)
plt.legend()
plt.show()
遍历,无解。想根据答案凑个解题过程都凑不出。
专门问了数学系的dalao
这可以归类到优化问题,可以用整数规划的割平面法去求解
当m为整数时,关于X的方程(2m-1)X2-(2m+1)X+1=0是否有有理根?如果有,求出m的值;如果没有,请说明理由,
没有.证明如下:
△
=(2m+1)^2-4(2m-1)×1=4m^2-4m+5=(2m-1)^2+4
设(2m-1)^2+4=n^2
∴n^2-(2m-1)^2=4
∴(n+2m-1)(n-2m+1)=4
∵n+(2m-1)与n-(2m-1)奇偶性相同
故只可能有n+2m-1=n-2m+1=2
或n+2m-1=n-2m+1=-2
,
解得2m-1=0
此与m为整数矛盾,故△不可能为完全平方数,方程不可能有理根.