今回は、整数型で、高次方程式を解きます。解く方程式は、4台クラスターで高次方程式を解くI と 100次方程式を解く で解いた方程式と同じ式です。しかし今回のプログラムは、整数型で加法・減法・乗法の演算をしています。そして最後に1回だけ除法を使って桁数を戻しています。pythonの倍精度浮動小数点型は有効数字桁数が14桁(浮動小数点の仮数部の10進数での桁数)ほどありますが、この時に浮動小数点型に戻ります。つまりこの時、仮数部の桁数によって、解の有効数字のダイナミックレンジ(対数表示の桁数の意味で)は制限されます。ただ計算途中は、整数型により計算精度は格段に上がります。また最後に1000次と10000次方程式も今回追加しました。1000次と10000次方程式になると、計算最後の1回だけ除法の時、今度は倍精度浮動小数点の指数部がオーバーフローします。
以下に今回試行したプログラムを示しました。Raspberry Pi 4Bのメモリー2GBの機種で、Raspberry Pi OS with DESKTOP(2020-DEC-02, 32bit版OS)のThonnyを使っています。USBにディスク等は接続していません。SwapはデフォルトのSDカード100MBです。
#3次方程式
4台クラスターで高次方程式を解くIと同じ方程式です。
y = 2.1 - 2.1425x - 2.3x^2 + x^3 = 0
今回は整数型で解くプログラムです。
import time
#### Input Start ####
x_initZero =-2.0
x_endZero = 0.0
x_init = 0.0
x_end = 3.0
a= 1
b=-2.3
c=-2.1425
d= 2.1
R_f=10000000
#### Input End ####
print(f"Calculation Start")
if R_f==10000000:
print(f" Please wait for 3 minutes.")
elif R_f==1000000:
print(f" Please wait for 20 seconds.")
X_initZero = int(R_f*x_endZero)
X_endZero = int(R_f*x_initZero*(-1))
X_init = int(R_f*x_init)
X_end = int(R_f*x_end)
A = int((R_f**0)*a)
B = int((R_f**1)*b)
C = int((R_f**2)*c)
D = int((R_f**3)*d)
#a= 1 *1
#b=-2.3 *10000000
#c=-2.1425 *100000000000000
#d= 2.1 *1000000000000000000000
AnswersXY = []
initial_time=time.time()
for X in range(X_initZero, X_endZero):
X = (-1)*X
Y = A*(X)**3 + B*(X)**2 + C*X + D
if X==X_init:
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
AnswersXY.append(X)
AnswersXY.append(Y)
else:
Ypre=Y
AnswersXY.append(X)
AnswersXY.append(Y)
for X in range(X_init, X_end):
Y = A*(X)**3 + B*(X)**2 + C*X + D
if X==X_init:
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
AnswersXY.append(X)
AnswersXY.append(Y)
else:
Ypre=Y
AnswersXY.append(X)
AnswersXY.append(Y)
print(f"Calculation Finished")
answersXY=[]
for i in range(int(len(AnswersXY)/2)):
answersXY.append(( (int(AnswersXY[2*i])/R_f),\
(int(AnswersXY[2*i+1]))/(R_f**3) ))
print(f"Time :")
print(str(time.time() - initial_time))
print(f"Answers :")
for i in range(len(answersXY)):
print(answersXY[i])
time.sleep(10)
#Time :
#90.....
#Answers :
#(-1.1501757, -2.83010741445093e-07)
#(0.6526514, -1.02833550915256e-07)
#(2.7975243, 1.11528199673907e-07)
#10次方程式
4台クラスターで高次方程式を解くI
と同じ方程式です。今回は整数型で解くプログラムです。
y=
=(x-1)(x-2)(x-3)(x-4)(x-5)(x-6)(x-7)(x-8)(x-9)(x-10)
=x^10 - 55x^9 + 1320x^8 - 18150x^7 + 157773x^6 - 902055x^5 + 3416930x^4 - 8409500x^3 + 12753576x^2 - 10628640*x + 3628800
= 0
import time
from multiprocessing import Pool
def calc_2s(i0,R_f,X_init,X_end,Keisus):
Ypre=0
totalsXY=[i0]
for X in range(int(X_init), int(X_end)+1):
Y = Keisus[0]+Keisus[1]*(X)**1+Keisus[2]*(X)**2+Keisus[3]*(X)**3+Keisus[4]*(X)**4+Keisus[5]*(X)**5+\
Keisus[6]*(X)**6+Keisus[7]*(X)**7+Keisus[8]*(X)**8+Keisus[9]*(X)**9+Keisus[10]*(X)**10
if X == int(X_init):
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
Y=Y
totalsXY.append(X)
totalsXY.append(Y)
else:
Ypre=Y
totalsXY.append(X)
totalsXY.append(Y)
return totalsXY
def wrapper_func(args):
return calc_2s(*args)
def multi_processing_pool(Args_Lists):
p = Pool(4)
process_XY = p.map(wrapper_func, Args_Lists)
p.close()
return process_XY
if __name__=="__main__":
#### Input Start ####
xx_Range_from = 0
xx_Range_to = 12
aa00= 3628800.0
aa01=-10628640.0
aa02= 12753576.0
aa03=-8409500.0
aa04= 3416930.0
aa05=-902055.0
aa06= 157773.0
aa07=-18150.0
aa08= 1320.0
aa09=-55.0
aa10= 1.0
r_f = 1000000
ji_suu = 10
#### Input End ####
print(f"Calculation Start")
if r_f==1000000:
print(f" Please wait for 40 seconds.")
x_Range_from = int(r_f*xx_Range_from)
x_Range_to = int(r_f*xx_Range_to)
f_range = x_Range_to - x_Range_from
keisus=[]
keisus.append( int((r_f**10)*aa00) )
keisus.append( int((r_f**9) *aa01) )
keisus.append( int((r_f**8) *aa02) )
keisus.append( int((r_f**7) *aa03) )
keisus.append( int((r_f**6) *aa04) )
keisus.append( int((r_f**5) *aa05) )
keisus.append( int((r_f**4) *aa06) )
keisus.append( int((r_f**3) *aa07) )
keisus.append( int((r_f**2) *aa08) )
keisus.append( int((r_f**1) *aa09) )
keisus.append( int((r_f**0) *aa10) )
initial_time=time.time()
ArgsLists= [(i,r_f,i*f_range/4,(i+1)*f_range/4,keisus) for i in range(4)]
processXY = multi_processing_pool(ArgsLists)
print(f"Calculation Finished")
processXYstr = str(processXY)
processXY.clear()
processXYstr = processXYstr.replace('[[', '')
processXYstr = processXYstr.replace(']]', '')
processesXYstr=processXYstr.split('], [')
process0XYstr=processesXYstr[0]
process1XYstr=processesXYstr[1]
process2XYstr=processesXYstr[2]
process3XYstr=processesXYstr[3]
processesXYstr.clear()
process0sXYstr=process0XYstr.split(', ')
process1sXYstr=process1XYstr.split(', ')
process2sXYstr=process2XYstr.split(', ')
process3sXYstr=process3XYstr.split(', ')
process0XYstr=''
process1XYstr=''
process2XYstr=''
process3XYstr=''
if process0sXYstr[0]=='0' or process0sXYstr[0]=='0.0':
ProcessAA0=process0sXYstr.copy()
elif process1sXYstr[0]=='0' or process1sXYstr[0]=='0.0':
ProcessAA0=process1sXYstr.copy()
elif process2sXYstr[0]=='0' or process2sXYstr[0]=='0.0':
ProcessAA0=process2sXYstr.copy()
elif process3sXYstr[0]=='0' or process3sXYstr[0]=='0.0':
ProcessAA0=process3sXYstr.copy()
if process0sXYstr[0]=='1' or process0sXYstr[0]=='1.0':
ProcessAA1=process0sXYstr.copy()
elif process1sXYstr[0]=='1' or process1sXYstr[0]=='1.0':
ProcessAA1=process1sXYstr.copy()
elif process2sXYstr[0]=='1' or process2sXYstr[0]=='1.0':
ProcessAA1=process2sXYstr.copy()
elif process3sXYstr[0]=='1' or process3sXYstr[0]=='1.0':
ProcessAA1=process3sXYstr.copy()
if process0sXYstr[0]=='2' or process0sXYstr[0]=='2.0':
ProcessAA2=process0sXYstr.copy()
elif process1sXYstr[0]=='2' or process1sXYstr[0]=='2.0':
ProcessAA2=process1sXYstr.copy()
elif process2sXYstr[0]=='2' or process2sXYstr[0]=='2.0':
ProcessAA2=process2sXYstr.copy()
elif process3sXYstr[0]=='2' or process3sXYstr[0]=='2.0':
ProcessAA2=process3sXYstr.copy()
if process0sXYstr[0]=='3' or process0sXYstr[0]=='3.0':
ProcessAA3=process0sXYstr.copy()
elif process1sXYstr[0]=='3' or process1sXYstr[0]=='3.0':
ProcessAA3=process1sXYstr.copy()
elif process2sXYstr[0]=='3' or process2sXYstr[0]=='3.0':
ProcessAA3=process2sXYstr.copy()
elif process3sXYstr[0]=='3' or process3sXYstr[0]=='3.0':
ProcessAA3=process3sXYstr.copy()
process0sXYstr.clear()
process1sXYstr.clear()
process2sXYstr.clear()
process3sXYstr.clear()
ProcessAA0.pop(0)
ProcessAA1.pop(0)
ProcessAA2.pop(0)
ProcessAA3.pop(0)
answersXY=[]
for i in range(int(len(ProcessAA0)/2)):
answersXY.append(( (int(ProcessAA0[2*i])/r_f),\
(int(ProcessAA0[2*i+1]))/(r_f**ji_suu) ))
for i in range(int(len(ProcessAA1)/2)):
answersXY.append(( (int(ProcessAA1[2*i])/r_f),\
(int(ProcessAA1[2*i+1]))/(r_f**ji_suu) ))
for i in range(int(len(ProcessAA2)/2)):
answersXY.append(( (int(ProcessAA2[2*i])/r_f),\
(int(ProcessAA2[2*i+1]))/(r_f**ji_suu) ))
for i in range(int(len(ProcessAA3)/2)):
answersXY.append(( (int(ProcessAA3[2*i])/r_f),\
(int(ProcessAA3[2*i+1]))/(r_f**ji_suu) ))
print(f"Time :")
print(str(time.time() - initial_time))
print(f"Answers :")
for i in range(len(answersXY)):
print(answersXY[i])
time.sleep(10)
#Time :
#55 ......
#Answers :
#(1.000001, -0.3628789724587281)
#(2.0, 6.650016466826255e-09)
#(3.000001, -0.010079961831267673)
#(4.0, 7.980505643289606e-08)
#(5.000001, -0.0028798142265657276)
#(6.0, 3.560047465463835e-07)
#(7.000001, -0.004319426533713714)
#(8.0, 7.675194067778865e-07)
#(9.000001, -0.04031932725371335)
#(10.0, 1.3557000349574745e-07)
解が0.000001ズレています。因数分解型を展開しただけの式なので、解は整数の1.0, 2.0, 3.0 ...となるはずです。さらにその時のy値は0.0になるはずです。今回のプログラムのどこかがおかしいようです。確認中です。
#100次方程式
100次方程式を解く
と同じ方程式です。今回は整数型で解くプログラムです。
y=
(x- 0.950)(x- 0.951)(x- 0.952)(x- 0.953)(x- 0.954)(x- 0.955)(x- 0.956)(x- 0.957)(x- 0.958)(x- 0.959)×
(x- 0.960)(x- 0.961)(x- 0.962)(x- 0.963)(x- 0.964)(x- 0.965)(x- 0.966)(x- 0.967)(x- 0.968)(x- 0.969)×
(x- 0.970)(x- 0.971)(x- 0.972)(x- 0.973)(x- 0.974)(x- 0.975)(x- 0.976)(x- 0.977)(x- 0.978)(x- 0.979)×
(x- 0.980)(x- 0.981)(x- 0.982)(x- 0.983)(x- 0.984)(x- 0.985)(x- 0.986)(x- 0.987)(x- 0.988)(x- 0.989)×
(x- 0.990)(x- 0.991)(x- 0.992)(x- 0.993)(x- 0.994)(x- 0.995)(x- 0.996)(x- 0.997)(x- 0.998)(x- 0.999)×
(x- 1.000)(x- 1.001)(x- 1.002)(x- 1.003)(x- 1.004)(x- 1.005)(x- 1.006)(x- 1.007)(x- 1.008)(x- 1.009)×
(x- 1.010)(x- 1.011)(x- 1.012)(x- 1.013)(x- 1.014)(x- 1.015)(x- 1.016)(x- 1.017)(x- 1.018)(x- 1.019)×
(x- 1.020)(x- 1.021)(x- 1.022)(x- 1.023)(x- 1.024)(x- 1.025)(x- 1.026)(x- 1.027)(x- 1.028)(x- 1.029)×
(x- 1.030)(x- 1.031)(x- 1.032)(x- 1.033)(x- 1.034)(x- 1.035)(x- 1.036)(x- 1.037)(x- 1.038)(x- 1.039)×
(x- 1.040)(x- 1.041)(x- 1.042)(x- 1.043)(x- 1.044)(x- 1.045)(x- 1.046)(x- 1.047)(x- 1.048)(x- 1.049) = 0
import time
from multiprocessing import Pool
def calc_2s(i0,R_f,X_init,X_end,\
A00,A01,A02,A03,A04,A05,A06,A07,A08,A09,\
A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,\
A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,\
A30,A31,A32,A33,A34,A35,A36,A37,A38,A39,\
A40,A41,A42,A43,A44,A45,A46,A47,A48,A49,\
A50,A51,A52,A53,A54,A55,A56,A57,A58,A59,\
A60,A61,A62,A63,A64,A65,A66,A67,A68,A69,\
A70,A71,A72,A73,A74,A75,A76,A77,A78,A79,\
A80,A81,A82,A83,A84,A85,A86,A87,A88,A89,\
A90,A91,A92,A93,A94,A95,A96,A97,A98,A99):
Ypre=0
totalsXY=[i0]
for X in range( int(X_init), int(X_end)+1 ):
Y = (X-A00)*(X-A01)*(X-A02)*(X-A03)*(X-A04)*(X-A05)*(X-A06)*(X-A07)*(X-A08)*(X-A09)*\
(X-A10)*(X-A11)*(X-A12)*(X-A13)*(X-A14)*(X-A15)*(X-A16)*(X-A17)*(X-A18)*(X-A19)*\
(X-A20)*(X-A21)*(X-A22)*(X-A23)*(X-A24)*(X-A25)*(X-A26)*(X-A27)*(X-A28)*(X-A29)*\
(X-A30)*(X-A31)*(X-A32)*(X-A33)*(X-A34)*(X-A35)*(X-A36)*(X-A37)*(X-A38)*(X-A39)*\
(X-A40)*(X-A41)*(X-A42)*(X-A43)*(X-A44)*(X-A45)*(X-A46)*(X-A47)*(X-A48)*(X-A49)*\
(X-A50)*(X-A51)*(X-A52)*(X-A53)*(X-A54)*(X-A55)*(X-A56)*(X-A57)*(X-A58)*(X-A59)*\
(X-A60)*(X-A61)*(X-A62)*(X-A63)*(X-A64)*(X-A65)*(X-A66)*(X-A67)*(X-A68)*(X-A69)*\
(X-A70)*(X-A71)*(X-A72)*(X-A73)*(X-A74)*(X-A75)*(X-A76)*(X-A77)*(X-A78)*(X-A79)*\
(X-A80)*(X-A81)*(X-A82)*(X-A83)*(X-A84)*(X-A85)*(X-A86)*(X-A87)*(X-A88)*(X-A89)*\
(X-A90)*(X-A91)*(X-A92)*(X-A93)*(X-A94)*(X-A95)*(X-A96)*(X-A97)*(X-A98)*(X-A99)
if X == int(X_init):
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
Y=Y
totalsXY.append(X)
totalsXY.append(Y)
else:
Ypre=Y
totalsXY.append(X)
totalsXY.append(Y)
return totalsXY
def wrapper_func(args):
return calc_2s(*args)
def multi_processing_pool(Args_Lists):
p = Pool(4)
process_XY = p.map(wrapper_func, Args_Lists)
p.close()
return process_XY
if __name__=="__main__":
#### Input Start ####
xx_Range_from = 0.900
xx_Range_to = 1.100
aa00= 0.950
aa01= 0.951
aa02= 0.952
aa03= 0.953
aa04= 0.954
aa05= 0.955
aa06= 0.956
aa07= 0.957
aa08= 0.958
aa09= 0.959
aa10= 0.960
aa11= 0.961
aa12= 0.962
aa13= 0.963
aa14= 0.964
aa15= 0.965
aa16= 0.966
aa17= 0.967
aa18= 0.968
aa19= 0.969
aa20= 0.970
aa21= 0.971
aa22= 0.972
aa23= 0.973
aa24= 0.974
aa25= 0.975
aa26= 0.976
aa27= 0.977
aa28= 0.978
aa29= 0.979
aa30= 0.980
aa31= 0.981
aa32= 0.982
aa33= 0.983
aa34= 0.984
aa35= 0.985
aa36= 0.986
aa37= 0.987
aa38= 0.988
aa39= 0.989
aa40= 0.990
aa41= 0.991
aa42= 0.992
aa43= 0.993
aa44= 0.994
aa45= 0.995
aa46= 0.996
aa47= 0.997
aa48= 0.998
aa49= 0.999
aa50= 1.000
aa51= 1.001
aa52= 1.002
aa53= 1.003
aa54= 1.004
aa55= 1.005
aa56= 1.006
aa57= 1.007
aa58= 1.008
aa59= 1.009
aa60= 1.010
aa61= 1.011
aa62= 1.012
aa63= 1.013
aa64= 1.014
aa65= 1.015
aa66= 1.016
aa67= 1.017
aa68= 1.018
aa69= 1.019
aa70= 1.020
aa71= 1.021
aa72= 1.022
aa73= 1.023
aa74= 1.024
aa75= 1.025
aa76= 1.026
aa77= 1.027
aa78= 1.028
aa79= 1.029
aa80= 1.030
aa81= 1.031
aa82= 1.032
aa83= 1.033
aa84= 1.034
aa85= 1.035
aa86= 1.036
aa87= 1.037
aa88= 1.038
aa89= 1.039
aa90= 1.040
aa91= 1.041
aa92= 1.042
aa93= 1.043
aa94= 1.044
aa95= 1.045
aa96= 1.046
aa97= 1.047
aa98= 1.048
aa99= 1.049
r_f = 10000
ji_suu = 100
Yaxis_Zoom = 20
#### Input End ####
print(f"Calculation Start")
x_Range_from = int(r_f*xx_Range_from)
x_Range_to = int(r_f*xx_Range_to)
f_range = x_Range_to - x_Range_from
a00= int(r_f *aa00)
a01= int(r_f *aa01)
a02= int(r_f *aa02)
a03= int(r_f *aa03)
a04= int(r_f *aa04)
a05= int(r_f *aa05)
a06= int(r_f *aa06)
a07= int(r_f *aa07)
a08= int(r_f *aa08)
a09= int(r_f *aa09)
a10= int(r_f *aa10)
a11= int(r_f *aa11)
a12= int(r_f *aa12)
a13= int(r_f *aa13)
a14= int(r_f *aa14)
a15= int(r_f *aa15)
a16= int(r_f *aa16)
a17= int(r_f *aa17)
a18= int(r_f *aa18)
a19= int(r_f *aa19)
a20= int(r_f *aa20)
a21= int(r_f *aa21)
a22= int(r_f *aa22)
a23= int(r_f *aa23)
a24= int(r_f *aa24)
a25= int(r_f *aa25)
a26= int(r_f *aa26)
a27= int(r_f *aa27)
a28= int(r_f *aa28)
a29= int(r_f *aa29)
a30= int(r_f *aa30)
a31= int(r_f *aa31)
a32= int(r_f *aa32)
a33= int(r_f *aa33)
a34= int(r_f *aa34)
a35= int(r_f *aa35)
a36= int(r_f *aa36)
a37= int(r_f *aa37)
a38= int(r_f *aa38)
a39= int(r_f *aa39)
a40= int(r_f *aa40)
a41= int(r_f *aa41)
a42= int(r_f *aa42)
a43= int(r_f *aa43)
a44= int(r_f *aa44)
a45= int(r_f *aa45)
a46= int(r_f *aa46)
a47= int(r_f *aa47)
a48= int(r_f *aa48)
a49= int(r_f *aa49)
a50= int(r_f *aa50)
a51= int(r_f *aa51)
a52= int(r_f *aa52)
a53= int(r_f *aa53)
a54= int(r_f *aa54)
a55= int(r_f *aa55)
a56= int(r_f *aa56)
a57= int(r_f *aa57)
a58= int(r_f *aa58)
a59= int(r_f *aa59)
a60= int(r_f *aa60)
a61= int(r_f *aa61)
a62= int(r_f *aa62)
a63= int(r_f *aa63)
a64= int(r_f *aa64)
a65= int(r_f *aa65)
a66= int(r_f *aa66)
a67= int(r_f *aa67)
a68= int(r_f *aa68)
a69= int(r_f *aa69)
a70= int(r_f *aa70)
a71= int(r_f *aa71)
a72= int(r_f *aa72)
a73= int(r_f *aa73)
a74= int(r_f *aa74)
a75= int(r_f *aa75)
a76= int(r_f *aa76)
a77= int(r_f *aa77)
a78= int(r_f *aa78)
a79= int(r_f *aa79)
a80= int(r_f *aa80)
a81= int(r_f *aa81)
a82= int(r_f *aa82)
a83= int(r_f *aa83)
a84= int(r_f *aa84)
a85= int(r_f *aa85)
a86= int(r_f *aa86)
a87= int(r_f *aa87)
a88= int(r_f *aa88)
a89= int(r_f *aa89)
a90= int(r_f *aa90)
a91= int(r_f *aa91)
a92= int(r_f *aa92)
a93= int(r_f *aa93)
a94= int(r_f *aa94)
a95= int(r_f *aa95)
a96= int(r_f *aa96)
a97= int(r_f *aa97)
a98= int(r_f *aa98)
a99= int(r_f *aa99)
initial_time=time.time()
ArgsLists= [(i,r_f,x_Range_from+i*f_range/4,x_Range_from+(i+1)*f_range/4,\
a00,a01,a02,a03,a04,a05,a06,a07,a08,a09,\
a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,\
a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,\
a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,\
a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,\
a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,\
a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,\
a70,a71,a72,a73,a74,a75,a76,a77,a78,a79,\
a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,\
a90,a91,a92,a93,a94,a95,a96,a97,a98,a99) for i in range(4)]
processXY = multi_processing_pool(ArgsLists)
print(f"Calculation Finished")
processXYstr = str(processXY)
processXY.clear()
processXYstr = processXYstr.replace('[[', '')
processXYstr = processXYstr.replace(']]', '')
processesXYstr=processXYstr.split('], [')
process0XYstr=processesXYstr[0]
process1XYstr=processesXYstr[1]
process2XYstr=processesXYstr[2]
process3XYstr=processesXYstr[3]
processesXYstr.clear()
process0sXYstr=process0XYstr.split(', ')
process1sXYstr=process1XYstr.split(', ')
process2sXYstr=process2XYstr.split(', ')
process3sXYstr=process3XYstr.split(', ')
process0XYstr=''
process1XYstr=''
process2XYstr=''
process3XYstr=''
if process0sXYstr[0]=='0' or process0sXYstr[0]=='0.0':
ProcessAA0=process0sXYstr.copy()
elif process1sXYstr[0]=='0' or process1sXYstr[0]=='0.0':
ProcessAA0=process1sXYstr.copy()
elif process2sXYstr[0]=='0' or process2sXYstr[0]=='0.0':
ProcessAA0=process2sXYstr.copy()
elif process3sXYstr[0]=='0' or process3sXYstr[0]=='0.0':
ProcessAA0=process3sXYstr.copy()
if process0sXYstr[0]=='1' or process0sXYstr[0]=='1.0':
ProcessAA1=process0sXYstr.copy()
elif process1sXYstr[0]=='1' or process1sXYstr[0]=='1.0':
ProcessAA1=process1sXYstr.copy()
elif process2sXYstr[0]=='1' or process2sXYstr[0]=='1.0':
ProcessAA1=process2sXYstr.copy()
elif process3sXYstr[0]=='1' or process3sXYstr[0]=='1.0':
ProcessAA1=process3sXYstr.copy()
if process0sXYstr[0]=='2' or process0sXYstr[0]=='2.0':
ProcessAA2=process0sXYstr.copy()
elif process1sXYstr[0]=='2' or process1sXYstr[0]=='2.0':
ProcessAA2=process1sXYstr.copy()
elif process2sXYstr[0]=='2' or process2sXYstr[0]=='2.0':
ProcessAA2=process2sXYstr.copy()
elif process3sXYstr[0]=='2' or process3sXYstr[0]=='2.0':
ProcessAA2=process3sXYstr.copy()
if process0sXYstr[0]=='3' or process0sXYstr[0]=='3.0':
ProcessAA3=process0sXYstr.copy()
elif process1sXYstr[0]=='3' or process1sXYstr[0]=='3.0':
ProcessAA3=process1sXYstr.copy()
elif process2sXYstr[0]=='3' or process2sXYstr[0]=='3.0':
ProcessAA3=process2sXYstr.copy()
elif process3sXYstr[0]=='3' or process3sXYstr[0]=='3.0':
ProcessAA3=process3sXYstr.copy()
process0sXYstr.clear()
process1sXYstr.clear()
process2sXYstr.clear()
process3sXYstr.clear()
ProcessAA0.pop(0)
ProcessAA1.pop(0)
ProcessAA2.pop(0)
ProcessAA3.pop(0)
answersXY=[]
for i in range(int(len(ProcessAA0)/2)):
answersXY.append(( (int(ProcessAA0[2*i])/r_f),\
(int(ProcessAA0[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA1)/2)):
answersXY.append(( (int(ProcessAA1[2*i])/r_f),\
(int(ProcessAA1[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA2)/2)):
answersXY.append(( (int(ProcessAA2[2*i])/r_f),\
(int(ProcessAA2[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA3)/2)):
answersXY.append(( (int(ProcessAA3[2*i])/r_f),\
(int(ProcessAA3[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
print(f"Time :")
print(str(time.time() - initial_time))
print(f"Answers :")
for i in range(len(answersXY)):
print(answersXY[i])
time.sleep(10)
#1000次方程式
今回追加した1000次方程式を整数型で解くプログラムです。式はプログラム内にあります。
import time
from multiprocessing import Pool
def calc_2s(i0, R_f, X_init, X_end, Ksu):
Ypre=0
totalsXY=[i0]
for X in range( int(X_init), int(X_end)+1 ):
Y = (X-Ksu[0]) *(X-Ksu[1]) *(X-Ksu[2]) *(X-Ksu[3]) *(X-Ksu[4]) *(X-Ksu[5]) *(X-Ksu[6]) *(X-Ksu[7]) *(X-Ksu[8]) *(X-Ksu[9])*\
(X-Ksu[10]) *(X-Ksu[11]) *(X-Ksu[12]) *(X-Ksu[13]) *(X-Ksu[14]) *(X-Ksu[15]) *(X-Ksu[16]) *(X-Ksu[17]) *(X-Ksu[18]) *(X-Ksu[19])*\
(X-Ksu[20]) *(X-Ksu[21]) *(X-Ksu[22]) *(X-Ksu[23]) *(X-Ksu[24]) *(X-Ksu[25]) *(X-Ksu[26]) *(X-Ksu[27]) *(X-Ksu[28]) *(X-Ksu[29])*\
(X-Ksu[30]) *(X-Ksu[31]) *(X-Ksu[32]) *(X-Ksu[33]) *(X-Ksu[34]) *(X-Ksu[35]) *(X-Ksu[36]) *(X-Ksu[37]) *(X-Ksu[38]) *(X-Ksu[39])*\
(X-Ksu[40]) *(X-Ksu[41]) *(X-Ksu[42]) *(X-Ksu[43]) *(X-Ksu[44]) *(X-Ksu[45]) *(X-Ksu[46]) *(X-Ksu[47]) *(X-Ksu[48]) *(X-Ksu[49])*\
(X-Ksu[50]) *(X-Ksu[51]) *(X-Ksu[52]) *(X-Ksu[53]) *(X-Ksu[54]) *(X-Ksu[55]) *(X-Ksu[56]) *(X-Ksu[57]) *(X-Ksu[58]) *(X-Ksu[59])*\
(X-Ksu[60]) *(X-Ksu[61]) *(X-Ksu[62]) *(X-Ksu[63]) *(X-Ksu[64]) *(X-Ksu[65]) *(X-Ksu[66]) *(X-Ksu[67]) *(X-Ksu[68]) *(X-Ksu[69])*\
(X-Ksu[70]) *(X-Ksu[71]) *(X-Ksu[72]) *(X-Ksu[73]) *(X-Ksu[74]) *(X-Ksu[75]) *(X-Ksu[76]) *(X-Ksu[77]) *(X-Ksu[78]) *(X-Ksu[79])*\
(X-Ksu[80]) *(X-Ksu[81]) *(X-Ksu[82]) *(X-Ksu[83]) *(X-Ksu[84]) *(X-Ksu[85]) *(X-Ksu[86]) *(X-Ksu[87]) *(X-Ksu[88]) *(X-Ksu[89])*\
(X-Ksu[90]) *(X-Ksu[91]) *(X-Ksu[92]) *(X-Ksu[93]) *(X-Ksu[94]) *(X-Ksu[95]) *(X-Ksu[96]) *(X-Ksu[97]) *(X-Ksu[98]) *(X-Ksu[99])*\
(X-Ksu[100])*(X-Ksu[101])*(X-Ksu[102])*(X-Ksu[103])*(X-Ksu[104])*(X-Ksu[105])*(X-Ksu[106])*(X-Ksu[107])*(X-Ksu[108])*(X-Ksu[109])*\
(X-Ksu[110])*(X-Ksu[111])*(X-Ksu[112])*(X-Ksu[113])*(X-Ksu[114])*(X-Ksu[115])*(X-Ksu[116])*(X-Ksu[117])*(X-Ksu[118])*(X-Ksu[119])*\
(X-Ksu[120])*(X-Ksu[121])*(X-Ksu[122])*(X-Ksu[123])*(X-Ksu[124])*(X-Ksu[125])*(X-Ksu[126])*(X-Ksu[127])*(X-Ksu[128])*(X-Ksu[129])*\
(X-Ksu[130])*(X-Ksu[131])*(X-Ksu[132])*(X-Ksu[133])*(X-Ksu[134])*(X-Ksu[135])*(X-Ksu[136])*(X-Ksu[137])*(X-Ksu[138])*(X-Ksu[139])*\
(X-Ksu[140])*(X-Ksu[141])*(X-Ksu[142])*(X-Ksu[143])*(X-Ksu[144])*(X-Ksu[145])*(X-Ksu[146])*(X-Ksu[147])*(X-Ksu[148])*(X-Ksu[149])*\
(X-Ksu[150])*(X-Ksu[151])*(X-Ksu[152])*(X-Ksu[153])*(X-Ksu[154])*(X-Ksu[155])*(X-Ksu[156])*(X-Ksu[157])*(X-Ksu[158])*(X-Ksu[159])*\
(X-Ksu[160])*(X-Ksu[161])*(X-Ksu[162])*(X-Ksu[163])*(X-Ksu[164])*(X-Ksu[165])*(X-Ksu[166])*(X-Ksu[167])*(X-Ksu[168])*(X-Ksu[169])*\
(X-Ksu[170])*(X-Ksu[171])*(X-Ksu[172])*(X-Ksu[173])*(X-Ksu[174])*(X-Ksu[175])*(X-Ksu[176])*(X-Ksu[177])*(X-Ksu[178])*(X-Ksu[179])*\
(X-Ksu[180])*(X-Ksu[181])*(X-Ksu[182])*(X-Ksu[183])*(X-Ksu[184])*(X-Ksu[185])*(X-Ksu[186])*(X-Ksu[187])*(X-Ksu[188])*(X-Ksu[189])*\
(X-Ksu[190])*(X-Ksu[191])*(X-Ksu[192])*(X-Ksu[193])*(X-Ksu[194])*(X-Ksu[195])*(X-Ksu[196])*(X-Ksu[197])*(X-Ksu[198])*(X-Ksu[199])*\
(X-Ksu[200])*(X-Ksu[201])*(X-Ksu[202])*(X-Ksu[203])*(X-Ksu[204])*(X-Ksu[205])*(X-Ksu[206])*(X-Ksu[207])*(X-Ksu[208])*(X-Ksu[209])*\
(X-Ksu[210])*(X-Ksu[211])*(X-Ksu[212])*(X-Ksu[213])*(X-Ksu[214])*(X-Ksu[215])*(X-Ksu[216])*(X-Ksu[217])*(X-Ksu[218])*(X-Ksu[219])*\
(X-Ksu[220])*(X-Ksu[221])*(X-Ksu[222])*(X-Ksu[223])*(X-Ksu[224])*(X-Ksu[225])*(X-Ksu[226])*(X-Ksu[227])*(X-Ksu[228])*(X-Ksu[229])*\
(X-Ksu[230])*(X-Ksu[231])*(X-Ksu[232])*(X-Ksu[233])*(X-Ksu[234])*(X-Ksu[235])*(X-Ksu[236])*(X-Ksu[237])*(X-Ksu[238])*(X-Ksu[239])*\
(X-Ksu[240])*(X-Ksu[241])*(X-Ksu[242])*(X-Ksu[243])*(X-Ksu[244])*(X-Ksu[245])*(X-Ksu[246])*(X-Ksu[247])*(X-Ksu[248])*(X-Ksu[249])*\
(X-Ksu[250])*(X-Ksu[251])*(X-Ksu[252])*(X-Ksu[253])*(X-Ksu[254])*(X-Ksu[255])*(X-Ksu[256])*(X-Ksu[257])*(X-Ksu[258])*(X-Ksu[259])*\
(X-Ksu[260])*(X-Ksu[261])*(X-Ksu[262])*(X-Ksu[263])*(X-Ksu[264])*(X-Ksu[265])*(X-Ksu[266])*(X-Ksu[267])*(X-Ksu[268])*(X-Ksu[269])*\
(X-Ksu[270])*(X-Ksu[271])*(X-Ksu[272])*(X-Ksu[273])*(X-Ksu[274])*(X-Ksu[275])*(X-Ksu[276])*(X-Ksu[277])*(X-Ksu[278])*(X-Ksu[279])*\
(X-Ksu[280])*(X-Ksu[281])*(X-Ksu[282])*(X-Ksu[283])*(X-Ksu[284])*(X-Ksu[285])*(X-Ksu[286])*(X-Ksu[287])*(X-Ksu[288])*(X-Ksu[289])*\
(X-Ksu[290])*(X-Ksu[291])*(X-Ksu[292])*(X-Ksu[293])*(X-Ksu[294])*(X-Ksu[295])*(X-Ksu[296])*(X-Ksu[297])*(X-Ksu[298])*(X-Ksu[299])*\
(X-Ksu[300])*(X-Ksu[301])*(X-Ksu[302])*(X-Ksu[303])*(X-Ksu[304])*(X-Ksu[305])*(X-Ksu[306])*(X-Ksu[307])*(X-Ksu[308])*(X-Ksu[309])*\
(X-Ksu[310])*(X-Ksu[311])*(X-Ksu[312])*(X-Ksu[313])*(X-Ksu[314])*(X-Ksu[315])*(X-Ksu[316])*(X-Ksu[317])*(X-Ksu[318])*(X-Ksu[319])*\
(X-Ksu[320])*(X-Ksu[321])*(X-Ksu[322])*(X-Ksu[323])*(X-Ksu[324])*(X-Ksu[325])*(X-Ksu[326])*(X-Ksu[327])*(X-Ksu[328])*(X-Ksu[329])*\
(X-Ksu[330])*(X-Ksu[331])*(X-Ksu[332])*(X-Ksu[333])*(X-Ksu[334])*(X-Ksu[335])*(X-Ksu[336])*(X-Ksu[337])*(X-Ksu[338])*(X-Ksu[339])*\
(X-Ksu[340])*(X-Ksu[341])*(X-Ksu[342])*(X-Ksu[343])*(X-Ksu[344])*(X-Ksu[345])*(X-Ksu[346])*(X-Ksu[347])*(X-Ksu[348])*(X-Ksu[349])*\
(X-Ksu[350])*(X-Ksu[351])*(X-Ksu[352])*(X-Ksu[353])*(X-Ksu[354])*(X-Ksu[355])*(X-Ksu[356])*(X-Ksu[357])*(X-Ksu[358])*(X-Ksu[359])*\
(X-Ksu[360])*(X-Ksu[361])*(X-Ksu[362])*(X-Ksu[363])*(X-Ksu[364])*(X-Ksu[365])*(X-Ksu[366])*(X-Ksu[367])*(X-Ksu[368])*(X-Ksu[369])*\
(X-Ksu[370])*(X-Ksu[371])*(X-Ksu[372])*(X-Ksu[373])*(X-Ksu[374])*(X-Ksu[375])*(X-Ksu[376])*(X-Ksu[377])*(X-Ksu[378])*(X-Ksu[379])*\
(X-Ksu[380])*(X-Ksu[381])*(X-Ksu[382])*(X-Ksu[383])*(X-Ksu[384])*(X-Ksu[385])*(X-Ksu[386])*(X-Ksu[387])*(X-Ksu[388])*(X-Ksu[389])*\
(X-Ksu[390])*(X-Ksu[391])*(X-Ksu[392])*(X-Ksu[393])*(X-Ksu[394])*(X-Ksu[395])*(X-Ksu[396])*(X-Ksu[397])*(X-Ksu[398])*(X-Ksu[399])*\
(X-Ksu[400])*(X-Ksu[401])*(X-Ksu[402])*(X-Ksu[403])*(X-Ksu[404])*(X-Ksu[405])*(X-Ksu[406])*(X-Ksu[407])*(X-Ksu[408])*(X-Ksu[409])*\
(X-Ksu[410])*(X-Ksu[411])*(X-Ksu[412])*(X-Ksu[413])*(X-Ksu[414])*(X-Ksu[415])*(X-Ksu[416])*(X-Ksu[417])*(X-Ksu[418])*(X-Ksu[419])*\
(X-Ksu[420])*(X-Ksu[421])*(X-Ksu[422])*(X-Ksu[423])*(X-Ksu[424])*(X-Ksu[425])*(X-Ksu[426])*(X-Ksu[427])*(X-Ksu[428])*(X-Ksu[429])*\
(X-Ksu[430])*(X-Ksu[431])*(X-Ksu[432])*(X-Ksu[433])*(X-Ksu[434])*(X-Ksu[435])*(X-Ksu[436])*(X-Ksu[437])*(X-Ksu[438])*(X-Ksu[439])*\
(X-Ksu[440])*(X-Ksu[441])*(X-Ksu[442])*(X-Ksu[443])*(X-Ksu[444])*(X-Ksu[445])*(X-Ksu[446])*(X-Ksu[447])*(X-Ksu[448])*(X-Ksu[449])*\
(X-Ksu[450])*(X-Ksu[451])*(X-Ksu[452])*(X-Ksu[453])*(X-Ksu[454])*(X-Ksu[455])*(X-Ksu[456])*(X-Ksu[457])*(X-Ksu[458])*(X-Ksu[459])*\
(X-Ksu[460])*(X-Ksu[461])*(X-Ksu[462])*(X-Ksu[463])*(X-Ksu[464])*(X-Ksu[465])*(X-Ksu[466])*(X-Ksu[467])*(X-Ksu[468])*(X-Ksu[469])*\
(X-Ksu[470])*(X-Ksu[471])*(X-Ksu[472])*(X-Ksu[473])*(X-Ksu[474])*(X-Ksu[475])*(X-Ksu[476])*(X-Ksu[477])*(X-Ksu[478])*(X-Ksu[479])*\
(X-Ksu[480])*(X-Ksu[481])*(X-Ksu[482])*(X-Ksu[483])*(X-Ksu[484])*(X-Ksu[485])*(X-Ksu[486])*(X-Ksu[487])*(X-Ksu[488])*(X-Ksu[489])*\
(X-Ksu[490])*(X-Ksu[491])*(X-Ksu[492])*(X-Ksu[493])*(X-Ksu[494])*(X-Ksu[495])*(X-Ksu[496])*(X-Ksu[497])*(X-Ksu[498])*(X-Ksu[499])*\
(X-Ksu[500])*(X-Ksu[501])*(X-Ksu[502])*(X-Ksu[503])*(X-Ksu[504])*(X-Ksu[505])*(X-Ksu[506])*(X-Ksu[507])*(X-Ksu[508])*(X-Ksu[509])*\
(X-Ksu[510])*(X-Ksu[511])*(X-Ksu[512])*(X-Ksu[513])*(X-Ksu[514])*(X-Ksu[515])*(X-Ksu[516])*(X-Ksu[517])*(X-Ksu[518])*(X-Ksu[519])*\
(X-Ksu[520])*(X-Ksu[521])*(X-Ksu[522])*(X-Ksu[523])*(X-Ksu[524])*(X-Ksu[525])*(X-Ksu[526])*(X-Ksu[527])*(X-Ksu[528])*(X-Ksu[529])*\
(X-Ksu[530])*(X-Ksu[531])*(X-Ksu[532])*(X-Ksu[533])*(X-Ksu[534])*(X-Ksu[535])*(X-Ksu[536])*(X-Ksu[537])*(X-Ksu[538])*(X-Ksu[539])*\
(X-Ksu[540])*(X-Ksu[541])*(X-Ksu[542])*(X-Ksu[543])*(X-Ksu[544])*(X-Ksu[545])*(X-Ksu[546])*(X-Ksu[547])*(X-Ksu[548])*(X-Ksu[549])*\
(X-Ksu[550])*(X-Ksu[551])*(X-Ksu[552])*(X-Ksu[553])*(X-Ksu[554])*(X-Ksu[555])*(X-Ksu[556])*(X-Ksu[557])*(X-Ksu[558])*(X-Ksu[559])*\
(X-Ksu[560])*(X-Ksu[561])*(X-Ksu[562])*(X-Ksu[563])*(X-Ksu[564])*(X-Ksu[565])*(X-Ksu[566])*(X-Ksu[567])*(X-Ksu[568])*(X-Ksu[569])*\
(X-Ksu[570])*(X-Ksu[571])*(X-Ksu[572])*(X-Ksu[573])*(X-Ksu[574])*(X-Ksu[575])*(X-Ksu[576])*(X-Ksu[577])*(X-Ksu[578])*(X-Ksu[579])*\
(X-Ksu[580])*(X-Ksu[581])*(X-Ksu[582])*(X-Ksu[583])*(X-Ksu[584])*(X-Ksu[585])*(X-Ksu[586])*(X-Ksu[587])*(X-Ksu[588])*(X-Ksu[589])*\
(X-Ksu[590])*(X-Ksu[591])*(X-Ksu[592])*(X-Ksu[593])*(X-Ksu[594])*(X-Ksu[595])*(X-Ksu[596])*(X-Ksu[597])*(X-Ksu[598])*(X-Ksu[599])*\
(X-Ksu[600])*(X-Ksu[601])*(X-Ksu[602])*(X-Ksu[603])*(X-Ksu[604])*(X-Ksu[605])*(X-Ksu[606])*(X-Ksu[607])*(X-Ksu[608])*(X-Ksu[609])*\
(X-Ksu[610])*(X-Ksu[611])*(X-Ksu[612])*(X-Ksu[613])*(X-Ksu[614])*(X-Ksu[615])*(X-Ksu[616])*(X-Ksu[617])*(X-Ksu[618])*(X-Ksu[619])*\
(X-Ksu[620])*(X-Ksu[621])*(X-Ksu[622])*(X-Ksu[623])*(X-Ksu[624])*(X-Ksu[625])*(X-Ksu[626])*(X-Ksu[627])*(X-Ksu[628])*(X-Ksu[629])*\
(X-Ksu[630])*(X-Ksu[631])*(X-Ksu[632])*(X-Ksu[633])*(X-Ksu[634])*(X-Ksu[635])*(X-Ksu[636])*(X-Ksu[637])*(X-Ksu[638])*(X-Ksu[639])*\
(X-Ksu[640])*(X-Ksu[641])*(X-Ksu[642])*(X-Ksu[643])*(X-Ksu[644])*(X-Ksu[645])*(X-Ksu[646])*(X-Ksu[647])*(X-Ksu[648])*(X-Ksu[649])*\
(X-Ksu[650])*(X-Ksu[651])*(X-Ksu[652])*(X-Ksu[653])*(X-Ksu[654])*(X-Ksu[655])*(X-Ksu[656])*(X-Ksu[657])*(X-Ksu[658])*(X-Ksu[659])*\
(X-Ksu[660])*(X-Ksu[661])*(X-Ksu[662])*(X-Ksu[663])*(X-Ksu[664])*(X-Ksu[665])*(X-Ksu[666])*(X-Ksu[667])*(X-Ksu[668])*(X-Ksu[669])*\
(X-Ksu[670])*(X-Ksu[671])*(X-Ksu[672])*(X-Ksu[673])*(X-Ksu[674])*(X-Ksu[675])*(X-Ksu[676])*(X-Ksu[677])*(X-Ksu[678])*(X-Ksu[679])*\
(X-Ksu[680])*(X-Ksu[681])*(X-Ksu[682])*(X-Ksu[683])*(X-Ksu[684])*(X-Ksu[685])*(X-Ksu[686])*(X-Ksu[687])*(X-Ksu[688])*(X-Ksu[689])*\
(X-Ksu[690])*(X-Ksu[691])*(X-Ksu[692])*(X-Ksu[693])*(X-Ksu[694])*(X-Ksu[695])*(X-Ksu[696])*(X-Ksu[697])*(X-Ksu[698])*(X-Ksu[699])*\
(X-Ksu[700])*(X-Ksu[701])*(X-Ksu[702])*(X-Ksu[703])*(X-Ksu[704])*(X-Ksu[705])*(X-Ksu[706])*(X-Ksu[707])*(X-Ksu[708])*(X-Ksu[709])*\
(X-Ksu[710])*(X-Ksu[711])*(X-Ksu[712])*(X-Ksu[713])*(X-Ksu[714])*(X-Ksu[715])*(X-Ksu[716])*(X-Ksu[717])*(X-Ksu[718])*(X-Ksu[719])*\
(X-Ksu[720])*(X-Ksu[721])*(X-Ksu[722])*(X-Ksu[723])*(X-Ksu[724])*(X-Ksu[725])*(X-Ksu[726])*(X-Ksu[727])*(X-Ksu[728])*(X-Ksu[729])*\
(X-Ksu[730])*(X-Ksu[731])*(X-Ksu[732])*(X-Ksu[733])*(X-Ksu[734])*(X-Ksu[735])*(X-Ksu[736])*(X-Ksu[737])*(X-Ksu[738])*(X-Ksu[739])*\
(X-Ksu[740])*(X-Ksu[741])*(X-Ksu[742])*(X-Ksu[743])*(X-Ksu[744])*(X-Ksu[745])*(X-Ksu[746])*(X-Ksu[747])*(X-Ksu[748])*(X-Ksu[749])*\
(X-Ksu[750])*(X-Ksu[751])*(X-Ksu[752])*(X-Ksu[753])*(X-Ksu[754])*(X-Ksu[755])*(X-Ksu[756])*(X-Ksu[757])*(X-Ksu[758])*(X-Ksu[759])*\
(X-Ksu[760])*(X-Ksu[761])*(X-Ksu[762])*(X-Ksu[763])*(X-Ksu[764])*(X-Ksu[765])*(X-Ksu[766])*(X-Ksu[767])*(X-Ksu[768])*(X-Ksu[769])*\
(X-Ksu[770])*(X-Ksu[771])*(X-Ksu[772])*(X-Ksu[773])*(X-Ksu[774])*(X-Ksu[775])*(X-Ksu[776])*(X-Ksu[777])*(X-Ksu[778])*(X-Ksu[779])*\
(X-Ksu[780])*(X-Ksu[781])*(X-Ksu[782])*(X-Ksu[783])*(X-Ksu[784])*(X-Ksu[785])*(X-Ksu[786])*(X-Ksu[787])*(X-Ksu[788])*(X-Ksu[789])*\
(X-Ksu[790])*(X-Ksu[791])*(X-Ksu[792])*(X-Ksu[793])*(X-Ksu[794])*(X-Ksu[795])*(X-Ksu[796])*(X-Ksu[797])*(X-Ksu[798])*(X-Ksu[799])*\
(X-Ksu[800])*(X-Ksu[801])*(X-Ksu[802])*(X-Ksu[803])*(X-Ksu[804])*(X-Ksu[805])*(X-Ksu[806])*(X-Ksu[807])*(X-Ksu[808])*(X-Ksu[809])*\
(X-Ksu[810])*(X-Ksu[811])*(X-Ksu[812])*(X-Ksu[813])*(X-Ksu[814])*(X-Ksu[815])*(X-Ksu[816])*(X-Ksu[817])*(X-Ksu[818])*(X-Ksu[819])*\
(X-Ksu[820])*(X-Ksu[821])*(X-Ksu[822])*(X-Ksu[823])*(X-Ksu[824])*(X-Ksu[825])*(X-Ksu[826])*(X-Ksu[827])*(X-Ksu[828])*(X-Ksu[829])*\
(X-Ksu[830])*(X-Ksu[831])*(X-Ksu[832])*(X-Ksu[833])*(X-Ksu[834])*(X-Ksu[835])*(X-Ksu[836])*(X-Ksu[837])*(X-Ksu[838])*(X-Ksu[839])*\
(X-Ksu[840])*(X-Ksu[841])*(X-Ksu[842])*(X-Ksu[843])*(X-Ksu[844])*(X-Ksu[845])*(X-Ksu[846])*(X-Ksu[847])*(X-Ksu[848])*(X-Ksu[849])*\
(X-Ksu[850])*(X-Ksu[851])*(X-Ksu[852])*(X-Ksu[853])*(X-Ksu[854])*(X-Ksu[855])*(X-Ksu[856])*(X-Ksu[857])*(X-Ksu[858])*(X-Ksu[859])*\
(X-Ksu[860])*(X-Ksu[861])*(X-Ksu[862])*(X-Ksu[863])*(X-Ksu[864])*(X-Ksu[865])*(X-Ksu[866])*(X-Ksu[867])*(X-Ksu[868])*(X-Ksu[869])*\
(X-Ksu[870])*(X-Ksu[871])*(X-Ksu[872])*(X-Ksu[873])*(X-Ksu[874])*(X-Ksu[875])*(X-Ksu[876])*(X-Ksu[877])*(X-Ksu[878])*(X-Ksu[879])*\
(X-Ksu[880])*(X-Ksu[881])*(X-Ksu[882])*(X-Ksu[883])*(X-Ksu[884])*(X-Ksu[885])*(X-Ksu[886])*(X-Ksu[887])*(X-Ksu[888])*(X-Ksu[889])*\
(X-Ksu[890])*(X-Ksu[891])*(X-Ksu[892])*(X-Ksu[893])*(X-Ksu[894])*(X-Ksu[895])*(X-Ksu[896])*(X-Ksu[897])*(X-Ksu[898])*(X-Ksu[899])*\
(X-Ksu[900])*(X-Ksu[901])*(X-Ksu[902])*(X-Ksu[903])*(X-Ksu[904])*(X-Ksu[905])*(X-Ksu[906])*(X-Ksu[907])*(X-Ksu[908])*(X-Ksu[909])*\
(X-Ksu[910])*(X-Ksu[911])*(X-Ksu[912])*(X-Ksu[913])*(X-Ksu[914])*(X-Ksu[915])*(X-Ksu[916])*(X-Ksu[917])*(X-Ksu[918])*(X-Ksu[919])*\
(X-Ksu[920])*(X-Ksu[921])*(X-Ksu[922])*(X-Ksu[923])*(X-Ksu[924])*(X-Ksu[925])*(X-Ksu[926])*(X-Ksu[927])*(X-Ksu[928])*(X-Ksu[929])*\
(X-Ksu[930])*(X-Ksu[931])*(X-Ksu[932])*(X-Ksu[933])*(X-Ksu[934])*(X-Ksu[935])*(X-Ksu[936])*(X-Ksu[937])*(X-Ksu[938])*(X-Ksu[939])*\
(X-Ksu[940])*(X-Ksu[941])*(X-Ksu[942])*(X-Ksu[943])*(X-Ksu[944])*(X-Ksu[945])*(X-Ksu[946])*(X-Ksu[947])*(X-Ksu[948])*(X-Ksu[949])*\
(X-Ksu[950])*(X-Ksu[951])*(X-Ksu[952])*(X-Ksu[953])*(X-Ksu[954])*(X-Ksu[955])*(X-Ksu[956])*(X-Ksu[957])*(X-Ksu[958])*(X-Ksu[959])*\
(X-Ksu[960])*(X-Ksu[961])*(X-Ksu[962])*(X-Ksu[963])*(X-Ksu[964])*(X-Ksu[965])*(X-Ksu[966])*(X-Ksu[967])*(X-Ksu[968])*(X-Ksu[969])*\
(X-Ksu[970])*(X-Ksu[971])*(X-Ksu[972])*(X-Ksu[973])*(X-Ksu[974])*(X-Ksu[975])*(X-Ksu[976])*(X-Ksu[977])*(X-Ksu[978])*(X-Ksu[979])*\
(X-Ksu[980])*(X-Ksu[981])*(X-Ksu[982])*(X-Ksu[983])*(X-Ksu[984])*(X-Ksu[985])*(X-Ksu[986])*(X-Ksu[987])*(X-Ksu[988])*(X-Ksu[989])*\
(X-Ksu[990])*(X-Ksu[991])*(X-Ksu[992])*(X-Ksu[993])*(X-Ksu[994])*(X-Ksu[995])*(X-Ksu[996])*(X-Ksu[997])*(X-Ksu[998])*(X-Ksu[999])
if X == int(X_init):
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
Y=Y
totalsXY.append(X)
totalsXY.append(Y)
else:
Ypre=Y
totalsXY.append(X)
totalsXY.append(Y)
return totalsXY
def wrapper_func(args):
return calc_2s(*args)
def multi_processing_pool(Args_Lists):
p = Pool(4)
process_XY = p.map(wrapper_func, Args_Lists)
p.close()
return process_XY
if __name__=="__main__":
#### Input Start ####
xx_Range_from = 0.900
xx_Range_to = 1.100
ksu_init = [0.9500,0.9501,0.9502,0.9503,0.9504,0.9505,0.9506,0.9507,0.9508,0.9509,\
0.9510,0.9511,0.9512,0.9513,0.9514,0.9515,0.9516,0.9517,0.9518,0.9519,\
0.9520,0.9521,0.9522,0.9523,0.9524,0.9525,0.9526,0.9527,0.9528,0.9529,\
0.9530,0.9531,0.9532,0.9533,0.9534,0.9535,0.9536,0.9537,0.9538,0.9539,\
0.9540,0.9541,0.9542,0.9543,0.9544,0.9545,0.9546,0.9547,0.9548,0.9549,\
0.9550,0.9551,0.9552,0.9553,0.9554,0.9555,0.9556,0.9557,0.9558,0.9559,\
0.9560,0.9561,0.9562,0.9563,0.9564,0.9565,0.9566,0.9567,0.9568,0.9569,\
0.9570,0.9571,0.9572,0.9573,0.9574,0.9575,0.9576,0.9577,0.9578,0.9579,\
0.9580,0.9581,0.9582,0.9583,0.9584,0.9585,0.9586,0.9587,0.9588,0.9589,\
0.9590,0.9591,0.9592,0.9593,0.9594,0.9595,0.9596,0.9597,0.9598,0.9599,\
0.9600,0.9601,0.9602,0.9603,0.9604,0.9605,0.9606,0.9607,0.9608,0.9609,\
0.9610,0.9611,0.9612,0.9613,0.9614,0.9615,0.9616,0.9617,0.9618,0.9619,\
0.9620,0.9621,0.9622,0.9623,0.9624,0.9625,0.9626,0.9627,0.9628,0.9629,\
0.9630,0.9631,0.9632,0.9633,0.9634,0.9635,0.9636,0.9637,0.9638,0.9639,\
0.9640,0.9641,0.9642,0.9643,0.9644,0.9645,0.9646,0.9647,0.9648,0.9649,\
0.9650,0.9651,0.9652,0.9653,0.9654,0.9655,0.9656,0.9657,0.9658,0.9659,\
0.9660,0.9661,0.9662,0.9663,0.9664,0.9665,0.9666,0.9667,0.9668,0.9669,\
0.9670,0.9671,0.9672,0.9673,0.9674,0.9675,0.9676,0.9677,0.9678,0.9679,\
0.9680,0.9681,0.9682,0.9683,0.9684,0.9685,0.9686,0.9687,0.9688,0.9689,\
0.9690,0.9691,0.9692,0.9693,0.9694,0.9695,0.9696,0.9697,0.9698,0.9699,\
0.9700,0.9701,0.9702,0.9703,0.9704,0.9705,0.9706,0.9707,0.9708,0.9709,\
0.9710,0.9711,0.9712,0.9713,0.9714,0.9715,0.9716,0.9717,0.9718,0.9719,\
0.9720,0.9721,0.9722,0.9723,0.9724,0.9725,0.9726,0.9727,0.9728,0.9729,\
0.9730,0.9731,0.9732,0.9733,0.9734,0.9735,0.9736,0.9737,0.9738,0.9739,\
0.9740,0.9741,0.9742,0.9743,0.9744,0.9745,0.9746,0.9747,0.9748,0.9749,\
0.9750,0.9751,0.9752,0.9753,0.9754,0.9755,0.9756,0.9757,0.9758,0.9759,\
0.9760,0.9761,0.9762,0.9763,0.9764,0.9765,0.9766,0.9767,0.9768,0.9769,\
0.9770,0.9771,0.9772,0.9773,0.9774,0.9775,0.9776,0.9777,0.9778,0.9779,\
0.9780,0.9781,0.9782,0.9783,0.9784,0.9785,0.9786,0.9787,0.9788,0.9789,\
0.9790,0.9791,0.9792,0.9793,0.9794,0.9795,0.9796,0.9797,0.9798,0.9799,\
0.9800,0.9801,0.9802,0.9803,0.9804,0.9805,0.9806,0.9807,0.9808,0.9809,\
0.9810,0.9811,0.9812,0.9813,0.9814,0.9815,0.9816,0.9817,0.9818,0.9819,\
0.9820,0.9821,0.9822,0.9823,0.9824,0.9825,0.9826,0.9827,0.9828,0.9829,\
0.9830,0.9831,0.9832,0.9833,0.9834,0.9835,0.9836,0.9837,0.9838,0.9839,\
0.9840,0.9841,0.9842,0.9843,0.9844,0.9845,0.9846,0.9847,0.9848,0.9849,\
0.9850,0.9851,0.9852,0.9853,0.9854,0.9855,0.9856,0.9857,0.9858,0.9859,\
0.9860,0.9861,0.9862,0.9863,0.9864,0.9865,0.9866,0.9867,0.9868,0.9869,\
0.9870,0.9871,0.9872,0.9873,0.9874,0.9875,0.9876,0.9877,0.9878,0.9879,\
0.9880,0.9881,0.9882,0.9883,0.9884,0.9885,0.9886,0.9887,0.9888,0.9889,\
0.9890,0.9891,0.9892,0.9893,0.9894,0.9895,0.9896,0.9897,0.9898,0.9899,\
0.9900,0.9901,0.9902,0.9903,0.9904,0.9905,0.9906,0.9907,0.9908,0.9909,\
0.9910,0.9911,0.9912,0.9913,0.9914,0.9915,0.9916,0.9917,0.9918,0.9919,\
0.9920,0.9921,0.9922,0.9923,0.9924,0.9925,0.9926,0.9927,0.9928,0.9929,\
0.9930,0.9931,0.9932,0.9933,0.9934,0.9935,0.9936,0.9937,0.9938,0.9939,\
0.9940,0.9941,0.9942,0.9943,0.9944,0.9945,0.9946,0.9947,0.9948,0.9949,\
0.9950,0.9951,0.9952,0.9953,0.9954,0.9955,0.9956,0.9957,0.9958,0.9959,\
0.9960,0.9961,0.9962,0.9963,0.9964,0.9965,0.9966,0.9967,0.9968,0.9969,\
0.9970,0.9971,0.9972,0.9973,0.9974,0.9975,0.9976,0.9977,0.9978,0.9979,\
0.9980,0.9981,0.9982,0.9983,0.9984,0.9985,0.9986,0.9987,0.9988,0.9989,\
0.9990,0.9991,0.9992,0.9993,0.9994,0.9995,0.9996,0.9997,0.9998,0.9999,\
1.0000,1.0001,1.0002,1.0003,1.0004,1.0005,1.0006,1.0007,1.0008,1.0009,\
1.0010,1.0011,1.0012,1.0013,1.0014,1.0015,1.0016,1.0017,1.0018,1.0019,\
1.0020,1.0021,1.0022,1.0023,1.0024,1.0025,1.0026,1.0027,1.0028,1.0029,\
1.0030,1.0031,1.0032,1.0033,1.0034,1.0035,1.0036,1.0037,1.0038,1.0039,\
1.0040,1.0041,1.0042,1.0043,1.0044,1.0045,1.0046,1.0047,1.0048,1.0049,\
1.0050,1.0051,1.0052,1.0053,1.0054,1.0055,1.0056,1.0057,1.0058,1.0059,\
1.0060,1.0061,1.0062,1.0063,1.0064,1.0065,1.0066,1.0067,1.0068,1.0069,\
1.0070,1.0071,1.0072,1.0073,1.0074,1.0075,1.0076,1.0077,1.0078,1.0079,\
1.0080,1.0081,1.0082,1.0083,1.0084,1.0085,1.0086,1.0087,1.0088,1.0089,\
1.0090,1.0091,1.0092,1.0093,1.0094,1.0095,1.0096,1.0097,1.0098,1.0099,\
1.0100,1.0101,1.0102,1.0103,1.0104,1.0105,1.0106,1.0107,1.0108,1.0109,\
1.0110,1.0111,1.0112,1.0113,1.0114,1.0115,1.0116,1.0117,1.0118,1.0119,\
1.0120,1.0121,1.0122,1.0123,1.0124,1.0125,1.0126,1.0127,1.0128,1.0129,\
1.0130,1.0131,1.0132,1.0133,1.0134,1.0135,1.0136,1.0137,1.0138,1.0139,\
1.0140,1.0141,1.0142,1.0143,1.0144,1.0145,1.0146,1.0147,1.0148,1.0149,\
1.0150,1.0151,1.0152,1.0153,1.0154,1.0155,1.0156,1.0157,1.0158,1.0159,\
1.0160,1.0161,1.0162,1.0163,1.0164,1.0165,1.0166,1.0167,1.0168,1.0169,\
1.0170,1.0171,1.0172,1.0173,1.0174,1.0175,1.0176,1.0177,1.0178,1.0179,\
1.0180,1.0181,1.0182,1.0183,1.0184,1.0185,1.0186,1.0187,1.0188,1.0189,\
1.0190,1.0191,1.0192,1.0193,1.0194,1.0195,1.0196,1.0197,1.0198,1.0199,\
1.0200,1.0201,1.0202,1.0203,1.0204,1.0205,1.0206,1.0207,1.0208,1.0209,\
1.0210,1.0211,1.0212,1.0213,1.0214,1.0215,1.0216,1.0217,1.0218,1.0219,\
1.0220,1.0221,1.0222,1.0223,1.0224,1.0225,1.0226,1.0227,1.0228,1.0229,\
1.0230,1.0231,1.0232,1.0233,1.0234,1.0235,1.0236,1.0237,1.0238,1.0239,\
1.0240,1.0241,1.0242,1.0243,1.0244,1.0245,1.0246,1.0247,1.0248,1.0249,\
1.0250,1.0251,1.0252,1.0253,1.0254,1.0255,1.0256,1.0257,1.0258,1.0259,\
1.0260,1.0261,1.0262,1.0263,1.0264,1.0265,1.0266,1.0267,1.0268,1.0269,\
1.0270,1.0271,1.0272,1.0273,1.0274,1.0275,1.0276,1.0277,1.0278,1.0279,\
1.0280,1.0281,1.0282,1.0283,1.0284,1.0285,1.0286,1.0287,1.0288,1.0289,\
1.0290,1.0291,1.0292,1.0293,1.0294,1.0295,1.0296,1.0297,1.0298,1.0299,\
1.0300,1.0301,1.0302,1.0303,1.0304,1.0305,1.0306,1.0307,1.0308,1.0309,\
1.0310,1.0311,1.0312,1.0313,1.0314,1.0315,1.0316,1.0317,1.0318,1.0319,\
1.0320,1.0321,1.0322,1.0323,1.0324,1.0325,1.0326,1.0327,1.0328,1.0329,\
1.0330,1.0331,1.0332,1.0333,1.0334,1.0335,1.0336,1.0337,1.0338,1.0339,\
1.0340,1.0341,1.0342,1.0343,1.0344,1.0345,1.0346,1.0347,1.0348,1.0349,\
1.0350,1.0351,1.0352,1.0353,1.0354,1.0355,1.0356,1.0357,1.0358,1.0359,\
1.0360,1.0361,1.0362,1.0363,1.0364,1.0365,1.0366,1.0367,1.0368,1.0369,\
1.0370,1.0371,1.0372,1.0373,1.0374,1.0375,1.0376,1.0377,1.0378,1.0379,\
1.0380,1.0381,1.0382,1.0383,1.0384,1.0385,1.0386,1.0387,1.0388,1.0389,\
1.0390,1.0391,1.0392,1.0393,1.0394,1.0395,1.0396,1.0397,1.0398,1.0399,\
1.0400,1.0401,1.0402,1.0403,1.0404,1.0405,1.0406,1.0407,1.0408,1.0409,\
1.0410,1.0411,1.0412,1.0413,1.0414,1.0415,1.0416,1.0417,1.0418,1.0419,\
1.0420,1.0421,1.0422,1.0423,1.0424,1.0425,1.0426,1.0427,1.0428,1.0429,\
1.0430,1.0431,1.0432,1.0433,1.0434,1.0435,1.0436,1.0437,1.0438,1.0439,\
1.0440,1.0441,1.0442,1.0443,1.0444,1.0445,1.0446,1.0447,1.0448,1.0449,\
1.0450,1.0451,1.0452,1.0453,1.0454,1.0455,1.0456,1.0457,1.0458,1.0459,\
1.0460,1.0461,1.0462,1.0463,1.0464,1.0465,1.0466,1.0467,1.0468,1.0469,\
1.0470,1.0471,1.0472,1.0473,1.0474,1.0475,1.0476,1.0477,1.0478,1.0479,\
1.0480,1.0481,1.0482,1.0483,1.0484,1.0485,1.0486,1.0487,1.0488,1.0489,\
1.0490,1.0491,1.0492,1.0493,1.0494,1.0495,1.0496,1.0497,1.0498,1.0499]
r_f = 1000000
ji_suu = 1000
Yaxis_Zoom = 200
#### Input End ####
print(f"Calculation Start")
if r_f==1000000:
print(f" Please wait for 3 minutes and print....")
x_Range_from = int(r_f*xx_Range_from)
x_Range_to = int(r_f*xx_Range_to)
f_range = x_Range_to - x_Range_from
ksu=[]
for i in range(len(ksu_init)):
ksu.append( int(r_f*ksu_init[i]) )
initial_time=time.time()
ArgsLists= [(i,r_f,x_Range_from+i*f_range/4,x_Range_from+(i+1)*f_range/4,ksu) for i in range(4)]
processXY = multi_processing_pool(ArgsLists)
print(f"Calculation Finished")
processXYstr = str(processXY)
processXY.clear()
processXYstr = processXYstr.replace('[[', '')
processXYstr = processXYstr.replace(']]', '')
processesXYstr=processXYstr.split('], [')
process0XYstr=processesXYstr[0]
process1XYstr=processesXYstr[1]
process2XYstr=processesXYstr[2]
process3XYstr=processesXYstr[3]
processesXYstr.clear()
process0sXYstr=process0XYstr.split(', ')
process1sXYstr=process1XYstr.split(', ')
process2sXYstr=process2XYstr.split(', ')
process3sXYstr=process3XYstr.split(', ')
process0XYstr=''
process1XYstr=''
process2XYstr=''
process3XYstr=''
if process0sXYstr[0]=='0' or process0sXYstr[0]=='0.0':
ProcessAA0=process0sXYstr.copy()
elif process1sXYstr[0]=='0' or process1sXYstr[0]=='0.0':
ProcessAA0=process1sXYstr.copy()
elif process2sXYstr[0]=='0' or process2sXYstr[0]=='0.0':
ProcessAA0=process2sXYstr.copy()
elif process3sXYstr[0]=='0' or process3sXYstr[0]=='0.0':
ProcessAA0=process3sXYstr.copy()
if process0sXYstr[0]=='1' or process0sXYstr[0]=='1.0':
ProcessAA1=process0sXYstr.copy()
elif process1sXYstr[0]=='1' or process1sXYstr[0]=='1.0':
ProcessAA1=process1sXYstr.copy()
elif process2sXYstr[0]=='1' or process2sXYstr[0]=='1.0':
ProcessAA1=process2sXYstr.copy()
elif process3sXYstr[0]=='1' or process3sXYstr[0]=='1.0':
ProcessAA1=process3sXYstr.copy()
if process0sXYstr[0]=='2' or process0sXYstr[0]=='2.0':
ProcessAA2=process0sXYstr.copy()
elif process1sXYstr[0]=='2' or process1sXYstr[0]=='2.0':
ProcessAA2=process1sXYstr.copy()
elif process2sXYstr[0]=='2' or process2sXYstr[0]=='2.0':
ProcessAA2=process2sXYstr.copy()
elif process3sXYstr[0]=='2' or process3sXYstr[0]=='2.0':
ProcessAA2=process3sXYstr.copy()
if process0sXYstr[0]=='3' or process0sXYstr[0]=='3.0':
ProcessAA3=process0sXYstr.copy()
elif process1sXYstr[0]=='3' or process1sXYstr[0]=='3.0':
ProcessAA3=process1sXYstr.copy()
elif process2sXYstr[0]=='3' or process2sXYstr[0]=='3.0':
ProcessAA3=process2sXYstr.copy()
elif process3sXYstr[0]=='3' or process3sXYstr[0]=='3.0':
ProcessAA3=process3sXYstr.copy()
process0sXYstr.clear()
process1sXYstr.clear()
process2sXYstr.clear()
process3sXYstr.clear()
ProcessAA0.pop(0)
ProcessAA1.pop(0)
ProcessAA2.pop(0)
ProcessAA3.pop(0)
answersXY=[]
for i in range(int(len(ProcessAA0)/2)):
answersXY.append(( (int(ProcessAA0[2*i])/r_f),\
(int(ProcessAA0[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)),\
int(ProcessAA0[2*i+1]) ))
for i in range(int(len(ProcessAA1)/2)):
answersXY.append(( (int(ProcessAA1[2*i])/r_f),\
(int(ProcessAA1[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)),\
int(ProcessAA1[2*i+1]) ))
for i in range(int(len(ProcessAA2)/2)):
answersXY.append(( (int(ProcessAA2[2*i])/r_f),\
(int(ProcessAA2[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)),\
int(ProcessAA2[2*i+1]) ))
for i in range(int(len(ProcessAA3)/2)):
answersXY.append(( (int(ProcessAA3[2*i])/r_f),\
(int(ProcessAA3[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)),\
int(ProcessAA3[2*i+1]) ))
print(f"Time :")
print(str(time.time() - initial_time))
print(f"Answers :")
for i in range(len(answersXY)):
print(answersXY[i])
time.sleep(10)
最後に桁数を戻す時に、Yaxis_Zoomという変数で桁数調整して、Y軸をズームアップして、y値を確認しています。しかしYaxis_Zoomを200よりさらに大きくズームアップすると、倍精度浮動小数点の指数部300桁を振り切れます。この最後の徐算の商の浮動小数点表示が少し難しいです。
#10000次方程式
最後に10000次方程式を整数型で解くプログラムです。これも今回追加したものです。1GB前後のメモリーを使います。Raspberry Pi 4Bのメモリー2GBの機種でも動きました。Thonnyで45分かかります。64bit 0Sベータ版だと半分くらいに早くなるかもしれません。フル稼働しますからCPUを冷却してください。
import time
from multiprocessing import Pool
def calc_2s(i0, R_f, X_init, X_end, Ksu):
Ypre=0
totalsXY=[i0]
for X in range( int(X_init), int(X_end)+1 ):
Y0=1
for j in range( 0, 1000):
Y0 *= (X-Ksu[j])
Y1=1
for j in range(1000, 2000):
Y1 *= (X-Ksu[j])
Y2=1
for j in range(2000, 3000):
Y2 *= (X-Ksu[j])
Y3=1
for j in range(3000, 4000):
Y3 *= (X-Ksu[j])
Y4=1
for j in range(4000, 5000):
Y4 *= (X-Ksu[j])
Y5=1
for j in range(5000, 6000):
Y5 *= (X-Ksu[j])
Y6=1
for j in range(6000, 7000):
Y6 *= (X-Ksu[j])
Y7=1
for j in range(7000, 8000):
Y7 *= (X-Ksu[j])
Y8=1
for j in range(8000, 9000):
Y8 *= (X-Ksu[j])
Y9=1
for j in range(9000, 10000):
Y9 *= (X-Ksu[j])
Y = Y0 * Y1 * Y2 * Y3 * Y4 * Y5 * Y6 * Y7 * Y8 * Y9
if X == int(X_init):
Ypre=Y
if Ypre * Y > 0:
Ypre=Y
else:
if Y == 0.0:
Y=Y
totalsXY.append(X)
totalsXY.append(Y)
else:
Ypre=Y
totalsXY.append(X)
totalsXY.append(Y)
return totalsXY
def wrapper_func(args):
return calc_2s(*args)
def multi_processing_pool(Args_Lists):
p = Pool(4)
process_XY = p.map(wrapper_func, Args_Lists)
p.close()
return process_XY
if __name__=="__main__":
#### Input Start ####
xx_Range_from = 0.940
xx_Range_to = 1.060
ksu_init = []
ksu_temp = 0.94999
for i in range(10000):
ksu_temp += 0.00001
ksu_init.append(ksu_temp)
r_f = 200000
ji_suu = 10000
Yaxis_Zoom = 2500
#### Input End ####
print(f"Calculation Start")
if r_f==200000:
print(f" Please wait for 5 minites.")
x_Range_from = int(r_f*xx_Range_from)
x_Range_to = int(r_f*xx_Range_to)
f_range = x_Range_to - x_Range_from
ksu=[]
for i in range(len(ksu_init)):
ksu.append( int(r_f*ksu_init[i]) )
initial_time=time.time()
ArgsLists= [(i,r_f,x_Range_from+i*f_range/4,x_Range_from+(i+1)*f_range/4,ksu) for i in range(4)]
processXY = multi_processing_pool(ArgsLists)
print(f"Calculation Finished")
print(f" Please wait for more 40 minutes to print....")
processXYstr = str(processXY)
processXY.clear()
processXYstr = processXYstr.replace('[[', '')
processXYstr = processXYstr.replace(']]', '')
processesXYstr=processXYstr.split('], [')
process0XYstr=processesXYstr[0]
process1XYstr=processesXYstr[1]
process2XYstr=processesXYstr[2]
process3XYstr=processesXYstr[3]
processesXYstr.clear()
process0sXYstr=process0XYstr.split(', ')
process1sXYstr=process1XYstr.split(', ')
process2sXYstr=process2XYstr.split(', ')
process3sXYstr=process3XYstr.split(', ')
process0XYstr=''
process1XYstr=''
process2XYstr=''
process3XYstr=''
if process0sXYstr[0]=='0' or process0sXYstr[0]=='0.0':
ProcessAA0=process0sXYstr.copy()
elif process1sXYstr[0]=='0' or process1sXYstr[0]=='0.0':
ProcessAA0=process1sXYstr.copy()
elif process2sXYstr[0]=='0' or process2sXYstr[0]=='0.0':
ProcessAA0=process2sXYstr.copy()
elif process3sXYstr[0]=='0' or process3sXYstr[0]=='0.0':
ProcessAA0=process3sXYstr.copy()
if process0sXYstr[0]=='1' or process0sXYstr[0]=='1.0':
ProcessAA1=process0sXYstr.copy()
elif process1sXYstr[0]=='1' or process1sXYstr[0]=='1.0':
ProcessAA1=process1sXYstr.copy()
elif process2sXYstr[0]=='1' or process2sXYstr[0]=='1.0':
ProcessAA1=process2sXYstr.copy()
elif process3sXYstr[0]=='1' or process3sXYstr[0]=='1.0':
ProcessAA1=process3sXYstr.copy()
if process0sXYstr[0]=='2' or process0sXYstr[0]=='2.0':
ProcessAA2=process0sXYstr.copy()
elif process1sXYstr[0]=='2' or process1sXYstr[0]=='2.0':
ProcessAA2=process1sXYstr.copy()
elif process2sXYstr[0]=='2' or process2sXYstr[0]=='2.0':
ProcessAA2=process2sXYstr.copy()
elif process3sXYstr[0]=='2' or process3sXYstr[0]=='2.0':
ProcessAA2=process3sXYstr.copy()
if process0sXYstr[0]=='3' or process0sXYstr[0]=='3.0':
ProcessAA3=process0sXYstr.copy()
elif process1sXYstr[0]=='3' or process1sXYstr[0]=='3.0':
ProcessAA3=process1sXYstr.copy()
elif process2sXYstr[0]=='3' or process2sXYstr[0]=='3.0':
ProcessAA3=process2sXYstr.copy()
elif process3sXYstr[0]=='3' or process3sXYstr[0]=='3.0':
ProcessAA3=process3sXYstr.copy()
process0sXYstr.clear()
process1sXYstr.clear()
process2sXYstr.clear()
process3sXYstr.clear()
ProcessAA0.pop(0)
ProcessAA1.pop(0)
ProcessAA2.pop(0)
ProcessAA3.pop(0)
answersXY=[]
for i in range(int(len(ProcessAA0)/2)):
answersXY.append(( (int(ProcessAA0[2*i])/r_f),\
(int(ProcessAA0[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA1)/2)):
answersXY.append(( (int(ProcessAA1[2*i])/r_f),\
(int(ProcessAA1[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA2)/2)):
answersXY.append(( (int(ProcessAA2[2*i])/r_f),\
(int(ProcessAA2[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
for i in range(int(len(ProcessAA3)/2)):
answersXY.append(( (int(ProcessAA3[2*i])/r_f),\
(int(ProcessAA3[2*i+1]))/(r_f**(ji_suu-Yaxis_Zoom)) ))
print(f"Time :")
print(str(time.time() - initial_time))
print(f"Answers :")
for i in range(len(answersXY)):
print(answersXY[i])
time.sleep(10)
最後までご覧いただき、ありがとうございました。
今回はQiitaの主旨に同意して投稿していますので、公開したプログラムはコピー、改変などでのご使用は自由です。著作権に関する問題も発生しません。
ただし、Raspberry Pi 4Bを使う場合にはCPUに特に大きめのヒートシンクが必須です。LAN通信の頻度の少ない今回のプログラムのような場合、LANチップは熱くなりません。しかし計算時間が継続するとCPUの激しい発熱で分かるように相当電力を使っています。電源USB Cタイプの後ろにある黒い小さなチップも熱くなりますので、ファンでの風流も必要です。