I have created a symbolic expression using the SymPy package (https://github.com/jverzani/SymPy.jl). I want to now find the roots of that expression using the Roots package (https://github.com/JuliaLang/Roots.jl). However, I cannot figure out how to use the fzeros
method for finding the roots, since this can only be applied on an object with the type Function
rather than Sym
, which is the type of my expression.
Here's an example of what I'm trying to do. I create a symbolic "x"
and a symbolic expression sin(x)
. Now lets try to find the zeros of sin(x)
between the values -10 and 10:
using SymPy
x = sym"x"
expr = sin(x)
using Roots
fzeros(expr,-10,10)
Here's the error:
ERROR: `fzeros` has no method matching fzeros(::Sym, ::Int64, ::Int64)
How do I convert an expression with Sym
type to Function
type, so I can find the roots?