0

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)
Salchem
  • 118
  • 1
  • 2
  • 11
  • Possible duplicate of [error with python sympy computing integral for cosine function](https://stackoverflow.com/questions/18267470/error-with-python-sympy-computing-integral-for-cosine-function) – pacholik Oct 30 '17 at 08:52
  • @Salchem Please provide a Minimum Working Example (MWE), so that the code you have posted can work on anybodies system. For instance, I cannot run `all_training_df` nor `solve_poly_system`. I do not know where those objects come from. – ThomasGuenet Oct 30 '17 at 08:59
  • Ok, see above, I replaced them – Salchem Oct 30 '17 at 17:23
  • I get the following error: could not solve -73*(y + LambertW(-40*y*exp(-40*y))/40)*exp(40*y)*exp(-LambertW(-40*y*exp(-40*y))) - 29*(exp(40*y) - exp(-LambertW(-40*y*exp(-40*y))))*LambertW(-40*y*exp(-40*y))/20 – Salchem Oct 30 '17 at 17:28

1 Answers1

1

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)
Smart Manoj
  • 5,230
  • 4
  • 34
  • 59