請問用Fslove中要解近似值~
其中的
1,1,3,3,5,5
-10,-19,-26,-41,42,-63
這些想改成可以由外部傳遞進去
要怎麼傳才好Orz 感謝
一樣是求a,b,c,d,e,f
from scipy.optimize import fsolve
def f(x):
a = float(x[0])
print(x[0])
b = float(x[1])
c = float(x[2])
d = float(x[3])
e = float(x[4])
f = float(x[5])
return [
1*a+1*b+c-10,
1*d+1*e+f-19,
3*a+3*b+c-26,
3*d+3*e+f-41,
5*a+5*b+c-42,
5*d+5*e+f-63
]
result = fsolve(f, [0,0,0,0,0,0])