Skip to content

Commit

Permalink
Updating README and Example Jupyter notebook with an example of usage…
Browse files Browse the repository at this point in the history
… of point_on_variety function. Exposing new classes at module level via __init__. Forcing primary decomposition to return non-short Singular syntax for variables and exponents.
  • Loading branch information
GDeLaurentis committed May 4, 2024
1 parent 20d7a48 commit 3df730a
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,69 @@ pytest --cov syngular/ --cov-report html tests/ --verbose

## Quick Start

Define an ideal over a ring in two variables
```
from syngular import Ideal, Ring
I = Ideal(Ring('0', ('x1', 'x2'), 'dp'), ['x1*x2'])
```
You can now inspect `I` to see what methods and attributes are available.

## Solving arbitrary systems of polynomial equations

Generate a $p$-adic solution to a system of 2 polynomial equations in 3 variables, controlling the precision to which they are solved.
```
field = Field("padic", 2 ** 31 - 1, 8)
ring = Ring('0', ('x', 'y', 'z', ), 'dp')
I = Ideal(ring, ['x*y^2+y^3-z^2, x^3+y^3-z^2', ])
```

The variety associated to `I` has 3 branches. In other words, the system of equations has 3 types of solutions.
```
(Q1, P1), (Q2, P2), (Q3, P3) = I.primary_decomposition
```

Generate a solution on the first branch
```
numerical_point = Q1.point_on_variety(field=field, directions=I.generators, valuations=(1, 1, ), )
```
is a dictionary of numerical values for each variable in the ring.

These are small with valuations (1, 1)
```
list(map(lambda string: Polynomial(string, field).subs(numerical_point), Q1.generators))
```

while these are O(1) with valuations (0, 0)
```
list(map(lambda string: Polynomial(string, field).subs(numerical_point), Q2.generators))
```

See [arXiv:2207.10125](https://arxiv.org/pdf/2207.10125) Fig. 1 for a graphical depiction.

## Citation

If you found this library useful, please consider citing it and [Singular](https://www.singular.uni-kl.de/)


```bibtex
@inproceedings{DeLaurentis:2023qhd,
author = "De Laurentis, Giuseppe",
title = "{Lips: $p$-adic and singular phase space}",
booktitle = "{21th International Workshop on Advanced Computing and Analysis Techniques in Physics Research}: {AI meets Reality}",
eprint = "2305.14075",
archivePrefix = "arXiv",
primaryClass = "hep-th",
reportNumber = "PSI-PR-23-14",
month = "5",
year = "2023"
}
```

```bibtex
@misc {DGPS,
title = {{\sc Singular} {4-3-0} --- {A} computer algebra system for polynomial computations},
author = {Decker, Wolfram and Greuel, Gert-Martin and Pfister, Gerhard and Sch\"onemann, Hans},
year = {2022},
howpublished = {\url{http://www.singular.uni-kl.de}},
}
```
40 changes: 37 additions & 3 deletions examples/Examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"source": [
"import sympy\n",
"\n",
"from syngular import Ideal, Ring, QuotientRing, SingularException"
"from syngular import Ideal, Ring, QuotientRing, SingularException, Field, Polynomial"
]
},
{
Expand Down Expand Up @@ -255,11 +255,45 @@
"L = I.reduce(J)\n",
"assert L == Ideal(ring, ['0'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# point on variety\n",
"field = Field(\"padic\", 2 ** 31 - 1, 8)\n",
"ring = Ring('0', ('x', 'y', 'z', ), 'dp')\n",
"I = Ideal(ring, ['x*y^2+y^3-z^2, x^3+y^3-z^2', ])\n",
"(Q1, P1), (Q2, P2), (Q3, P3) = I.primary_decomposition # the variety associated to I has 3 branches. In other words, the system of equations has 3 types of solutions.\n",
"numerical_point = Q1.point_on_variety(field=field, directions=I.generators, valuations=(1, 1, ), ) # generate a solution on the first branch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# these are small with valuations (1, 1)\n",
"list(map(lambda string: Polynomial(string, field).subs(numerical_point), Q1.generators))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# these are O(1) with valuations (0, 0)\n",
"list(map(lambda string: Polynomial(string, field).subs(numerical_point), Q2.generators))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -273,7 +307,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
},
"toc": {
"base_numbering": 1,
Expand Down
1 change: 1 addition & 0 deletions syngular/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
from .qring import QuotientRing, QRing # noqa
from .tools import SingularException # noqa
from .field import Field # noqa
from .polynomial import Polynomial # noqa
1 change: 1 addition & 0 deletions syngular/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def primary_decomposition(self):
f"ideal i = {self};",
# f"ideal gb = {','.join(self.groebner_basis)};",
"def pr = primdecGTZ(i);", # options: GTZ / SY
"short=0;",
"print(pr);",
"$"]
output = execute_singular_command(singular_commands)
Expand Down

0 comments on commit 3df730a

Please sign in to comment.