Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

mpmath not working with sage equations

I'm trying to get a numerical solution to a problem similar to the one discussed in this old post but somewhat messier -- there are decimals and the variables to solve for are in an exponent. I ran the example given in the old post, with som syntactical updating and using import mpmath as mp and everything works exactly as shown. But when I switch to my problem, I get a "TypeError: cannot evaluate symbolic expression numerically" error. What's the difference between the two cases and what should I do? I've tried changing ^ to ** and restarting the kernel.

Here's my code:

import mpmath as mp


eq0 = 101/4563863823**(32.4*Vmax/Km) - 71.85 == 0
eq1 = 96.3/85080567**(2.4*Vmax/Km) - 74.25 == 0

f = [lambda Vmax,Km: eq0.lhs().subs(Vmax=RR(Vmax), Km=RR(Km)),
 lambda Vmax,Km: eq1.lhs().subs(Vmax=RR(Vmax), b=RR(Km))]

found_root = mp.findroot(f, (2, 2))
found_root = Matrix(RR, found_root.tolist())

fa,fb = found_root.list()

#Check results