Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions doc/source/fmpq_mpoly.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
**fmpq_mpoly** -- multivariate polynomials over the rational numbers
===============================================================================

A context fixes the variables and monomial ordering of a polynomial ring
over :math:`\mathbb{Q}`. For nonnegative integers :math:`i` and :math:`j`,
a dictionary entry ``(i, j): c`` represents the term :math:`c x^i y^j`
when the context's variables are ``x`` and ``y``, in that order.

For example, the polynomial

.. math::

p(x, y) = \frac{1}{3} x y + \frac{1}{2} x + \frac{3}{4} y

can be constructed from the context's generators::

>>> from flint import fmpq, fmpq_mpoly_ctx
>>> ctx = fmpq_mpoly_ctx.get(("x", "y"), "lex")
>>> x, y = ctx.gens()
>>> p = x*y/3 + x/2 + 3*y/4
>>> p
1/3*x*y + 1/2*x + 3/4*y

Division by a nonzero integer gives exact rational coefficients.
The same polynomial can also be constructed from a dictionary::

>>> p = ctx.from_dict({
... (1, 1): fmpq(1, 3),
... (1, 0): fmpq(1, 2),
... (0, 1): fmpq(3, 4),
... })
Comment on lines +27 to +31

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should print out what p is so that someone reading the docs can interpret the dict format.

>>> p
1/3*x*y + 1/2*x + 3/4*y

For integers :math:`a` and :math:`b \ne 0`, ``fmpq(a, b)`` represents
:math:`a/b` exactly. Integer coefficients are also allowed.

.. autoclass :: flint.fmpq_mpoly_ctx
:members:
:inherited-members:
Expand Down
Loading