Solve equation in Symbolics.jl

Symbolics.jl can’t solve this equation but if I multiply both sides by x^3 then it can. Wolfram Alpha can solve both. Symbolics.jl’s docs say it can do polynomial equations; do these count? What’s the problem?

  [2edaba10] Nemo v0.46.2
  [0c5d862f] Symbolics v6.11.0

using Symbolics, Nemo
@variables x y
julia> symbolic_solve(1/x^2 ~ 1/y^2 - 2/x^3 * (x-y), x)
┌ Warning: This expression cannot be solved with the methods available to ia_solve. Try a numerical method instead.
└ @ Symbolics ~/.julia/packages/Symbolics/6WqId/src/solver/ia_main.jl:176

julia> symbolic_solve( (1/x^2 * x^3 ~ (1/y^2 - 2/x^3 * (x-y)) * x^3), x)
[ Info: Assuming (y^2) != 0
[ Info: Assuming (y^2) != 0
2-element Vector{SymbolicUtils.BasicSymbolic{Real}}:
 y
 -2y

Create an issue: Issues · JuliaSymbolics/Symbolics.jl · GitHub

Not clear to me: Why is Nemo needed?

This code is easier to copy and paste:

using Symbolics, Nemo

@variables x y
symbolic_solve(1/x^2 ~ 1/y^2 - 2/x^3 * (x-y), x)
# symbolic_solve( (1/x^2 * x^3 ~ (1/y^2 - 2/x^3 * (x-y)) * x^3), x)
1 Like

Nemo is needed to enable a package extension in Symbolics. The problem is that only polynomial equations can be solved, so you need to multiply out any denominators. Here’s a quick way to reproduce the problem.

julia> using Symbolics, Nemo

julia> @variables x;

julia> symbolic_solve(x ~ 1/x, x) # denominators cannot be handled
┌ Warning: This expression cannot be solved with the methods available to ia_solve. Try a numerical method instead.
└ @ Symbolics ~/.julia/packages/Symbolics/e7UFe/src/solver/ia_main.jl:176

julia> symbolic_solve(x^2 ~ 1, x) # multiply both sides by `x` to get polynomials
2-element Vector{BigInt}:
 -1
  1

So should the issue be fixed in Symbolics or in Nemo?

It should be fixed in Symbolics, since Nemo is used as a backend. But since their recent feature announcement mentions “multivariate polynomial solving”, I understand that is a feature limitation not a bug.

There isn’t a reason this cannot be handled via some normalization pass that occurs before the solve and then fixes the solution after the solve. Definitely worth an issue

2 Likes

Issue submitted: