# Using inequalities in a polynomial system in Groebner.jl

**URL:** <https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651>\
**Category:** General Usage\
**Tags:** symbolic, polynomials\
**Created:** [November 24, 2023, 1:18am UTC](https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651 "2023-11-24T01:18:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [November 24, 2023, 1:18am UTC](https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651/1 "2023-11-24T01:18:15Z")

</div>

Groebner.jl is useful for solving a system of polynomial equations. This is about a method of transforming an inequality into an equation, so it could be used with Groebner.jl.

Suppose, for example, I have this simple equation: {\left(x-2\right) \cdot \left(x+3\right)} = 0. It has two solutions, 2 and -3. Now suppose we had this equation in a system together with the inequality 0 \le x. Now there’s only a single solution, 2, because -3 is negative.

To make the above system usable in Groebner.jl, the inequality must be turned into a set of equations. Luckily, I thought, this should be easy: 0 \le x should be equivalent with x = {y^2}, where y is a newly introduced variable, because a square is never negative. Supposing both x and y are real, that is.

This is why I hoped that if I input the equations {\left(x-2\right) \cdot \left(x+3\right)} = 0 and x = {y^2} into `Groebner.groebner`, I would get a system containing the equation {x-2}=0 as output. This is, however, not the case - Groebner.jl doesn’t seem to be able to eliminate the negative solution. I guess perhaps Groebner.jl doesn’t know that I intend for the variables to be real?

I’m wondering why is that, is it a limitation inherent in the algorithm, and is there another way to solve inequalities with Groebner.jl.

REPL example:

```julia-repl
julia> using DynamicPolynomials, Groebner

julia> @polyvar x y
(x, y)

julia> groebner([(x - 2)*(x + 3), x - y^2])
2-element Vector{Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}, Int64}}:
 -x + y²
 -6 + x + x²

```

EDIT: here’s another example, I would expect the output here to be 0 = 1 (“inconsistent system”):

```julia-repl
julia> groebner([(x + 2)*(x + 3), x - y^2])
2-element Vector{Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}, Int64}}:
 -x + y²
 6 + 5x + x²

```

@sumiya11 hope you can give some insight

---

<div class="post-metadata">

**Author:** ![shikil](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@shikil](https://discourse.julialang.org/u/shikil)\
**Post date:** [November 24, 2023, 3:49am UTC](https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651/2 "2023-11-24T03:49:06Z")

</div>

As I know, groebner basis is not used to get numerical results of system of polynomials. In order to get numerical results, real or complex, I suggest HomotopyContinuation.jl

```julia
using HomotopyContinuation

@var x y

F = System([(x - 2)*(x + 3), x - y^2])

R = solve(F)

results(R; only_real=true)

2-element Vector{PathResult}:
 PathResult:
 • return_code → :success
 • solution → ComplexF64[2.0 + 0.0im, 1.4142135623730951 + 4.81482486096809e-35im]
 • accuracy → 1.066e-16
 • residual → 4.4409e-16
 • condition_jacobian → 2.1496
 • steps → 28 / 0
 • extended_precision → false
 • path_number → 1

 PathResult:
 • return_code → :success
 • solution → ComplexF64[2.0 + 0.0im, -1.4142135623730951 - 4.81482486096809e-35im]
 • accuracy → 1.066e-16
 • residual → 4.4409e-16
 • condition_jacobian → 1.1471
 • steps → 28 / 0
 • extended_precision → false
 • path_number → 2

```

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [November 24, 2023, 8:49am UTC](https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651/3 "2023-11-24T08:49:58Z")

</div>

> [@shikil](#):
>
> groebner basis is not used to get numerical results of system of polynomials

Yeah, but notice that all the manipulations in my post are purely symbolic, I think. It’s just that I picked the simplest possible example to illustrate my point. Thanks regardless, I didn’t know about HomotopyContinuation.jl and it seems interesting.

---

<div class="post-metadata">

**Author:** ![sumiya11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sumiya11/32/207147_2.png) [@sumiya11](https://discourse.julialang.org/u/sumiya11)\
**Post date:** [November 24, 2023, 11:19am UTC](https://discourse.julialang.org/t/using-inequalities-in-a-polynomial-system-in-groebner-jl/106651/4 "2023-11-24T11:19:39Z")

</div>

Hi @nsajko ,

As far as I know it is not possible to use inequalities together with Gröbner bases to eliminate certain solutions in the way you describe.

If the end goal is obtaining a numerical solution, then in addition to [HomotopyContinuation.jl](https://juliahub.com/ui/Packages/HomotopyContinuation) you can perhaps consider [AlgebraicSolving.jl](https://github.com/algebraic-solving/AlgebraicSolving.jl).  
On the other hand, if the goal is to simplify existing polynomial relations using inequalities, I think Gröbner bases won’t help much.

> [@nsajko](#):
>
> EDIT: here’s another example, I would expect the output here to be 0 = 10=10 = 1 (“inconsistent system”):

A subtle detail is that a Gröbner basis contains 1 iff the system has no solutions in \mathbb{C}, and your example has some solutions in \mathbb{C}.
