Symbolics.jl
Symbolics.jl copied to clipboard
undocumented exported functions `solve_single_eq` and `solve_system_eq`
I notice that Symbolics defines and exports two functions, solve_single_eq and solve_system_eq. Even though they are exported, they are not documented. That said, the function signatures are somewhat self-explanatory.
Are they supposed to be exposed to external users? Otherwise they probably shouldn't be exported?
Furthermore, I wonder what is the relation of these two functions with Symbolics.solve_for supposed to be, because they seem to provide roughly similar functionality? The latter function is documented, but not exported.
FTR, solve_single_eq is useful:
julia> solve_single_eq((x^3) ~ false, x)
x ~ 0^(1//3)
julia> simplify(ans)
x ~ 0.0
However, it's not foolproof:
julia> solve_single_eq((x^2) ~ false, x)
ERROR: MethodError: no method matching occursin(::Num, ::Int64)
Closest candidates are:
occursin(::SymbolicUtils.Symbolic, ::Any)
@ SymbolicUtils ~/.julia/packages/SymbolicUtils/Oyu8Z/src/substitute.jl:52
occursin(::Any, ::SymbolicUtils.Symbolic)
@ SymbolicUtils ~/.julia/packages/SymbolicUtils/Oyu8Z/src/substitute.jl:51
occursin(::Any)
@ Base strings/search.jl:724
Stacktrace:
[1] _occursin(needle::Num, haystack::SymbolicUtils.BasicSymbolic{Rational{Int64}})
@ SymbolicUtils ~/.julia/packages/SymbolicUtils/Oyu8Z/src/substitute.jl:59
[2] move_to_other_side(eq::Equation, var::Num)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:379
[3] solve_single_eq_unchecked(eq::Equation, var::Num, single_solution::Bool)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:287
[4] solve_single_eq(eq::Equation, var::Num, single_solution::Bool, verify::Bool)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:17
[5] reverse_powers(eq::Equation, var::Num, single_solution::Bool)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:629
[6] solve_single_eq_unchecked(eq::Equation, var::Num, single_solution::Bool)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:301
[7] solve_single_eq(eq::Equation, var::Num, single_solution::Bool, verify::Bool)
@ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/solver.jl:17
[8] top-level scope
solve_system_eq doesn't have the same bug as solve_single_eq:
julia> solve_system_eq([(x^2) ~ false], [x])
Dict{Any, Any} with 1 entry:
x => 0.0
It, however, doesn't find all possible solutions:
julia> solve_system_eq([(x^2) ~ true], [x])
Dict{Any, Any} with 1 entry:
x => 1
@YingboMa we should not export this.