diff --git a/sympy/solvers/solveset.py b/sympy/solvers/solveset.py index 51e7b16c4879..67d5ee2cb536 100644 --- a/sympy/solvers/solveset.py +++ b/sympy/solvers/solveset.py @@ -862,7 +862,7 @@ def _solve_radical(f, unradf, symbol, solveset_solver): result = Union(*[imageset(Lambda(y, g_y), f_y_sols) for g_y in g_y_s]) - if isinstance(result, (Complement, ConditionSet)): + if not isinstance(result, FiniteSet): solution_set = result else: f_set = [] # solutions for FiniteSet @@ -1067,7 +1067,7 @@ def _solveset(f, symbol, domain, _check=False): elif isinstance(rhs_s, FiniteSet): for equation in [lhs - rhs for rhs in rhs_s]: if equation == f: - u = unrad(f) + u = unrad(f, symbol) if u: result += _solve_radical(equation, u, symbol, @@ -3448,7 +3448,7 @@ def _separate_poly_nonpoly(system, symbols): if isinstance(eq, Equality): eq = eq.rewrite(Add) # try to remove sqrt and rational power - without_radicals = unrad(simplify(eq)) + without_radicals = unrad(simplify(eq), *symbols) if without_radicals: eq_unrad, cov = without_radicals if not cov: diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py index 2a0227cb8b42..864cd6e581e5 100644 --- a/sympy/solvers/tests/test_solveset.py +++ b/sympy/solvers/tests/test_solveset.py @@ -3064,3 +3064,9 @@ def test_issue_19144(): def test_issue_19814(): assert nonlinsolve([ 2**m - 2**(2*n), 4*2**m - 2**(4*n)], m, n ) == FiniteSet((log(2**(2*n))/log(2), S.Complexes)) + + +def test_issue_22058(): + sol = solveset(-sqrt(t)*x**2 + 2*x + sqrt(t), x, S.Reals) + # doesn't fail (and following numerical check) + assert sol.xreplace({t: 1}) == {1 - sqrt(2), 1 + sqrt(2)}, sol.xreplace({t: 1})