# Symbolics + Gröbner basis

**URL:** https://discourse.julialang.org/t/symbolics-grobner-basis/127706
**Category:** Modelling & Simulations
**Tags:** polynomials
**Created:** [April 4, 2025, 1:55pm UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706 "2025-04-04T13:55:27Z")
**Posts on this page:** 5
**Page:** 2

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [April 7, 2025, 9:15am UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706/21 "2025-04-07T09:15:52Z")

</div>

OK – I have tried the code (I updated all packages first). The second time I run it (as it is), it took 28.5 seconds on my laptop in battery mode (some sort of power efficiency).

- Is that a decent speed?
- I see your point about no constant term in the fourth order polynomial for `n_H2O_L`, i.e., `n_H2O_L = 0` being a root. Physically, this would imply that water is completely in the vapor phase. Probably not impossible, but not something I would expect. So would (at the outset) neglect that root. That leaves a third order polynomial, so either 3 real roots or one real and two complex roots. In the latter case, it would be trivial to choose the physical solution. Of course, if the real roots are (i) one negative, (ii) one larger than `n_H2O`, and a third one, it would also be easy to pick the correct root.

OK – I’ll do some more testing. E.g.,

1. Check the speed when replacing `paramgb` with `groebner` just to check the gain in speed, and

- Answer: I stopped the computation after some 18 minutes. Will re-run tonight.

1. Reduce the problem to water + one additional light gas.

- Answer: With one light gas in addition to water, the solution was found in 0.6 seconds with `paramgb`. Result: a third order polynomial, again with `n_H2O_L` equal to zero as one possible root.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [April 7, 2025, 9:56am UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706/22 "2025-04-07T09:56:08Z")

</div>

> [@sumiya11](#):
>
> In 3., mark several variables as interesting to uncover relations between them (for example, [n\_H2O\_L, n\_1\_g, n\_2\_g]).

I tried to add `n_1_g`. The result is that `gb[1]` depends on \*both  
`n_H2O_L` and `n_1_g`, which is not a solution. But, it probably shows some correlation.

---

<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: [April 7, 2025, 1:08pm UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706/23 "2025-04-07T13:08:00Z")

</div>

> Is that a decent speed?

For `paramgb`, I do not have a reference point: I do not know of any other similar implementations (please tell me if you do!).

In general, for GB over rational function fields we can compare with slimgb in Oscar.jl / Singular.

> 1. Check the speed when replacing `paramgb` with `groebner` just to check the gain in speed, and
> 
> - Answer: I stopped the computation after some 18 minutes. Will re-run tonight.

I see, thanks for checking. It is hard to tell which one would be faster in advance.

> I tried to add `n_1_g` . The result is that `gb[1]` depends on \*both  
> `n_H2O_L` and `n_1_g` , which is not a solution. But, it probably shows some correlation.

Right, not as useful for solving. It can perhaps be useful for finding interesting conservation laws. As a silly example, with `interesting_vars = [n_H2O_L, n_1_g, n_2_g]`, `gb[2]` is a relatively small expression that only depends on `n_1_g, n_2_g`, which may (or may not) tell something useful about the proportional amounts.

---

<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: [April 7, 2025, 1:10pm UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706/24 "2025-04-07T13:10:16Z")

</div>

It would be nice if `symbolic_solve` was able to solve these equations out of the box.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [April 7, 2025, 1:15pm UTC](https://discourse.julialang.org/t/symbolics-grobner-basis/127706/25 "2025-04-07T13:15:20Z")

</div>

I’m sure Oscar is nice. However, it is slightly more complicated to install on Windows, I seem to recall: it requires the Windows subsystem for Linux (?), which I have not installed.

[Previous page](https://discourse.julialang.org/t/symbolics-grobner-basis/127706.md?page=1)
