it fixes the issue I am currently developping a python program to tranform a symbolic expression computed by sympy into a numpy array containing all the numerical values. I instantiate the symbolic expression with the sympy.lambdify function. , I can reproduce your error. Based on these inputs: code :
m = Symbol('m')
expr = 1.06048319593874*((3.14159265358979*m*besselj(27.9937791601866*m, 4.46681007624482*sqrt(I))  0.501286290793831*sqrt(I)*besselj(27.9937791601866*m + 1, 4.46681007624482*sqrt(I)))*bessely(27.9937791601866*m, 6.81776274795262*sqrt(I))/(3.14159265358979*m*bessely(27.9937791601866*m, 4.46681007624482*sqrt(I))  0.501286290793831*sqrt(I)*bessely(27.9937791601866*m + 1, 4.46681007624482*sqrt(I))) + besselj(27.9937791601866*m, 6.81776274795262*sqrt(I)))*sin(0.942966379693359*m)*cos(1.5707963267949*m)/m
nm = 2
bessel = {'besselj': jv,'besselk':kv,'besseli':iv,'bessely':yv}
libraries = [bessel, "numpy"]
vm = np.arange(nm, dtype=np.int) +1
result = lambdify(m, expr, modules=libraries)(vm)
vm = np.arange(nm, dtype=np.complex) +1
result = lambdify(m, expr, modules=libraries)(vm)
TypeError Traceback (most recent call last)
<ipythoninput30f0e31009275a> in <module>()
1 vm = np.arange(nm, dtype=np.complex) +1
> 2 result = lambdify(m, expr, modules=libraries)(vm)
/Users/mike/anaconda/envs/py34/lib/python3.4/sitepackages/numpy/__init__.py in <lambda>(_Dummy_27)
TypeError: ufunc 'jv' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
result = lambdify(m, expr, modules=libraries).(vm.real)
Share :

How to lambdify elliptic functions in sympy
By : Jared
Date : March 29 2020, 07:55 AM
around this issue I want to use the elliptic function embedded in the sympy library, but something is wrong when I try to lambdify elliptic(f(z)), where f is a symbolic function: , sympy.functions.elliptic_k perhaps?

Error with sympy.lambdify for piecewise functions and numpy module
By : Vjmsilva
Date : March 29 2020, 07:55 AM
I wish this helpful for you I deleted my other answer (in case you already saw it). There is a much simpler solution. The ZeroDivisionError comes because the lambdified expression produces, roughly, lambda x, y: select([less(y, 1),less_equal(y, 1),True], [1/x,x,1/x], default=nan). The problem is that passing in x = 0 results in 1/0 being evaluated by Python, which raises the error. code :
f_numpy(0, 1)
f_numpy(array(0), array(1))

lambdify expressions with native sympy functions
By : Andreas Mitrousis
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You should specify modules you want to use with modules argument of the lambdify function: code :
f = sympy.lambdify(t, sympy.exp(t), modules=["sympy"])

sympy lambdify add two functions
By : VikingTiger
Date : November 08 2020, 03:01 PM
wish helps you I have two functions created with sympy's lamdify code :
c = lambda x, y: a(x, y) + b(x,y)
var('x y')
expr1 = x + y
a = lambdify((x, y), expr1)
expr2 = x/y
b = lambdify((x, y), expr2)
c = lambdify((x, y), expr1 + expr2)

Why does the lambdify function from sympy throw an error in my case?
By : Simon
Date : March 29 2020, 07:55 AM
wish helps you AFAIU your cunning plan is to first use Python interpreter to build a function from user's string (using input) and then to use SymPy to build a reusable function from that. There are a few problems with your code, the most important probably is that you get signature of SymPy methods wrong. Also idea of providing dfdx as input doesn't look good to me. If the original function f has a good derivative that you can calculate, SymPy can probably calculate it on its own. code :
import sympy
import sys
v0 = int(input("Please enter the v0 value: "))
eps = float(input("Please enter the tolerance: "))
f_inp = lambda x: eval(input("Enter the function: "))
x = sympy.symbols('x')
f_symb = f_inp(x)
func = sympy.lambdify(x, f_symb)
deriv = sympy.lambdify(x, sympy.diff(f_symb, x))
def Newton(func, deriv, v0, eps):
f_value = func(v0)
iteration_counter = 0
while abs(f_value) > eps and iteration_counter < 100:
try:
v0 = v0  float(f_value) / deriv(v0)
except ZeroDivisionError:
print ("Error!  derivative zero for x = ", v0)
sys.exit(1) # Abort with error
f_value = func(v0)
iteration_counter += 1
# Here, either a solution is found, or too many iterations
if abs(f_value) > eps:
iteration_counter = 1
return v0, iteration_counter
print (Newton(func, deriv, v0, eps))
import sympy
import sys
v0 = int(input("Please enter the v0 value: "))
eps = float(input("Please enter the tolerance: "))
f_inp = lambda x: input("Enter the function: ")
x = sympy.symbols('x')
f_symb = f_inp(x)
func = sympy.lambdify(x, f_symb)
deriv = sympy.lambdify(x, sympy.diff(f_symb, x))
def Newton(func, deriv, v0, eps):
f_value = func(v0)
iteration_counter = 0
while abs(f_value) > eps and iteration_counter < 100:
try:
v0 = v0  float(f_value) / deriv(v0)
except ZeroDivisionError:
print ("Error!  derivative zero for x = ", v0)
sys.exit(1) # Abort with error
f_value = func(v0)
iteration_counter += 1
# Here, either a solution is found, or too many iterations
if abs(f_value) > eps:
iteration_counter = 1
return v0, iteration_counter
print Newton(func, deriv, v0, eps)
1
0.000001
x**3 + 3*x + 5

