Skip to main content

Algebraic structures

Project description


CI Coverage Status Latest Docs Code style: black

Algebraic structures

Note: Algebra requires Python 3.6 or higher.

Requirements and Installation

pip install algebra

See also the instructions here.


This package provides an algebra where the elements can be manipulated in a natural way, with basic algebraic simplifications happening automatically. It also support equality checking, which is conservative: if x == y, then x is equal to y; but if x != y, then either x is different from y, or it could not be proven that x is equal to y.

As an example, let's create numbered elements.

from algebra import Element

class Numbered(Element):
    total = 0
    def __init__(self):
        self.num = += 1
    def render(self, formatter):
        return f'x{self.num}'

Then instances of Numbered can be manipulated as follows.

>>> x0 = Numbered()

>>> x1 = Numbered()

>>> x0 == x0

>>> x0 == x1

>>> x0 + x1
x0 + x1

>>> x0 + x0
2 * x0

>>> x0 + x1 == x1 + x0

>>> x0 - x0

>>> 2 + x0
2 * 1 + x0

>>> (2 + x0) * x1
(2 * 1 + x0) * x1

>>> (2 + x0) * x1 * 0

Create Your Own Algebra

Coming soon.

Function Algebra

Coming soon.

Create Your Own Function Algebra

Coming soon.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algebra-1.2.1.tar.gz (19.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page