Symbolics.jl
Symbolics.jl copied to clipboard
Could `Base.rationalize` be made to work on symbolic expression?
reference https://discourse.julialang.org/t/how-to-use-base-rationalize-on-whole-symbolic-expression/86748
Using 1.8
Base.rationalize(expr)
gives an error on symbolic expression
using Symbolics
@syms x
expr=(0.014378665475956662 - 0.0645731363698366im)*((72 + 132x + 2262(x^4) + 6743(x^5) - 754(x^2) - 234(x^6) - 1641(x^3) - 9180(x^7) - 5400(x^8))^-1) + (-0.0995313498923154 + 0.07922575111068406im)*x*((72 + 132x + 2262(x^4) + 6743(x^5) - 754(x^2) - 234(x^6) - 1641(x^3) - 9180(x^7) - 5400(x^8))^-1)
Base.rationalize(expr)
gives
ERROR: MethodError: no method matching rationalize(::SymbolicUtils.Add{Number, Int64, Dict{Any, Number}, Nothing})
Closest candidates are:
rationalize(::Type{T}, ::AbstractFloat; tol) where T<:Integer at rational.jl:217
rationalize(::Type{T}, ::AbstractFloat, ::Real) where T<:Integer at rational.jl:157
rationalize(::AbstractFloat; kvs...) at rational.jl:218
...
Stacktrace:
[1] top-level scope
@ REPL[16]:1
Could Base.rationalize
be made to work on whole symbolic expression?