ABSTRACT (original article): A tutorial of the Mathematica package CGAlgebra, for conformal geometric algebra calculations is presented. Using rule-based programming, the 5-dimensional conformal geometric algebra is implemented and defined functions simplify the calculations of geometric, outer and inner products, as well as many other calculations related with geometric transformations. CGAlgebra is available from this https URL and now it is available also at the Wolfram Paclet Repository.
​CITATION (original article): E. Alejandra Ortiz-Duran, Jose L. Aragon (2017), CGAlgebra: a Mathematica package for conformal geometric algebra. v.2.0, arXiv:1711.02513. https://doi.org/10.48550/arXiv.1711.02513.

1. Installation

Option 1

To install and load the package download the Package file “CGAlgebra.m”and load the Package in Mathematica using the command:
​
<<”DIR/CGAlgebra.m”
where DIR is the full path of the directory where the package is located.
​
Once done, you can begin performing Conformal Geometric Algebra computations within Mathematica. For detailed usage examples and further information, refer to the tutorial available at: https://arxiv.org/abs/1711.02513.

Option 2

To install this paclet in your Wolfram Language environment, evaluate this code:
In[]:=
PacletInstall["Jlaragonvera/CGAlgebra"]
Out[]=
PacletObject
Name: Jlaragonvera/CGAlgebra
Version: 1.0.4

To load the code after installation, evaluate this code:
In[]:=
Needs["Jlaragonvera`CGAlgebra`"]
Once done, you can begin performing Conformal Geometric Algebra computations within Mathematica. For detailed usage examples and further information, refer to the tutorial available at:

2. Introduction

Calculations on conformal geometric algebra are implemented in the system using a rule-based programming paradigm. As a result, a tool is offered to perform calculations and manipulation of objects in this algebra.

Definition 1. (The conformal space)

The five-dimensional space spanned by {
e
0
,
e
1
,
e
2
,
e
3
,
e
∞
} with the inner product
⟨x,y⟩=x1y1+x2y2+x3y3−x0y∞−x∞y0,
(
1
)
for x = x0
e
0
+x1
e
1
+x2
e
2
+x3
e
3
+x∞
e
∞
, and y = y0
e
0
+y1
e
1
+y2
e
2
+y3
e
3
+ y∞
e
∞
, vectors in this space, is called the conformal space.
The inner product (1) has signature (4, 1) and the conformal space is the Minkowsky space
4,1
R
.
​
For the purpose of the Mathematica package developed here, a definition of the conformal geometric algebra based on generators and relations is more suitable.

Definition 2. (
4,1
G
)

The conformal geometric algebra
4,1
G
over
4,1
R
, equipped with the inner product (1), is an algebra generated by the identity 1 and the symbols {
e
0
,
e
1
,
e
2
,
e
3
,
e
∞
} by an associative multiplication operation called geometric product, and the following relations:
e
i
e
j
+
e
j
e
i
=0,​​
e
i
e
j0
+
e
0
e
i
=0,​​
e
i
e
∞
+
e
∞
e
i
=0,​​
2
e
i
=1,​​
e
0
e
∞
+
e
∞
e
0
=−2,​​
2
e
i
0
=
2
e
∞
=0,
(
2
)
for i,j = 1,2,3.
Another way to build the conformal geometric algebra
4,1
G
is to start with the Clifford algebra
4,1
C
over
4,1
R
, which is the five-dimensional space generated by {
e
1
,
e
2
,
e
3
,
e
4
,
e
5
} with the inner product
⟨x,y⟩=
x
1
y
1
+
x
2
y
2
+
x
3
y
3
+
x
4
y
4
−
x
5
y
5
,
(
3
)
for x =
x
1
e
1
+
x
2
e
2
+
x
3
e
3
+
x
4
e
4
+
x
5
e
5
, and y =
y
1
e
1
+
y
2
e
2
+
y
3
e
3
+
y
4
e
4
+
y
5
e
5
, vectors in
4,1
C
. In this space we now define the null vectors:
e
0
=
e
4
+
e
5
,and
e
∞
=
e
5
−
e
4
.
(
4
)
With this definition, the conformal geometric algebra
4,1
G
is the generated by {
e
0
,
e
1
,
e
2
,
e
3
,
e
∞
}. The inverse of the transformation (4) is
e
4
=
e
0
−e∞,and
e
5
=
e
0
+
e
∞
.
(
5
)
Both approaches are used in the Mathematica package.

Notation

In CGAlgebra, a basis element of the conformal space
e
i
is denoted by e[i]. With this notation,
4,1
G
{
e
0
,
e
1
,
e
2
,
e
3
,
e
∞
} is generated by {e[0],e[1],e[2],e[3],e[∞]}. The geometric product between basis elements
e
i
e
j
· · ·
e
k
will be denoted as e[i,j,....,k].

Details

The results of any calculation is given in terms of the geometric product of the basis elements, that is, the outer (Grassman) product of basis elements or multi-vectors is calculated by using
OuterProduct
and the output is given in terms of geometric product of basis vectors.

4. Examples

Basic Examples

We can check basic relationships like:
In[]:=
e[2,1]
Out[]=
-e[1,2]
In[]:=
e[∞,0]
Out[]=
-2-e[0,∞]
In[]:=
e[∞,∞]
Out[]=
0
In[]:=
e[0,0]
Out[]=
0
In[]:=
e[1,∞,2,0]
Out[]=
2e[1,2]+e[0,1,2,∞]
We can also operate arbitrary multivectors. For example If we consider the two vectors:
In[]:=
X=x0e[0]+x1e[1]+x2e[2]+x3e[3]+x∞e[∞];
In[]:=
Y=y0e[0]+y1e[1]+y2e[2]+y3e[3]+y∞e[∞];
The inner product will be:
In[]:=
InnerProduct[X,Y]
Out[]=
-x∞y0+x1y1+x2y2+x3y3-x0y∞
The outer product will be:
In[]:=
OuterProduct[X,Y]
Out[]=
-x∞y0+x0y∞-x1y0e[0,1]+x0y1e[0,1]-x2y0e[0,2]+x0y2e[0,2]-x3y0e[0,3]+x0y3e[0,3]-x∞y0e[0,∞]+x0y∞e[0,∞]-x2y1e[1,2]+x1y2e[1,2]-x3y1e[1,3]+x1y3e[1,3]-x∞y1e[1,∞]+x1y∞e[1,∞]-x3y2e[2,3]+x2y3e[2,3]-x∞y2e[2,∞]+x2y∞e[2,∞]-x∞y3e[3,∞]+x3y∞e[3,∞]
The geometric product will be:
In[]:=
GeometricProduct[X,Y]
Out[]=
x1y1+x2y2+x3y3-x1y0e[0,1]+x0y1e[0,1]-x2y0e[0,2]+x0y2e[0,2]-x3y0e[0,3]+x0y3e[0,3]+x∞y0(-2-e[0,∞])+x0y∞e[0,∞]-x2y1e[1,2]+x1y2e[1,2]-x3y1e[1,3]+x1y3e[1,3]-x∞y1e[1,∞]+x1y∞e[1,∞]-x3y2e[2,3]+x2y3e[2,3]-x∞y2e[2,∞]+x2y∞e[2,∞]-x∞y3e[3,∞]+x3y∞e[3,∞]

Some applications:

The direct representation of the sphere Σ, which passes through four points p1, p2, p3 and p4 s p1∧p2∧p3∧p4 is:
In[]:=
P1=x1e[1]+y1e[2]+z1e[3];​​P2=x2e[1]+y2e[2]+z2e[3];​​P3=x3e[1]+y3e[2]+z3e[3];​​P4=x4e[1]+y4e[2]+z4e[3];​​p1=e[0]+P1+(Magnitude[P1]/2)e[∞];​​p2=e[0]+P2+(Magnitude[P2]/2)e[∞];​​p3=e[0]+P3+(Magnitude[P3]/2)e[∞];​​p4=e[0]+P4+(Magnitude[P4]/2)e[∞];
In[]:=
directSphere=OuterProduct[p1,p2,p3,p4];
This equation can be written in terms of a point p that lies on the sphere as p∧Σ=0:
In[]:=
P=xe[1]+ye[2]+ze[3];​​p=e[0]+P+(Magnitude[P]/2)e[∞]
Out[]=
e[0]+xe[1]+ye[2]+ze[3]+
1
2
(
2
x
+
2
y
+
2
z
)e[∞]
In[]:=
sphere=OuterProduct[p,directSphere]==0;
If we use the points (x1,y1,z1)=(1,-1,3), (x2,y2,z2)=(4,1,-2), (x3,y3,z3)=(-1,-1,1) and (x4,y4,z4)=(1,1,1) we can get:
In[]:=
exsphere=sphere/.{x1->1,y1->-1,z1->3,x2->4,y2->1,z2->-2,x3->-1,y3->-1,z3->1,x4->1,y4->1,z4->1}//FullSimplify
Out[]=
(-4+(-5+x)x+y(5+y)+z+
2
z
)(e[1,2,3]-e[0,1,2,3,∞])0
In[]:=
s=z/.Solve[exsphere]
Out[]=

1
2
-1-
17+20x-4
2
x
-20y-4
2
y
,
1
2
-1+
17+20x-4
2
x
-20y-4
2
y
,z
In[]:=
Plot3D[s,{x,-5,10},{y,-10,5},PlotStyle->{{Pink,Opacity[.4]},{Pink,Opacity[.4]}}]
Out[]=
If we consider two spheres:
In[]:=
Y=x1e[1]+y1e[2]+z1e[3];​​Z=x2e[1]+y2e[2]+z2e[3];​​p1=e[0]+Y+(Magnitude[Y]/2)e[∞];​​p2=e[0]+Z+(Magnitude[Z]/2)e[∞];
With center Y=(−4,0,0) and Z=(−3,−1.1,1.3) and radius 𝑟1=2.5 y 𝑟2=1.3:
The intersection will be the circle:
With radius:
And center:
We obtain the intersection of the sphere.

5. List of Functions

Basic functions of CGAlgebra

◼
  • Grade[m, r] — Returns the r-vector part of the multivector m.
  • ◼
  • GradeQ[m, r] — Returns True if m is an r-vector.
  • ◼
  • GeometricProduct[m1, m2, ...] — Returns the geometric product of multivectors.
  • ◼
  • OuterProduct[m1, m2, ...] — Returns the outer (Grassmann) product.
  • ◼
  • InnerProduct[m1, m2] — Returns the inner product (left contraction).
  • Additional functions of CGAlgebra

    ◼
  • Reversion[m] — Computes the reversion of the multivector m.
  • ◼
  • Involution[m] — Returns the grade involution (denoted †) of m.
  • ◼
  • Magnitude[m] — Computes the magnitude of the multivector m.
  • ◼
  • MultivectorInverse[m] — Returns the inverse, if it exists.
  • ◼
  • GFactor[m] — Groups terms with common e[__].
  • ◼
  • Dual[m] — Returns the dual of m.
  • ◼
  • DDual[m] — De-dualizes the multivector m.
  • ◼
  • I5i — The inverse of I5.
  • ◼
  • MultiplicationTable[e] — Returns the multiplication table for the symbol e.
  • ◼
  • ToVector[v] — Transforms elements of the conformal space of the kind v=xe[1]+ye[2]+ze[e]
    to the standard Mathematica notation {x,y,x}
  • ◼
  • Rotation[x, a, b, θ] — Rotates vector x by angle θ (in radians) in the plane defined by a and b.
  • ◼
  • Arco[center, radius, normal, angle] — Plots an arc in 3D space.
  • ◼
  • circle3D[center, radius] — Plots a circle in 3D.
  • ◼
  • Centere[c] — Finds the center of a circle c in conformal notation.
  • ◼
  • Radio[c] — Finds the radius of a circle c in conformal notation.
  • CITE THIS NOTEBOOK

    CGAlgebra: a Mathematica package for conformal geometric algebra​
    By José Luis Aragón, Alejandra Ortiz Duran​
    Wolfram Community, STAFF PICKS, May 15, 2025
    ​https://community.wolfram.com/groups/-/m/t/3463173