The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CayleyDickson - create and operate with hypercomplex numbers

SYNOPSIS

    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";

DESCRIPTION

    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 (+,-,/,*)

USAGE

new()

    # 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);

conjugate()

      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;

inverse()

      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;

norm()

      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;

add()

    # ass z1 + z2 = (a,b)+(c,d) = (a+c,b+d)
    
    printf "The sum of q1 + q2 is: %s\n", $q1 + $q2;

subtract()

    # subtract z1 - z2 =  (a,b)-(c,d) = (a-c,b-d)
    
    printf "The difference of q1 - q2 is: %s\n", $q1 - $q2;

divide()

    # divide z1 / z2 = z1 × inverse(z2)
    
    printf "The division of q1 / q2 is: %s\n", $q1 / $q2;

multiply()

    # 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;

new()

    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);

tensor()

    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.

a()

b()

    returns the two objects or numbers held by this object

flat()

    return all the coefficients of the number as an array
    
    printf "[%s]\n", join( ', ', $q1->flat); 

as_string()

    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;

i_squared()

    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

doubling_product()

    something

is_complex()

is_quaternion()

is_octonion()

is_sedenion()

is_trigintaduonions()

is_sexagintaquatronions()

is_centumduodetrigintanions()

is_ducentiquinquagintasexions()

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";
}

SUMMARY

    This object holds Cayley Dickson numbers and provides math operations on them.
    
    =back

AUTHOR

Jeff Anderson
truejeffanderson@gmail.com

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 662:

=back without =over

Around line 672:

You forgot a '=back' before '=head1'