Symbolic Geometric Algebra/Calculus package for SymPy.
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.
expand
, factor
, simplify
, subs
, trigsimp
etc.Overloaded Python operators for basic GA operations:
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() ```
pdflatex
/pdfcrop
installedAfter 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.
bash
pip install galgebra
Then you are all set!
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.
Note: The APIs have changed since the era of
sympy.galgebra
andbrombo/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!
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 *
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
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.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.
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
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.
Bumps ipython from 5.8.0 to 7.16.3.
d43c7c7
release 7.16.35fa1e40
Merge pull request from GHSA-pq7m-3gw7-gq5x8df8971
back to dev9f477b7
release 7.16.2138f266
bring back release helper from master branch5aa3634
Merge pull request #13341 from meeseeksmachine/auto-backport-of-pr-13335-on-7...bcae8e0
Backport PR #13335: What's new 7.16.28fcdcd3
Pin Jedi to <0.17.2.2486838
release 7.16.120bdc6f
fix conda buildDependabot 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
.
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?
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?
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
See Changelog.
https://pypi.org/project/galgebra/0.5.0/
See Changelog.
See Changelog.
https://pypi.org/project/galgebra/0.4.5/
See Changelog.
geometric-algebra clifford-algebras quaternions physics python