@@ -5,7 +5,6 @@ import Symbolics: ssqrt, slog, scbrt, symbolic_solve, ia_solve, postprocess_root
55 @test Base. get_extension (Symbolics, :SymbolicsNemoExt ) === nothing
66 @variables x
77 roots = ia_solve (log (2 + x), x)
8- @test substitute (roots[1 ], Dict ()) == - 1.0
98 roots = @test_warn [" Nemo" , " required" ] ia_solve (log (2 + x^ 2 ), x)
109 @test operation (roots[1 ]) == Symbolics. RootsOf
1110end
6968@testset " Solving in terms of a constant var" begin
7069 eq = ((s^ 2 + 1 )/ (s^ 2 + 2 * s + 1 )) - ((s^ 2 + a)/ (b* c* s^ 2 + (b+ c)* s + d))
7170 calcd_roots = sort_arr (Symbolics. solve_interms_ofvar (eq, s), [a,b,c,d])
71+ solve_roots = sort_arr (symbolic_solve (eq, [a,b,c,d]), [a,b,c,d])
7272 known_roots = sort_arr ([Dict (a=> 1 , b=> 1 , c=> 1 , d=> 1 )], [a,b,c,d])
7373 @test check_approx (calcd_roots, known_roots)
74+ @test check_approx (solve_roots, known_roots)
7475
7576 eq = (a+ b)* s^ 2 - 2 s^ 2 + 2 * b* s - 3 * s
7677 calcd_roots = sort_arr (Symbolics. solve_interms_ofvar (eq, s), [a,b])
78+ solve_roots = sort_arr (symbolic_solve (eq, [a,b]), [a,b])
7779 known_roots = sort_arr ([Dict (a=> 1 / 2 , b=> 3 / 2 )], [a,b])
7880 @test check_approx (calcd_roots, known_roots)
81+ @test check_approx (solve_roots, known_roots)
7982
8083 eq = (a* x^ 2 + b)* s^ 2 - 2 s^ 2 + 2 * b* s - 3 * s + 2 (x^ 2 )* (s^ 3 ) + 10 * s^ 3
81- calcd_roots = sort_arr (Symbolics. solve_interms_ofvar (eq, s), [a,b])
84+ calcd_roots = sort_arr (Symbolics. solve_interms_ofvar (eq, s), [a,b,x])
85+ solve_roots = sort_arr (symbolic_solve (eq, [a,b,x]), [a,b,x])
8286 known_roots = sort_arr ([Dict (a=> - 1 / 10 , b=> 3 / 2 , x=> - im* sqrt (5 )), Dict (a=> - 1 / 10 , b=> 3 / 2 , x=> im* sqrt (5 ))], [a,b,x])
8387 @test check_approx (calcd_roots, known_roots)
88+ @test check_approx (solve_roots, known_roots)
8489end
8590
8691@testset " Invalid input" begin
8792 @test_throws AssertionError symbolic_solve (x, x^ 2 )
88- @test_throws AssertionError symbolic_solve (1 / x, x)
8993end
9094
9195@testset " Nice univar cases" begin
@@ -355,14 +359,18 @@ end
355359@testset " Post Process roots" begin
356360 SymbolicUtils. @syms __x
357361 __symsqrt (x) = SymbolicUtils. term (ssqrt, x)
362+ term = SymbolicUtils. term
358363 @test Symbolics. postprocess_root (2 // 1 ) == 2 && Symbolics. postprocess_root (2 + 0 * im) == 2
359364 @test Symbolics. postprocess_root (__symsqrt (4 )) == 2
360365 @test isequal (Symbolics. postprocess_root (__symsqrt (__x)^ 2 ), __x)
361366
362- @test Symbolics. postprocess_root ( SymbolicUtils. term (^ , __x, 0 ) ) == 1
363- @test Symbolics. postprocess_root ( SymbolicUtils. term (^ , Base. MathConstants. e, 0 ) ) == 1
364- @test Symbolics. postprocess_root ( SymbolicUtils. term (^ , Base. MathConstants. pi , 1 ) ) == Base. MathConstants. pi
365- @test isequal (Symbolics. postprocess_root ( SymbolicUtils. term (^ , __x, 1 ) ), __x)
367+
368+ @test isequal (Symbolics. postprocess_root (term (^ , 0 , __x)), 0 )
369+ @test_broken isequal (Symbolics. postprocess_root (term (/ , __x, 0 )), Inf )
370+ @test Symbolics. postprocess_root (term (^ , __x, 0 ) ) == 1
371+ @test Symbolics. postprocess_root (term (^ , Base. MathConstants. e, 0 ) ) == 1
372+ @test Symbolics. postprocess_root (term (^ , Base. MathConstants. pi , 1 ) ) == Base. MathConstants. pi
373+ @test isequal (Symbolics. postprocess_root (term (^ , __x, 1 ) ), __x)
366374
367375 x = Symbolics. term (sqrt, 2 )
368376 @test isequal (Symbolics. postprocess_root ( expand ((x + 1 )^ 4 ) ), 17 + 12 x)
426434 lhs = ia_solve (a* x^ b + c, x)[1 ]
427435 lhs2 = symbolic_solve (a* x^ b + c, x)[1 ]
428436 rhs = Symbolics. term (^ , - c. val/ a. val, 1 / b. val)
429- # @test isequal(lhs, rhs)
437+ @test_broken isequal (lhs, rhs)
438+
439+ @test isequal (symbolic_solve (2 / x, x)[1 ], Inf )
440+ @test isequal (symbolic_solve (x^ 1.5 , x)[1 ], 0 )
430441
431442 lhs = symbolic_solve (log (a* x)- b,x)[1 ]
432443 @test isequal (Symbolics. unwrap (Symbolics. ssubs (lhs, Dict (a=> 1 , b=> 1 ))), 1 E)
0 commit comments