When using Symbolics.build_function to generate a numerically usable Julia function from a symbolic function, the resulting function is very slow and raises a stack overflow error when calling it. The following example reproduces the error:
using Symbolics
N = 100 # for N=10, no error.
@variables xarray[1:N]
funexpr = xarray.^2 # example vector-valued function of length N
jacobianfun = eval(Symbolics.build_function(Symbolics.jacobian(funexpr, xarray), xarray)[1]) # build function from symbolic expression
xvalue = ones(N)
jacobianfun(xvalue) # raises overflow error
generating the error
Internal error: stack overflow in type inference of #29(Array{Float64, 1}).
This might be caused by recursion over very long tuples or argument lists.
This limits the usage of symbolics to efficiently generate functions from symbolic expressions.
When using
Symbolics.build_function
to generate a numerically usable Julia function from a symbolic function, the resulting function is very slow and raises a stack overflow error when calling it. The following example reproduces the error:generating the error
This limits the usage of symbolics to efficiently generate functions from symbolic expressions.