Symbolic Geometric Algebra/Calculus package for SymPy :crystal_ball:

pygae, updated 🕥 2022-01-21 19:55:36

GAlgebra

Symbolic Geometric Algebra/Calculus package for SymPy.

PyPI PyPI - Python Version Build Status on CircleCI Documentation Status DOI

Development Status

PyPI - Status GitHub contributors Codecov Language grade: Python Maintainability

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:

```python 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:

```python 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 (0.4.x was the last supported release series for Python 2.7)
  • SymPy >= 1.3

Installing GAlgebra From PyPI (Recommended for users)

bash pip install galgebra

Then you are all set!

Installing GAlgebra From Source (Recommended for developers)

To install from the latest source code of GAlgebra:

bash 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:

bash pip install pytest pytest test

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

bash 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

Note: The APIs have changed since the era of sympy.galgebra and brombo/galgebra, some properties and methods are deprecated, the supported versions of Python and SymPy have also changed, please check Changelog and further update your scripts accordingly besides the following. If you encounter any problems, feel free to open an issue!

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:

python from sympy.galgebra.ga import *

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

python 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:

python from galgebra.printer import Format, Eprint, latex, GaPrinter from galgebra.ga import Ga 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.

Issues

Getting wrong type of multivector

opened on 2023-03-10 10:30:53 by ingodahn

I am trying to calculate the image of a 3D vector $u=e_1+2e_2+3e_3$ under the rotation with axis vector $e_1+e_2+e_3$. I would expect to get a vector as image but the calculation yields a vector + a tiny multiple of $e_1\wedge e_2\wedge e_3$, perhaps due to rounding errors.

The code is attached gaerror.txt

Edit: Using an updated version of galgebra as described in http://www.faculty.luther.edu/~macdonal/GAlgebraPrimer.pdf and then using the exp() method from galgebra yields exactly the same result.

Ubuntu 20.04

opened on 2022-11-16 17:24:13 by abrombo

I have install galgebra on Ubuntu 22.04 using github -

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

When I try to run terminal examples from the geany editor I get -

Traceback (most recent call last): File "/home/brombo/galgebra/examples/Terminal/terminal_check.py", line 4, in from galgebra.printer import Eprint ModuleNotFoundError: No module named 'galgebra'

When I run a ipynb file (in Google-Chrome) all the packages are found and the code runs and when I run from the terminal command line, "python3 some_galgebra_code.py" the galgebra modules are found. Note that when I run python code from the geany editor with sympy imports it works.

Any idea what is going on here. It started when I upgraded to Ubuntu 22.04.

Bump ipython from 5.8.0 to 7.16.3

opened on 2022-01-21 19:55:36 by dependabot[bot]

Bumps ipython from 5.8.0 to 7.16.3.

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/pygae/galgebra/network/alerts).

Projective geometric algebra

opened on 2022-01-18 14:01:59 by technolapin

I am working with projective geometric algebra (metric: [0, 1, 1, 1] ), but I have trouble to find a way to make it work with galgebra because of the nilpotent basis vector.

For instance, this code

python p3g = [0, 1, 1, 1] p3ga = Ga('e_0 e_1 e_2 e_3', g=p3g, coords=oxyz, norm=False, wedge=False) e0, e1, e2, e3 = p3ga.mv() ux = p3ga.mv('u_x', 'scalar') uy = p3ga.mv('u_y', 'scalar') uz = p3ga.mv('u_z', 'scalar') u = e1*ux + e2*uy+e3*uz print("u", u) print("u*", u.dual()) prints : !!!!If I**2 = 0, I cannot be normalized!!!! : u u_x*e_1 + u_y*e_2 + u_z*e_3 : u* zoo*(u_x + u_y + u_z) when u* should be u_x*e_23 - u_y*e_13 + u_z*e_12

How should I do to make it work? Is there a way to give a user-defined dualization method, or to add the antiproduct?

Looking to Contribute GUI or Some Geometric Algorithms

opened on 2021-11-24 15:14:42 by nadavsuissa

Hello, We are a group of Vs students looking to contribute to an open source code, we would like to implement a Graphic interface or some interesting geometric algorithms and are questions are the following Is someone already working on this? I not is this something that you might be interest in, If we implement this to a high enough level, would you accept the contribution?

Improvements (I hope) to the mv.py and lt.py modules

opened on 2021-11-05 08:29:46 by Greg1950

I have made a number of changes to the mv.py and lt.py modules, changes which I believe address the issues about which I've previously posted. I've improved the treatment of spinor-based orthogonal transformations so that now one can instantiate an orthogonal transformation using versors, a broader set of multivectors than are spinors. And I've added to the multivector methods in mv.py several new methods, most of them inspired by Dorst, Fontijne, & Mann's Geometric Algebra for Computer Science.

The changed modules have met every test I've made of them. They are placed in the galgebra folder of the attached zip file. Another folder, notebooks, contains four Jupyter notebooks. Two of them describe precisely the changes I've made to the modules' code. The other two are oriented towards GAlgebra users (as opposed to programmers). A Read Me First file has been placed at the top level within the archive.

I'm much better at mathematics than programming. My level of skill at the latter goes no further than a couple of introductory CS courses from M.I.T.'s edX division. So I would appreciate it if readers of this GitHub issues forum, who are almost certainly better programmers than me, would look over the modified modules and test their functioning.

(Changes in the indicated modules are delimited by comment lines ### GSG code starts ### and ### GSG code ends ###. Those comment lines are there to aid real programmers in locating the modifications I've made. They should be stripped out if it's decided by the PyGAE GAlgebra group that the modification should be kept.)

I can be contacted at [email protected]

Greg Grunberg

GSG_2021-11-05_GAlgebra_fixes.zip

Releases

v0.5.0 2020-06-04 04:47:57

See Changelog.

https://pypi.org/project/galgebra/0.5.0/

v0.5.0rc1 2020-05-26 17:24:21

See Changelog.

v0.4.5 2019-12-31 15:26:54

See Changelog.

https://pypi.org/project/galgebra/0.4.5/

v0.4.4 2019-09-26 03:57:41

See Changelog.

pygae

Pythonic Geometric Algebra Enthusiasts

GitHub Repository Homepage

geometric-algebra clifford-algebras quaternions physics python