有很多bug,暂时先放上来。
思路为:画一条竖线,令a等于a',如图求M;这是碎石与石屑两曲线求一个。
对于石屑和矿粉也要按相同的步骤求一个m。
探索错误中:
def qiuab(x1,y1,x2,y2): #求斜截式a,b
X1 = float(x1)
Y1 = float(y1)
X2 = float(x2)
Y2 = float(y2)
if X1-X2 == 0:
a,b = 0,0
else:
a = -((Y2-Y1)/(X1-X2))
b = (X1*Y2-X2*Y1)/(X1-X2)
return a,b
y=0
def f(x,a,b): #求相应a,b下x得值
global y
y = a*x + b
return y
def A(x): #碎石的分段函数
global y
if x >=0 and x < 2.36:
y=0
elif (x >= 2.36 and x < 4.75):
a, b = qiuab(2.36,0,4.75,4.6)
y=f(x,a,b)
elif (x >= 4.75 and x < 9.5):
a, b = qiuab(4.6,4.75,9.5,19.8)
y=f(x,a,b)
elif (x >= 9.5 and x < 13.2):
a, b = qiuab( 9.5, 19.8,13.2,34.5)
y=f(x,a,b)
elif (x >= 13.2 and x < 16 ):
a, b = qiuab(13.2, 34.5,16,61.5)
y=f(x,a,b)
elif (x >= 16 and x < 19 ):
a, b = qiuab(16,61.5,19,27)
y=f(x,a,b)
elif (x >= 19 and x < 26.5 ):
a, b = qiuab(19,27,26.5,100)
y=f(x,a,b)
return y
def B(x): #石屑的分段函数
global y
x13, x12, x11, x10, x9, x8, x7, x6, x5, x4, x3 = 26.5,19,16,13.2,9.5,4.75,2.36,1.18,0.6,0.3,0.15
y13, y12, y11, y10, y9, y8, y7, y6, y5, y4, y3 = 100,100,100,100,93.8,77.9,58.7,36,2