# Gröbner bases are in 'hspray' 2.0.0

**URL:** <https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019>\
**Category:** Announcements\
**Created:** [March 11, 2024, 4:06pm UTC](https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019 "2024-03-11T16:06:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [March 11, 2024, 4:06pm UTC](https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019/1 "2024-03-11T16:06:42Z")

</div>

Hello,

I worked on my package ‘hspray’ (multivariate polynomials) these days. In the new version, it is possible to compute Gröbner bases.

I should upload this version on Hackage today.

```haskell
import Math.Algebra.Hspray
import Data.Ratio

-- define the elementary monomials
o = lone 0 :: Spray Rational
x = lone 1 :: Spray Rational
y = lone 2 :: Spray Rational
z = lone 3 :: Spray Rational

-- define three polynomials
p1 = x^**^2 ^+^ y ^+^ z ^-^ o -- x² + y + z - 1
p2 = x ^+^ y^**^2 ^+^ z ^-^ o -- x + y² + z - 1
p3 = x ^+^ y ^+^ z^**^2 ^-^ o -- x + y + z² - 1

-- compute the Gröbner basis
g = groebner [p1, p2, p3]

-- show result
prettyResult = map (prettySpray show "x") g
mapM_ print prettyResult
"((-1) % 1) * x^() + (1 % 1) * x^(0, 0, 2) + (1 % 1) * x^(0, 1) + (1 % 1) * x^(1)"
"(1 % 1) * x^(0, 0, 1) + ((-1) % 1) * x^(0, 0, 2) + ((-1) % 1) * x^(0, 1) + (1 % 1) * x^(0, 2)"
"((-1) % 2) * x^(0, 0, 2) + (1 % 2) * x^(0, 0, 4) + (1 % 1) * x^(0, 1, 2)"
"((-1) % 1) * x^(0, 0, 2) + (4 % 1) * x^(0, 0, 3) + ((-4) % 1) * x^(0, 0, 4) + (1 % 1) * x^(0, 0, 6)"

```

---

<div class="post-metadata">

**Author:** ![dbarton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/dbarton/32/2585_2.png) [@dbarton](https://discourse.haskell.org/u/dbarton)\
**Post date:** [March 11, 2024, 4:32pm UTC](https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019/2 "2024-03-11T16:32:51Z")

</div>

I also have a repo at [GitHub - DaveBarton/calculi: Fast parallel calculations in pure mathematics, e.g. Gröbner Bases](https://github.com/DaveBarton/calculi) that does this, with an emphasis on parallelism and timings. I’ve been working mostly on Macaulay2 the past few months, but hope to connect the two eventually (and upload to Hackage 😀).

---

<div class="post-metadata">

**Author:** ![andreasabel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/andreasabel/32/1764_2.png) [@andreasabel](https://discourse.haskell.org/u/andreasabel)\
**Post date:** [March 11, 2024, 9:18pm UTC](https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019/3 "2024-03-11T21:18:05Z")

</div>

Maybe you could define `instance Num (Spray ...)` to prettify the syntax for polynomials…

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [March 11, 2024, 9:24pm UTC](https://discourse.haskell.org/t/grobner-bases-are-in-hspray-2-0-0/9019/4 "2024-03-11T21:24:30Z")

</div>

Not sure to understand… But if I correctly understand, then that won’t do it. Because there’s the multiplication by a scalar too. And please see [Easier usage](https://github.com/stla/hspray) in the README.
