CayleyDickson - create and operate with hypercomplex numbers
use Tangle; my $q1 = Tangle->new(1,0); print "q1 = $q1\n"; $q1->x_gate; print "X(q1) = $q1\n"; $q1->hadamard; print "H(X(q1)) = $q1\n"; my $q2 = Tangle->new(1,0); print "q2 = $q2\n"; # perform CNOT($q1 ⊗ $q2) $q1->cnot($q2); print "q1 = $q1\n"; print "q2 = $q2\n"; $q1->x_gate; print "X(q1) = $q1\n"; print "entanglement causes q2 to automatically changed: $q2\n";
Cayley-Dickson construction and operations are defined here: https://en.wikipedia.org/wiki/Cayley–Dickson_construction This object provides natural and intuitive operations on these numbers by overriding the native numeric operations (+,-,/,*)
# create a new CayleyDickson number "i" ... my $q1 = CayleyDickson->new(0,1); # create a new CayleyDickson number "1+2i+3j+4k" ... my $q2 = CayleyDickson->new(1,2,3,4); # create a bigger CayleyDickson number (a Sedenion) ... my $q3 = CayleyDickson->new(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); # create a CayleyDickson number from others ... my $one = CayleyDickson->new(0,1); my $zero = CayleyDickson->new(1,0); my $quaternion = CayleyDickson->new($one,$zero);
if z = (a,b) then conjugate z = z* = (a,b)* = (a*,-b) or conjugate(number) = number printf "The conjugate of q1 is: %s\n", $q1->conjugate;
if z = (a,b) then inverse z = z⁻¹ = (a,b)⁻¹ = (a,b)*/(norm(a,b)²) or inverse(number) = number printf "The inverse of q1 is: %s\n", $q1->inverse;
if z = (a,b) then norm z = norm(a,b) = √(norm(a)²+norm(b)²) or norm(number) = number printf "The norm of q1 is: %s\n", $q1->norm;
# ass z1 + z2 = (a,b)+(c,d) = (a+c,b+d) printf "The sum of q1 + q2 is: %s\n", $q1 + $q2;
# subtract z1 - z2 = (a,b)-(c,d) = (a-c,b-d) printf "The difference of q1 - q2 is: %s\n", $q1 - $q2;
# divide z1 / z2 = z1 × inverse(z2) printf "The division of q1 / q2 is: %s\n", $q1 / $q2;
# Multiply: (a,b)×(c,d) = (a×c - d*×b, d×a + b×c*) where x* = conjugate(x) or x if x is a number printf "The product of q1 * q2 is: %s\n", $q1 * $q2;
create a new CayleyDickson number of any size ... # create the number 1+j-k ... my $c = CayleyDickson->new( -1, 0, 1, -1 ); # create an octonion ... my $c = CayleyDickson->new( 3, 7, -2, 8, 0, 3, 3, 5 ); # create a representation of the Horne bell state |+-> ... my $c = CayleyDickson->new( 1/2, 1/2, 1/2 ,-1/2 ); # create a 128 number construction: 1+2i+3j+4k+ .. + 128 .... my $c = CayleyDickson->new(1 .. 128);
Tensors two Cayley Dickson numbers to calculate a new number of higher dimensional construction. reference: https://en.wikipedia.org/wiki/Tensor_product # calculate the tensor of c1 ⊗ c2 ... $d = $c1->tensor($c2); $d will be a number of the product of the dimensions of c1 and c2.
returns the two objects or numbers held by this object
return all the coefficients of the number as an array printf "[%s]\n", join( ', ', $q1->flat);
called automatically when this object is requested in a string form. if you want to force the object to be resolved as a string ... printf "q1 as a string = %s\n", $q1->as_string;
returns the square of i: i² = -1 normally this will be -1, but you can change it to +1 or 0 using the constant I_SQUARED
something
returns true if the given object has depth equal to the function name if ($q1->is_octionion) { print "q1 is an Octonion\n"; } else { print "q1 is NOT an Octonion\n"; }
This object holds Cayley Dickson numbers and provides math operations on them. =back
Jeff Anderson truejeffanderson@gmail.com
2 POD Errors
The following errors were encountered while parsing the POD:
=back without =over
You forgot a '=back' before '=head1'
To install CayleyDickson, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CayleyDickson
CPAN shell
perl -MCPAN -e shell install CayleyDickson
For more information on module installation, please visit the detailed CPAN module installation guide.