Nion is a library for hyper-complex arithmetic. It is written in C++ and is designed to be portable and fast. It is a header-only library, so there is no need to compile it. It is licensed under the Apache License.
The Nion is a generalization of complex numbers to higher degrees. Nions form a division algebra up to degree 3, and more generally a Subalgebra of the Hypercomplex numbers.
The Nion is defined as a Cayley-Dickson construction. A nion of degree n is defined as the pairing of two nions of degree n-1. Each degree doubles the number of dimensions (i.e. 2n) and removes symmetries from the algebra.
- The Reals are a Nion of degree 0, which is a single real number.
- Complex numbers are a Nion of degree 1, which is the pairing of two reals.
- Complex numbers are no longer an ordered field.
- The Quaternions are a Nion of degree 2, which is the pairing of two complex numbers.
- Quaternions lose the commutative property of multiplication.
- The Octonions are a Nion of degree 3, which is the pairing of two quaternions.
- Octonions lose the associative property of multiplication.
- The Sedenions are a Nion of degree 4, which is the pairing of two octonions.
- Sedenions (and higher order nions) lose the alternative property of multiplication and can have zero divisors.
Nions support the generalization of complex numbers to even higher arbitrary degrees. While the higher order nions are not as well known as the lower order nions, they exhibit emergent properties that have potential applications in physics, computer graphics, and other fields.
Nions have the following properties:
- They form a Subalgebra. That is, they have the following properties:
- The nions form a vector space.
- The identity element belongs to the set of nions.
- The product of two nions is a nion (i.e., the nions form a ring).
- The inverse element of a nion is a nion.
- The product of a nion and its inverse is the identity.
Nions can be used to improve the accuracy and efficiency of machine learning, and to accomplish tasks that cannot be done with real or complex numbers.
Nion is licensed under the Apache License. See the LICENSE file for more information.
- [Nion] - A Library for Hyper-Complex Arithmetic
- Usage
- Examples
- Contributing
- License
- How to Cite
- References
- More Information
nion = nion + nion
nion = nion - nion
nion = nion * nion
nion = nion / nion
nion = nion + scalar
nion = nion - scalar
nion = nion * scalar
nion = nion / scalar
nion++
nion--
nion.conj
nion.inv
nion.abs
nion.norm
nion.real
nion.imag
nion.resize
nion.is_real
exp(nion)
log(nion)
pow(nion)
sqr(nion)
sqrt(nion)
cbrt(nion)
sin(nion)
sinh(nion)
cos(nion)
cosh(nion)
tan(nion)
tanh(nion)
cot(nion)
coth(nion)
sec(nion)
sech(nion)
csc(nion)
csch(nion)
asin(nion)
asinh(nion)
acos(nion)
acosh(nion)
atan(nion)
atanh(nion)
acot(nion)
acoth(nion)
asec(nion)
asech(nion)
acsc(nion)
acsch(nion)
- Addition
nion<float> a = {1, 2, 3, 4};
nion<float> b = {5, 6, 7, 8};
nion<float> c = a + b;
std::cout << "a + b = " << c << std::endl; // (6,8,10,12)
- Subtraction
nion<float> a = {1, 2, 3, 4};
nion<float> b = {5, 6, 7, 8};
nion<float> c = a - b;
std::cout << "a - b = " << c << std::endl; // (-4,-4,-4,-4)
- Multiplication
nion<float> a = {1, 2, 3, 4};
nion<float> b = {5, 6, 7, 8};
nion<float> c = a * b;
std::cout << "a * b = " << c << std::endl; // (-60,12,30,24)
- Division
nion<float> a = {1, 2, 3, 4};
nion<float> b = {5, 6, 7, 8};
nion<float> c = a / b;
std::cout << "a / b = " << c << std::endl; // (0.402299,0.045977,0,0.091954)
- Increment
nion<float> a = {1, 2, 3, 4};
nion<float> b = ++a;
std::cout << "++a = " << b << std::endl; // (2,2,3,4)
- Decrement
nion<float> a = {1, 2, 3, 4};
nion<float> b = --a;
std::cout << "--a = " << b << std::endl; // (0,2,3,4)
- Conjugation
nion<float> a = {1, 2, 3, 4};
nion<float> b = a.conj();
std::cout << "a.conj() = " << b << std::endl; // (1,-2,-3,-4)
- Inversion
nion<float> a = {1, 2, 3, 4};
nion<float> b = a.inv();
std::cout << "a.inv() = " << b << std::endl; // (0.0333333,-0.0666667,-0.1,-0.133333)
- Absolute Value
nion<float> a = {1, 2, 3, 4};
float b = a.abs();
std::cout << "a.abs() = " << b << std::endl; // 30
- Norm
nion<float> a = {1, 2, 3, 4};
float b = a.norm();
std::cout << "a.norm() = " << b << std::endl; // 5.47723
- Real Component
nion<float> a = {1, 2, 3, 4};
float b = a.real();
std::cout << "a.real() = " << b << std::endl; // 1
- Imaginary Component
nion<float> a = {1, 2, 3, 4};
nion<float> b = a.imag();
std::cout << "a.imag() = " << b << std::endl; // (0,2,3,4)
- Resize
nion<float> a = {1, 2, 3, 4};
nion<float> b = a.resize(8);
std::cout << "a.resize(8) = " << b << std::endl; // (1,2,3,4,0,0,0,0)
- Is Real
nion<float> a = {1, 2, 3, 4};
nion<float> b = {2, 0};
std::cout << "a.is_real() = " << a.is_real() << std::endl; // false
std::cout << "b.is_real() = " << b.is_real() << std::endl; // true
- Exponential
nion<float> a = {1, 2, 3, 4};
nion<float> b = exp(a);
std::cout << "exp(a) = " << b << std::endl; // (1.69392,-0.78956,-1.18434,-1.57912)
- Logarithm
nion<float> a = {1, 2, 3, 4};
nion<float> b = log(a);
std::cout << "log(a) = " << b << std::endl; // (1.7006,0.51519,0.772785,1.03038)
- Power
nion<float> a = {1, 2, 3, 4};
nion<float> b = pow(a, -2);
std::cout << "pow(a, -2) = " << b << std::endl; // (-0.0311111,-0.00444444,-0.00666667,-0.00888889)
- Sine
nion<float> a = {1, 2, 3, 4};
nion<float> b = sin(a);
std::cout << "sin(a) = " << b << std::endl; // (91.7837,21.8865,32.8297,43.773)
- Cosine
nion<float> a = {1, 2, 3, 4};
nion<float> b = cos(a);
std::cout << "cos(a) = " << b << std::endl; // (58.9336,-34.0862,-51.1293,-68.1724)
- Tangent
nion<float> a = {1, 2, 3, 4};
nion<float> b = tan(a);
std::cout << "tan(a) = " << b << std::endl; // (3.82662e-05,0.371397,0.557096,0.742794)
Please feel free to contribute.
This project is licensed under the Apache License, Version 2.0 - see the LICENSE.md file for details
When using Nion for research projects, please cite:
@misc{NionAlgebra,
author = {Marcus Dante Liebenthal},
title = {{Nion}: A Library for Hyper-Complex Arithmetic},
month = {December},
year = {2022},
url = {https://github.com/Marclie/nion}
}