Skip to main content

A simple python package for algebraic calculations

Project description

algebra

Install with PyPi

pip install algebra.py

How to use

Importing

from algebra.components import term

Initializing

Note: to see the output shown in the comments you need to run print() or str() at the answer

term1 = term('2x')# 2x
#exponent in terms
term2 = term('2x²')# 2x²
term3 = term('2x2')# also works
#supports multiple variables
term4 = term('2x2y3')# 2x²y³
# suports negative coefficients
term5 = term('-2x3')# -2x³

Supported Operations

sum

substraction is supported the same way

sum1 = term('2x') + term('3x')# 5x
sum2 = term('2x') + term('2y')# 2x + 2y
# support for integer sum
sum3 = term('3x') + 4 # 3x + 4

multiplication

mul1 = term('2x') * 4# 8x
mul2 = term('2x') * term('3x')# 6x²
mul3 = term('2x') * term('3y')# 6xy
mul4 = term('2xy') * term('3yz')# 6xy²z

division

div1  = term('4x')/2 # 2x
div2 = term('4x')/term('2x')# 2
div3 = term('4x2')/term('4x')# x
div4 = term('4x')/term('4x2')# xᐨ¹
div5 = term('4x2')/term('4x2')# 1

Exponentiation

exp1 = term('2x')**2 # supported
exp2 = term('2x')**-1 # supported
exp2 = term('2x')**term('2x')# not supported
exp3 = term('2x')**2.5# supported

polynoms

example

pol1 = term('2x') + term('3y') # 2x + 3y
pol2 = term('2x') - 2 # 2x - 2
# sum
pol4 = pol1 + pol2 #  4x + 3y - 2
# multiplication
pol5 = pol1 * pol2 #  supported
# exponentiation
pol6 = pol1**2 # supported
pol7 = pol1**2.5 # not supported
pol8 = pol1**pol2 # not supported

div1  = pol1/2 # x + 1.5y
div2 = pol1/term('2x')# 1 + 1.5xᐨ¹y
div3 = pol1/pol2 # not supported

polynoms support sum, substraction, multiplication and exponents as terms do.

have fun!

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.py-1.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

algebra.py-1.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file algebra.py-1.1.2.tar.gz.

File metadata

  • Download URL: algebra.py-1.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for algebra.py-1.1.2.tar.gz
Algorithm Hash digest
SHA256 5a88c0b0a7853311529cf1efda14b89839d7bd4f353f22f8ceeadba4fe34b830
MD5 aa91792195ae9395186c58b4635d4d32
BLAKE2b-256 1f91f7dc4f4c7e23cb5fde0ffdb784011b140caea19b61c4bf55531e47388977

See more details on using hashes here.

File details

Details for the file algebra.py-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: algebra.py-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for algebra.py-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2926a4c3a1c42202c0f0d428ac8f9e1f4b04bbbda3df938d5a7bec6bbd748c0
MD5 58ab3dc73c0cb9d17efef1b3a777e7b5
BLAKE2b-256 5ea69aad00218672fd51a5f6680488e0100ff42029556146b4334e7736f30fca

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