Skip to main content

Equations that can be algebraically manipulated.

Project description

sympy_equation

PyPI version Conda Version Documentation Status

This package defines relations that all high school and college students would recognize as mathematical equations, consisting of a left hand side (lhs) and a right hand side (rhs) connected by the relation operator "=". This is implemented by the Equation class, which also supports mathematical operations applied to both sides simultaneously, just as students are taught to do when attempting to isolate (solve for) a variable. Thus the statement Equation/b yields a new equation Equation.lhs/b = Equation.rhs/b.

The intent is to allow using the mathematical tools in SymPy to rearrange equations and perform algebra in a stepwise fashion using as close to standard mathematical notation as possible. In this way more people can successfully perform algebraic rearrangements without stumbling over missed details such as a negative sign.

A simple example as it would appear in a Jupyter notebook is shown immediately below:

screenshot of simple example

In IPython environments (IPython, Jupyter, Google Colab, etc...) there is also a shorthand syntax for entering equations provided through the IPython preparser. An equation can be specified as eq1 =@ a/b = c/d.

screenshot of short syntax

If no Python name is specified for the equation (no eq_name to the left of =@), the equation will still be defined, but will not be easily accessible for further computation. The =@ symbol combination was chosen to avoid conflicts with reserved python symbols while minimizing impacts on syntax highlighting and autoformatting.

More examples of the capabilities of sympy-equation are here.

Development and Support

If you feel like a feature could be implemented, open an issue or create a PR. Implementing new features and fixing bugs requires time and energy too. If you found this module useful and would like to show your appreciation, please consider sponsoring this project with either one of these options:

"Buy Me A Coffee" or

Installation

sympy_equation can be installed with pip or conda.

pip install sympy_equation

Or

conda install -c conda-forge sympy_equation

Customizing the module

equation_config is an object containing a few properties to customize the behaviour of the module:

from sympy_equation import equation_config

Arguably the most useful options are :

  • equation_config.integers_as_exact (default is False). When it's True and we are running in an IPython/Jupyter environment, it preparses the content of a code line in order to convert integer numbers to sympy's Integer. In doing so, we can write 2/3, which will be converted to Integer(2)/Integer(3), which then SymPy converts to Rational(2, 3). If False, no preparsing is done, and Python evaluates 2/3 to 0.6666667, which will then be converted by SymPy to a Float.
  • equation_config.show_label (default is False). When it's True, a label with the name of the equation in the python environment will be shown on the screen.

Check out the documentation to read more about these and other options.

Differences between sympy_equation and algebra_with_sympy

  • sympy_equation is a fork of algebra_with_sympy, starting from the version 1.0.2.
  • algebra_with_sympy installs a custom version of SymPy, which exposes the Equation class. The basic idea is to better integrate the Equation class with other SymPy functionalities. The downside is that as new releases of SymPy are available, the users of algebra_with_sympy must wait for a new version of the package to be released as well. Differently, sympy_equation is an external package that only depends on SymPy: as new releases of SymPy are available, sympy_equation will work with them right away. The downside is that it might not be as integrated with SymPy's functionalities as one would like it to be.
  • algebra_with_sympy exposes the algwsym_config object to customize the behaviour of the module. Similarly, sympy_equation exposes the equation_config. The available options are very similar, but their default values are often different.
  • algebra_with_sympy overwrites the default behaviour of SymPy's solve() and solveset() in order for them to return sets of solutions. This can be annoying if you are used to the SymPy's way of doing things. Differently, sympy_equation doesn't change the behaviour of these functions, rather it extends it in order to deal with the Equation class.

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

sympy_equation-1.3.0.tar.gz (79.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sympy_equation-1.3.0-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file sympy_equation-1.3.0.tar.gz.

File metadata

  • Download URL: sympy_equation-1.3.0.tar.gz
  • Upload date:
  • Size: 79.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.6 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for sympy_equation-1.3.0.tar.gz
Algorithm Hash digest
SHA256 0d4cca5b359d61b0ca97c2978042cf87f720b11c7a3fdc19243559f1c19e5edc
MD5 299bd004746fa93eed5f72bf77cb48c1
BLAKE2b-256 7552bccd20dc69838e8344455d7d972fec7fd9e4c9538161d86232a0a0a296fd

See more details on using hashes here.

File details

Details for the file sympy_equation-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: sympy_equation-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.6 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for sympy_equation-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9516d3d0c9500a4df2f0995335166364264668a024526c7e28841adc7300baac
MD5 15c7610ff7455dae2f4111c2c3c959d8
BLAKE2b-256 6f011da56cc2ecaf4db6ffe75b779d38ae7adcd8a6599958b5cc4443480f6290

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page