Solving set of exponential equations in python

2k Views Asked by At

Trying to solve a set of exponential equations but keep getting errors saying that "can't convert float" or "float is not callable"

You may run the code, just replace the variables with any values you'd like.

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)
1

There are 1 best solutions below

1
Smart Manoj On

remove the math and use sympy for log and 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)