尝试解决一组指数方程,但不断收到错误,指出"无法转换浮点数#34;或"浮动不可调用"
您可以运行代码,只需将变量替换为您喜欢的任何值。
from sympy.abc import x, y
import numpy as np
import sympy as sp
import math
A0 = 58
G0 = 44
Gmax = 117
tmax = 40
s=[((sp.log(x) - sp.log(y)) - (tmax*(x-y))), (Gmax- G0 - (A0 * x /(y-x))*((sp.exp((-x)*tmax)) - (sp.exp((-y)*tmax))))]
sp.solve(s, x, y)
答案 0 :(得分:1)
删除数学并使用sympy for log和exp
from sympy.abc import x, y
import numpy as np
import sympy as sp
Gmax = np.amax(all_training_df.iloc[1])
tmax = np.argmax(all_training_df.iloc[1])
A0 = all_combined_df.iloc[1]['CHO (g)']
G0 = all_combined_df.iloc[1]['mg/dL']
s=[((sp.log(x) - sp.log(y)) - (tmax*(x-y))), (Gmax- G0 - (A0 * x /(y-x))*((sp.exp((-x)*tmax)) - (sp.exp((-y)*tmax))))]
sp.solve_poly_system(s, x, y)