Hyperbolic numbers represented as a one-dimensional geometric algebra.
This module implements the split-complex (hyperbolic) numbers using the geometric algebra:
Cl(1,0)with signature:
{1}The basis element e1 acts as the hyperbolic unit:
j² = +1A hyperbolic number:
a + bjis represented as the multivector:
a + b*e1Unlike complex numbers, hyperbolic numbers contain zero divisors:
(1 + j)(1 - j) = 0because:
j² = 1Examples
iex> z = Galixir.Algebras.Hyper1.hyper(3, 2)
iex> Galixir.Algebras.Hyper1.real(z)
3.0
iex> z = Galixir.Algebras.Hyper1.hyper(3, 2)
iex> Galixir.Algebras.Hyper1.hyper_part(z)
2.0
Summary
Functions
Adds two multivectors component-wise.
Checks whether a multivector is a blade.
Returns the mapping between blade names and storage indices.
Returns the canonical sign of a multivector.
Returns the coefficient of a basis blade.
Computes the hyperbolic conjugate.
Returns the dimension of the algebra.
Computes the scalar product of two hyperbolic multivectors.
Computes the dual of a multivector.
Computes the hyperbolic exponential.
Computes the geometric product of two multivectors.
Extracts the grade-g component of a multivector.
Returns the grades present in a multivector.
Constructs a hyperbolic number.
Extracts the hyperbolic component.
Computes the inner product of two multivectors.
Computes the multiplicative inverse.
Computes the inverse of a multivector.
Returns the hyperbolic unit.
Computes the principal hyperbolic logarithm.
Returns the maximum absolute coefficient of a multivector.
Returns the norm of a multivector.
Computes the squared norm.
Normalizes a multivector.
Returns the multiplicative identity
Computes hyperbolic exponentiation.
Extracts the real component.
Applies the reverse operation to a multivector.
Checks whether a multivector contains only a scalar component.
Returns the scalar coefficient of a multivector.
Computes the scalar product of two multivectors.
Returns the metric signature of the algebra.
Returns the number of coefficients stored by the algebra.
Returns the squared norm of a multivector.
Subtracts two multivectors component-wise.
Returns the multiplication table for the algebra.
Formats a multivector using standard geometric algebra notation.
Computes the inverse dual operation.
Computes the outer product (wedge product) of two multivectors.
Returns the zero hyperbolic number
Checks whether all coefficients of a multivector are zero.
Functions
Adds two multivectors component-wise.
Examples
iex> a = Galixir.Algebras.Hyper1.new(scalar: 2)
iex> b = Galixir.Algebras.Hyper1.new(scalar: 3)
iex> Galixir.Algebras.Hyper1.add(a, b)
Galixir.Algebras.Hyper1.new(scalar: 5)
Checks whether a multivector is a blade.
A blade is a multivector containing components from at most one grade.
Scalars are considered blades.
Examples
iex> Galixir.Algebras.Hyper1.blade?(Galixir.Algebras.Hyper1.new(e1: 2))
true
iex> Galixir.Algebras.Hyper1.blade?(Galixir.Algebras.Hyper1.new(scalar: 2))
true
iex> Galixir.Algebras.Hyper1.blade?(Galixir.Algebras.Hyper1.new(scalar: 2, e1: 1))
false
Returns the mapping between blade names and storage indices.
Blade coefficients are stored in a fixed-size tuple. This map translates canonical blade names into their corresponding tuple index.
Example
iex> Galixir.Algebras.Hyper1.blade_indices()[:e1]
1
Returns the canonical sign of a multivector.
The canonical sign is determined by the first non-zero coefficient in storage order.
Returns:
1if the first non-zero coefficient is positive-1if the first non-zero coefficient is negative0if all coefficients are zero
Examples
iex> Elixir.Galixir.Algebras.Hyper1.canonical_sign(Elixir.Galixir.Algebras.Hyper1.new(e1: 2))
1
iex> Elixir.Galixir.Algebras.Hyper1.canonical_sign(Elixir.Galixir.Algebras.Hyper1.new(e1: -2))
-1
iex> Elixir.Galixir.Algebras.Hyper1.canonical_sign(Elixir.Galixir.Algebras.Hyper1.new())
0
Returns the coefficient of a basis blade.
The requested blade can be given in canonical form or as any registered blade alias. Aliases are automatically converted to the canonical blade and the appropriate sign is applied.
## Examples
iex> Elixir.Galixir.Algebras.Hyper1.coefficient( ...> Elixir.Galixir.Algebras.Hyper1.new(e1: 3), ...> :e1 ...> ) 3.0
Computes the hyperbolic conjugate.
For:
z = a + bjreturns:
z̄ = a - bj
Returns the dimension of the algebra.
This is the number of basis vectors defined by the signature.
Computes the scalar product of two hyperbolic multivectors.
Computes the dual of a multivector.
The dual maps each basis blade to its complementary blade with the appropriate orientation sign. The complement is determined by the full pseudoscalar of the algebra.
The operation is linear and applies independently to every coefficient.
Examples
iex> Galixir.Algebras.Hyper1.dual(Galixir.Algebras.Hyper1.new(e1: 1)) |> inspect Galixir.Algebras.Hyper1.new(scalar: 1.0) |> inspect
Computes the hyperbolic exponential.
For:
z = a + bjreturns:
exp(z) =
exp(a)(cosh(b) + j*sinh(b))
Computes the geometric product of two multivectors.
The geometric product is the fundamental multiplication operation of geometric algebra. It combines the outer product and metric-dependent inner product into a single associative operation.
The result depends on the algebra's metric signature.
Examples
iex> Galixir.Algebras.Hyper1.gp(
...> Galixir.Algebras.Hyper1.new(e1: 1),
...> Galixir.Algebras.Hyper1.new(e1: 1)
...> )
Galixir.Algebras.Hyper1.new(scalar: 1)
Extracts the grade-g component of a multivector.
All coefficients whose basis blades are not of grade g are set to zero.
Raises ArgumentError if g is outside the range 0..dimension().
Examples
iex> Galixir.Algebras.Hyper1.grade(
...> Galixir.Algebras.Hyper1.new(scalar: 1, e1: 2),
...> 1
...> )
Galixir.Algebras.Hyper1.new(e1: 2)
iex> Galixir.Algebras.Hyper1.grade(
...> Galixir.Algebras.Hyper1.new(scalar: 1, e1: 2),
...> 0
...> )
Galixir.Algebras.Hyper1.new(scalar: 1)
Returns the grades present in a multivector.
The returned list contains every grade with at least one non-zero coefficient, ordered from lowest to highest.
Examples
iex> Galixir.Algebras.Hyper1.grades(
...> Galixir.Algebras.Hyper1.new(scalar: 1)
...> )
[0]
iex> Galixir.Algebras.Hyper1.grades(
...> Galixir.Algebras.Hyper1.new(e1: 2)
...> )
[1]
iex> Galixir.Algebras.Hyper1.grades(
...> Galixir.Algebras.Hyper1.new(scalar: 1, e1: 2)
...> )
[0, 1]
iex> Galixir.Algebras.Hyper1.grades(
...> Galixir.Algebras.Hyper1.new()
...> )
[]
Constructs a hyperbolic number.
Creates:
real + hyper* j
Extracts the hyperbolic component.
This is the coefficient of the hyperbolic unit j.
Computes the inner product of two multivectors.
The inner product retains only those terms of the geometric product whose grade is the absolute difference of the operand grades.
For homogeneous blades A and B:
grade(inner(A, B)) = |grade(A) - grade(B)|The exact result depends on the metric signature of the algebra.
Examples
iex> Galixir.Algebras.Hyper1.inner(
...> Galixir.Algebras.Hyper1.new(e1: 2),
...> Galixir.Algebras.Hyper1.new(e1: 3)
...> )
Galixir.Algebras.Hyper1.new(scalar: 6)
Computes the multiplicative inverse.
The inverse exists only when:
a² - b² != 0Hyperbolic numbers on the null cone are zero divisors and cannot be inverted.
Computes the inverse of a multivector.
The inverse is computed using the reverse:
inverse(a) = reverse(a) / scalar_part(a * reverse(a))
This formula is valid when a * reverse(a) is a non-zero scalar.
Raises ArgumentError if the multivector is not invertible by this formula.
## Examples
iex> Galixir.Algebras.Hyper1.inverse(
...> Galixir.Algebras.Hyper1.new(e1: 2)
...> )|> inspect
Galixir.Algebras.Hyper1.new(e1: 0.5) |> inspect
Returns the hyperbolic unit.
The unit satisfies:
j² = 1
Computes the principal hyperbolic logarithm.
Returns:
log(z) =
log(|z|) + atanh(b/a)j
Returns the maximum absolute coefficient of a multivector.
Accepts either a multivector struct or the internal coefficient tuple.
Example
iex> Elixir.Galixir.Algebras.Hyper1.max_abs_component(Elixir.Galixir.Algebras.Hyper1.new(e1: 2, scalar: 5))
5.0
iex> Elixir.Galixir.Algebras.Hyper1.max_abs_component(Elixir.Galixir.Algebras.Hyper1.new(e1: 5, scalar: 2))
5.0
Returns the norm of a multivector.
The norm is the square root of the absolute squared norm.
Example
iex> a = Galixir.Algebras.Hyper1.new(scalar: 3)
iex> Galixir.Algebras.Hyper1.norm(a)
3.0
Computes the squared norm.
For:
z = a + bjreturns:
|z|² = a² - b²The norm is not positive definite because hyperbolic numbers have an indefinite metric.
Normalizes a multivector.
The result has unit norm while preserving the direction of the multivector.
Raises ArgumentError when attempting to normalize a null
multivector.
Example
iex> a = Galixir.Algebras.Hyper1.new(scalar: 2)
iex> Galixir.Algebras.Hyper1.norm(Galixir.Algebras.Hyper1.normalize(a))
1.0
Returns the multiplicative identity:
1 + 0j
Computes hyperbolic exponentiation.
Calculates:
z^t = exp(t * log(z))
Extracts the real component.
Applies the reverse operation to a multivector.
Reverse (also called reversion) changes the sign of basis blades according to their grade:
grade 0: +
grade 1: +
grade 2: -
grade 3: -
grade 4: +
...For a blade with grade r, the sign is:
(-1)^(r(r-1)/2)Examples
iex> Galixir.Algebras.Hyper1.reverse(Galixir.Algebras.Hyper1.new(e1: 2)) |> inspect
Galixir.Algebras.Hyper1.new(e1: 2)|> inspect
iex> Galixir.Algebras.Hyper1.reverse(Galixir.Algebras.Hyper1.new(scalar: 3))|> inspect
Galixir.Algebras.Hyper1.new(scalar: 3)|> inspect
Checks whether a multivector contains only a scalar component.
Components with an absolute value smaller than eps are considered
zero.
Examples
iex> Galixir.Algebras.Hyper1.scalar?(Galixir.Algebras.Hyper1.new(scalar: 3))
true
iex> Galixir.Algebras.Hyper1.scalar?(Galixir.Algebras.Hyper1.new(e1: 3))
false
iex> Galixir.Algebras.Hyper1.scalar?(Galixir.Algebras.Hyper1.new())
true
Returns the scalar coefficient of a multivector.
This is equivalent to retrieving the coefficient of the scalar blade.
Examples
iex> Elixir.Galixir.Algebras.Hyper1.scalar_part(Elixir.Galixir.Algebras.Hyper1.new(scalar: 5.0, e1: 2.0))
5.0
Computes the scalar product of two multivectors.
The scalar product is the grade-0 component of the geometric product:
<a b>₀The result depends on the metric signature of the algebra. In particular, basis vectors with negative or null squares affect the result.
Examples
iex> Galixir.Algebras.Hyper1.scalar_product(
...> Galixir.Algebras.Hyper1.new(e1: 2),
...> Galixir.Algebras.Hyper1.new(e1: 3)
...> )
6.0
Returns the metric signature of the algebra.
Example:
{1, 1, 1, 0}represents a projective geometric algebra with three Euclidean basis vectors and one null basis vector.
Returns the number of coefficients stored by the algebra.
A dimension n algebra contains 2^n basis blades.
Returns the squared norm of a multivector.
The squared norm is computed as:
scalar_part(a * reverse(a))The result may be negative for algebras with indefinite metrics.
Example
iex> a = Galixir.Algebras.Hyper1.new(scalar: 3)
iex> Galixir.Algebras.Hyper1.squared_norm(a)
9.0
Subtracts two multivectors component-wise.
Examples
iex> a = Galixir.Algebras.Hyper1.new(scalar: 5)
iex> b = Galixir.Algebras.Hyper1.new(scalar: 2)
iex> Galixir.Algebras.Hyper1.sub(a, b)
Galixir.Algebras.Hyper1.new(scalar: 3)
Returns the multiplication table for the algebra.
The table contains precomputed geometric products between basis blades.
Each entry maps {left_blade, right_blade} to {coefficient, result_blade}.
The blades are represented internally as bitmasks.
Example
iex> Galixir.Algebras.Hyper1.table() |> Map.has_key?({1, 1})
true
Formats a multivector using standard geometric algebra notation.
Zero coefficients are omitted. Coefficients of 1 and -1 are elided for
non-scalar basis blades.
Examples
iex> inspect(Galixir.Algebras.Hyper1.new())
"0"
iex> inspect(Galixir.Algebras.Hyper1.new(scalar: 2))
"2.0"
iex> inspect(Galixir.Algebras.Hyper1.new(e1: 1))
"e1"
iex> inspect(Galixir.Algebras.Hyper1.new(scalar: 1, e1: 2))
"1.0 + 2.0e1"
Computes the inverse dual operation.
undual/1 reverses the blade complement operation performed by dual/1.
For non-degenerate Euclidean algebras this corresponds to applying the dual operation twice with the appropriate pseudoscalar factor. In degenerate algebras the result depends on the implemented dual convention.
Examples
iex> Galixir.Algebras.Hyper1.undual(Galixir.Algebras.Hyper1.dual(Galixir.Algebras.Hyper1.new(e1: 2)))
Galixir.Algebras.Hyper1.new(e1: 2)
Computes the outer product (wedge product) of two multivectors.
The wedge product combines blades by joining their basis vectors. It is antisymmetric:
a ∧ b = -(b ∧ a)and vanishes when the operands share a basis vector.
Examples
iex> Galixir.Algebras.Hyper1.wedge(
...> Galixir.Algebras.Hyper1.new(e1: 1),
...> Galixir.Algebras.Hyper1.new(e1: 1)
...> )
Galixir.Algebras.Hyper1.new()
Returns the zero hyperbolic number:
0 + 0j
Checks whether all coefficients of a multivector are zero.
Examples
iex> Galixir.Algebras.Hyper1.zero?(Galixir.Algebras.Hyper1.new())
true
iex> Galixir.Algebras.Hyper1.zero?(Galixir.Algebras.Hyper1.new(e1: 1))
false