diff --git a/README.md b/README.md index b137a4a..2bf7972 100644 --- a/README.md +++ b/README.md @@ -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}}, +} +``` diff --git a/examples/Examples.ipynb b/examples/Examples.ipynb index d6e325b..a561810 100644 --- a/examples/Examples.ipynb +++ b/examples/Examples.ipynb @@ -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" ] }, { @@ -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" }, @@ -273,7 +307,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.12" }, "toc": { "base_numbering": 1, diff --git a/syngular/__init__.py b/syngular/__init__.py index ba937be..9806f9a 100644 --- a/syngular/__init__.py +++ b/syngular/__init__.py @@ -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 diff --git a/syngular/ideal.py b/syngular/ideal.py index e1a4a89..2704c94 100644 --- a/syngular/ideal.py +++ b/syngular/ideal.py @@ -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)