I need to solve an equation numerically (solution must depend on k∈⟨0,1)). Every time I use a function that returns expression or use lambda to define function it returns similar error. Now I tried using lambdify to translate a SymPy expression into an equivalent numeric function, but same error is returned.
from scipy import *
import sympy as sym
init_printing()
x,k=symbols("x,k")
f=(sym.log(x)/sym.log(k))**k-x**(1/sym.atanh(k))
a=lambdify([x,k], f, "scipy")
(a([0,1]))
TypeError Traceback (most recent call last)
<ipython-input-29-04519472dd5e> in <module>
7
8 a=lambdify([x,k], f, "scipy")
----> 9 print(a([0,1]))
TypeError: _lambdifygenerated() missing 1 required positional argument: 'k'
Call with a(0,1)
, not a([0,1])
. If you want to use a list as the argument, you can use a nested variable list like this: a=lambdify([(x,k)], f, "scipy")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With