=====================
Multi-Complex Numbers
=====================

=== Creating Multi-Complex Numbers ===

Multi-Complex numbers consist of a number of parts, the first of which is always the real part, the subsequent parts are the imaginary parts. The each imaginary unit is equal to the square root of -1, however if two different imaginary terms are multiplied together they do not equal the square root of -1.

The multicomplex number in Matlab is described as an array of real coefficients of the real term and all the imaginary
terms. An example of this is shown below for a C3 number
z3 = a + i_1 b + i_2 (c + i_1 d) + i_3 (e + i_1 f + (i_2 (g + i_1 h))) has the following terms z3: [a, b, c, d, e, f , g, h]

For convenience a function 'inputconverter' is provided which allows the creation of multicomplex numbers with only the i_n terms included, for the C3 case above, this means only a, b, c and e are non-zero. Running 'inputconverter(20, [1, 2, 3], 10^(?10))'
creates the multicomplex number 20 + 10^?10 i_1 + 10^?10 i_2 + 10^?10 i_3. This function is especially useful when higher order
derivatives are required. This function is not part of the class definition as it does not have a multicomplex type input
and is therefore a separate function.

=== How to use the class ===

To use the class make sure the matlab file "multicomplex" is in a directory "visible" to matlab. The file contains the multicomplex class, and also additional functions at the end of the file, which if you wish to use outside of the class definition can be cut and pasted into a new file. The class can then be used for the mathematical operators described below. Note that arrays and matrices of multicomplex numbers are not currently available in the class definition. If the matlab code you wish to operate with multicomple numbers uses the operators below it should be possible to replace the input of the real or complex input with the multicomplex input without further changes. Matlab functions such as the ODE and BVP solvers do not work with multicomplex numbers.

=== Multi-Complex Class ====

The multicomplex class includes the main mathematical functions for multicomplex numbers, these have the same names are the double operators in matlab such that exisiting code can readily used with mulitcomplex numbers as the input rather than single, double or complex types. They also include equality and inequality operators based on the real term only, to facilitate integration with exisiting code. The operators are,

plus,
minus,
uminus,
uplus
lt (less than)
gt (greater than)
le (less than or equal to)
ge (greater than or equal to)
eq (equality)
ne (not equal)
mtimes (multiplication of mulitcomplex number using matrix mulitplication method)
mrdivide (division of mulitcomplex number using matrix division method)
mpower (power of multicomplex number, power term may also be multicomplex type)
exp
log
sin
cos
tan
asin
acos
atan2
atan
sinh
cosh
mod

+++Class specific function +++

imagn(C)
This function essentially just extracts the 'last' imaginary term, or the one that contains all of the imaginary terms from multicomplex number C.

CX2(C,im,in)
This function extracts the coefficient of the user inputed imaginary part in im. Note that for the algorithm to work m>n. C is the multicomplex number you wan to extract the coefficient of Ex: CX2(C,3,4) extracts the i_3 i_4 coefficient of C. It is useful for second partial derivative calculation when using the class as part of the multicomplex step method.

[self,other] = consismulti(self,other)
Verifies that self and other are multicomplex, converts different sized multicomplex numbers into the same format. This funciton enables the operations between differently sized multicomplex numbers (and with realnumbers).

=== Example Cases ===

The example cases used in the paper can be run using the matlab scripts in the "DriverFiles.zip" folder. These scripts can be unpackaged and run directly to produce your own versions of the figures in the paper.

=== Unit Test ===

A class SolverTest.m was included, which uses the class-based unit test package matlab.unittest.TestCase, 
to aid in any future code optimisations. This tests every function inside the class definition. You can 
execute the tests running:

testCase = SolverTest; 
res = run(testCase)

This will give you the total number of tests passed, failed and incomplete. 