C++ code to perform the Lorentz boosts and rotations of special relativity using complex quaternions The interface is a complex quaternion console-based calculator with operations + - * / ^ and functions for Lorentz boosts and rotations.
THEORY
Complex quaternions have form q = A + B * I + C * J + D * K with A, B, C, D complex
I * I = -1 , J * J = -1 , K * K = -1, I * J = K, J * I = -K , J * K = I,K * J = -I, K * I = J, I * K = -J
Transpose T takes I into -I, J into -J, K into -K
(q1 q2)T = q2T q1T
Star complex conjugates A, B, C, D
Bar is product of T and Star,
Norm(q) = qTq
Norm(q1*q2)=Norm(q1)*Norm( q2)
q in H1 iff q qT = qT q = 1
4-vector X=t + i*x*I +i*y*J + i*z*K
XPRIME = q X Bar(q) for q in H1
Form with real scalar, imaginary spatial is preserved
Bar(X) = X and Bar(XPRIME )= XPRIME
Norm(XPRIME) = Norm(X) = t*t - x*x - y*y - z*z
q=cos(theta/2)+K*sin(theta/2) rotates by theta about z
q=cosh(alpha/2)+i*I*sinh(alpha/2) boosts by alpha along x
Features
- Interface is a complex quaternion calculator with console command line.
- Lorentz boosts and rotations on 4-vectors performed using complex quaternion transformation functions. Thomas precession is easily calculated.
- Calculator has + - * ^ / (No x/y if Norm(y)=0. No x^y if x and y don't commute),
- Calculator has scientific notation and many functions defined for quaternion arguments, such as exp, sqrt, log, cos, sin, tan, sec, csc, cot, acos, asin, atan, asec, acsc, acot, cosh, sinh, tanh, sech, csch, coth, acosh, asinh, atanh, asech, acsch, acoth
- Variables can simultaneously be complex quaternions, arrays of complex quaternions, and strings for user-defined functions or command sequences
- Arrays up to ten dimensions with definition by equation, resizing, mapping
- User defined functions. Execute commands strings with loop count and flag test.
- Help, bash .sh compile and link scripts, Lorentz theory and math explanations can be displayed by the calculator
- Uses namespaces and C++ classes such as class Quaternion and class Calculator with overloaded operators. Hash table for variable and function names with linked lists for collisions.
- Uses STL template libraries such as <complex> and <vector>
- Builds with WSL2 Ubuntu and Debian g++ and with Raspberry Pi g++ for Unix and with mingw-w64 package's x86_64-w64-mingw32-g++ cross-platform compiler and linker for Microsoft Windows 11. This cross-platform compiler and linker can be installed on WSL2 Ubuntu and Debian and on the Raspberry Pi.
- System commands can be done by having the exclamation mark as the first character, such as !clear in Unix and !cls in Windows
- Multi-line system commands can be executed from a file
- Multi-line calculator commands can be executed from a file