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
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
feat: allow using ia_solve without Nemo
  • Loading branch information
AayushSabharwal committed Nov 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit fb103072e12e6e81464b376a7a05bc0e69a4d75d
14 changes: 13 additions & 1 deletion src/solver/ia_main.jl
Original file line number Diff line number Diff line change
@@ -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)
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

Loading