Skip to content

Commit 7fba695

Browse files
author
Karl Wessel
committed
2 parents 89ac04e + 195c95d commit 7fba695

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/solver/ia_main.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ function isolate(lhs, var; warns=true, conditions=[], complex_roots = true, peri
1515
roots = []
1616
new_var = gensym()
1717
new_var = (@variables $new_var)[1]
18-
lhs_roots = solve_univar(lhs - new_var, var)
18+
if Base.get_extension(Symbolics, :SymbolicsNemoExt) !== nothing
19+
lhs_roots = solve_univar(lhs - new_var, var)
20+
else
21+
a, b, islin = linear_expansion(lhs - new_var, var)
22+
if islin
23+
lhs_roots = [-b / a]
24+
else
25+
lhs_roots = [RootsOf(lhs - new_var, var)]
26+
if warns
27+
@warn "Nemo is required to properly solve this expression. Execute `using Nemo` to enable this functionality."
28+
end
29+
end
30+
end
1931

2032
for i in eachindex(lhs_roots)
2133
for j in eachindex(rhs)

test/solver.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
using Symbolics
22
import Symbolics: ssqrt, slog, scbrt, symbolic_solve, ia_solve, postprocess_root
3+
4+
@testset "ia_solve without Nemo" begin
5+
@test Base.get_extension(Symbolics, :SymbolicsNemoExt) === nothing
6+
@variables x
7+
roots = ia_solve(log(2 + x), x)
8+
@test substitute(roots[1], Dict()) == -1.0
9+
roots = @test_warn ["Nemo", "required"] ia_solve(log(2 + x^2), x)
10+
@test operation(roots[1]) == Symbolics.RootsOf
11+
end
12+
313
using Groebner, Nemo
414
E = Base.MathConstants.e
515

0 commit comments

Comments
 (0)