Skip to main content

Symbolic Geometric Algebra/Calculus package for SymPy.

Project description

GAlgebra

Symbolic Geometric Algebra/Calculus package for SymPy.

PyPI PyPI - Python Version Build Status Documentation Status

Development Status

PyPI - Status GitHub contributors Codacy Badge Codecov

brombo/galgebra was originally written by Alan Bromborsky, but was no longer actively maintained, and as of 2019-11-25 no longer exists.

pygae/galgebra is a community fork, maintained by Pythonic Geometric Algebra Enthusiasts.

The fork supports Python 3, increases test coverage, set up CI and linters, maintains releases to PyPI, improves docs and has many bug fixes, see Changelog.

Features

Geometric Algebra

  • Arbitrary Vector Basis and Metric
  • Scalar, Vector, Bivector, Multivector, Pseudoscalar, Spinor, Blade
  • Basic Geometic Algebra Operations
    • Sum Difference
    • Geometric Product
    • Outer and Inner Products
    • Left and Right Contractions
    • Reverse, Dual, Exponential
    • Commutator
    • Projection, Reflection, Rotation
    • Reciprocal Frames
  • Inspecting Base/Blade Representation
  • Symbolic Manipulations
    • expand, factor, simplify, subs, trigsimp etc.

Overloaded Python operators for basic GA operations:

Geometric Calculus

  • Geometric Derivative
  • Submanifolds
  • Linear Transformations
  • Differential Operators

The various derivatives of a multivector function is accomplished by multiplying the gradient operator vector with the function:

Tip: an example for getting grad and rgrad of a 3-d Euclidean geometric algebra in rectangular coordinates:

from sympy import symbols
from galgebra.ga import Ga

o3d = Ga('e', g=[1,1,1], coords=symbols('x,y,z',real=True))
(grad,rgrad) = o3d.grads()

Printing

  • Enhanced Console Printing
  • Latex Printing
    • out-of-the-box support for Jupyter Notebook
    • PDF generation and croping support if you have pdflatex/pdfcrop installed

Getting Started

After installing GAlgebra (see section Installing GAlgebra below), in a Jupyter Notebook:

from sympy import symbols
from galgebra.ga import Ga

from galgebra.printer import Format
Format(Fmode = False, Dmode = True)

st4coords = (t,x,y,z) = symbols('t x y z', real=True)
st4 = Ga('e',
         g=[1,-1,-1,-1],
         coords=st4coords)

M = st4.mv('M','mv',f = True)

M.grade(3).Fmt(3,r'\langle \mathbf{M} \rangle _3')

You will see:

You may also check out more examples here.

For detailed documentation, please visit https://galgebra.readthedocs.io/ .

NOTE: If you are coming from sympy.galgebra or brombo/galgebra, please check out section Migration Guide below.

Installing GAlgebra

Prerequisites

  • Works on Linux, Windows, Mac OSX
  • Python >=3.5
  • SymPy 1.3, 1.4 or preferably 1.5

Installing GAlgebra From PyPI (Recommended for users)

pip install galgebra

Then you are all set!

Installing GAlgebra From Source (Recommended for developers)

To install from the latest source code of GAlgebra:

git clone https://github.com/pygae/galgebra.git
cd galgebra
pip install -e .

Note that the optional -e argument is used here for a developer install so modifying the source will take effect immediately without the need of reinstallation.

Now you may run tests to verify the installation, run from the root of the repository:

pip install pytest
pytest test

Further, to run the complete test suite including the ones using nbval, just run:

pip install nbval
pytest --nbval examples/ipython/ test --current-env --sanitize-with test/.nbval_sanitize.cfg

This could take more than 10 minutes, please be patient.

Migration Guide

Migrating from sympy.galgebra

GAlgebra is no longer part of SymPy since 1.0.0, if you have an import like this in your source:

from sympy.galgebra.ga import *

Simply remove the sympy. prefix before galgebra then you are good to go:

from galgebra.ga import *

Migrating from brombo/galgebra

The setgapth.py way to install is now deprecated by pip install galgebra and all modules in GAlgebra should be imported from galgebra, for example:

from galgebra.printer import Format, Eprint, Get_Program, latex, GaPrinter
from galgebra.ga import Ga, one, zero
from galgebra.mv import Mv, Nga

Bundled Resources

Note that in the doc/books directory there are:

  • BookGA.pdf which is a collection of notes on Geometric Algebra and Calculus based of "Geometric Algebra for Physicists" by Doran and Lasenby and on some papers by Lasenby and Hestenes.
  • galgebra.pdf which is the original main doc of GAlgebra in PDF format, while the math part is still valid, the part describing the installation and usage of GAlgebra is outdated, please read with cautious or visit https://galgebra.readthedocs.io/ instead.
  • Macdonald which constains bundled supplementary materials for Linear and Geometric Algebra and Vector and Geometric Calculus by Alan Macdonald, see here and here for more information.

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

galgebra-0.5.0rc1.tar.gz (87.3 kB view details)

Uploaded Source

Built Distribution

galgebra-0.5.0rc1-py3-none-any.whl (92.9 kB view details)

Uploaded Python 3

File details

Details for the file galgebra-0.5.0rc1.tar.gz.

File metadata

  • Download URL: galgebra-0.5.0rc1.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for galgebra-0.5.0rc1.tar.gz
Algorithm Hash digest
SHA256 fc5fa9efff4dae47c43ff722865ad9aa393416448ecc8ff8bb99d47f73a3b71b
MD5 aa516929c96d2aa24b5a780d67d90089
BLAKE2b-256 26efd2c29849c98b863aa2bc828ab1e095b415c097255554fec801c462e44862

See more details on using hashes here.

File details

Details for the file galgebra-0.5.0rc1-py3-none-any.whl.

File metadata

  • Download URL: galgebra-0.5.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 92.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for galgebra-0.5.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 ded8dff347e23a08c59dee5a93bef993ebdf18d753e62f58cce48aaae1804605
MD5 2123f94ab9e988bf177ef6782231e71b
BLAKE2b-256 a7bd51cb2e9a5e6070207ff6a46be257cf25b5fa1488d54179660e366e46ed68

See more details on using hashes here.

Supported by

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