Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow using ia_solve without Nemo #1355

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/solver/ia_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ function isolate(lhs, var; warns=true, conditions=[], complex_roots = true, peri
roots = []
new_var = gensym()
new_var = (@variables $new_var)[1]
lhs_roots = solve_univar(lhs - new_var, var)
if Base.get_extension(Symbolics, :SymbolicsNemoExt) !== nothing
lhs_roots = solve_univar(lhs - new_var, var)
else
a, b, islin = linear_expansion(lhs - new_var, var)
if islin
lhs_roots = [-b / a]
else
lhs_roots = [RootsOf(lhs - new_var, var)]
if warns
@warn "Nemo is required to properly solve this expression. Execute `using Nemo` to enable this functionality."
end
end
end

for i in eachindex(lhs_roots)
for j in eachindex(rhs)
Expand Down
10 changes: 10 additions & 0 deletions test/solver.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
using Symbolics
import Symbolics: ssqrt, slog, scbrt, symbolic_solve, ia_solve, postprocess_root

@testset "ia_solve without Nemo" begin
@test Base.get_extension(Symbolics, :SymbolicsNemoExt) === nothing
@variables x
roots = ia_solve(log(2 + x), x)
@test substitute(roots[1], Dict()) == -1.0
roots = @test_warn ["Nemo", "required"] ia_solve(log(2 + x^2), x)
@test operation(roots[1]) == Symbolics.RootsOf
end

using Groebner, Nemo
E = Base.MathConstants.e

Expand Down
Loading