Complex number manipulation in the 1456 object code system.

William Overington

Copyright 2000 William Overington

Complex numbers are an important aspect of mathematics and have important applications in various branches of science and engineering. Complex numbers are an advanced level of mathematics and I have thought for some time as to whether complex number manipulation should be included in the 1456 engine as a standard feature. In the event I have decided that it should be so included. The first matter to note however is that complex numbers are an advanced level of mathematics and that some people wishing to apply 1456 object code to the authoring of free to the end user distance education material, producing graphics and the like, may not have any knowledge of complex numbers or may not need to use them. Such readers may happily omit this section of this course on 1456 object code, as the commands introduced deal solely with the use of complex numbers in the 1456 object code system and if one chooses not to use those commands, then one may act as if they did not exist. However, readers might like to look at this demonstration of the complex numbers facility in use to generate a colour graphic representation of the Mandelbrot set.

demo11.htm

In implementing the manipulation of complex numbers in the 1456 object code system I have added a number of commands to the 1456 object code specification. Each of these commands is expressed using two characters, the first character of the pair being either a Z character or a z character. It is convenient to think of the processing of complex numbers within the 1456 engine as if they are being carried out in a separate area, a complex number courtyard so to speak. The reason for this is that commands beginning with Z involve moving data in and out of the courtyard and commands beginning with z involve manipulating complex numbers within the courtyard. The complex number courtyard interfaces with the rest of the 1456 engine using the ad1456 and bd1456 registers. The bi1456 register is also used to provide addressing data for z> and z< commands. Please note that although bi1456 is not within the complex number courtyard a z character is used for z> and z< because the data being manipulated is complex.

The 1456 engine is regarded as having az1456 and bz1456 registers and mz1456 storage from mz1456[0] to mz1456[99] inclusive. In fact, in the underlying Java coding two doubles are used for each complex number. As far as possible it is nice, mathematically elegant, to think of az1456, bz1456 and mz1456 as being complex variables. However, in order to get data in and out of the courtyard, one needs to think of az1456 and bz1456 as being composed or four doubles, namely azr1456, azi1456, bzr1456 and bzi1456, where the r and i in the register names represent real and imaginary parts. Let us begin by looking at those Z commands used in copying data into the complex registers. Each of ZU, ZV, ZX, ZY, Zu, Zv, Zx, Zy copy one double into part of a complex register. These commands are summarized in the table below. Please note that, for these eight instructions, those four with the second letter being a capital letter take the data from ad1456, whereas those four with the second letter being a lowercase letter take the data from bd1456. There is no Zw command, nor, indeed, is there a ZW command.

ZU azr1456 takes the value in ad1456
ZV azi1456 takes the value in ad1456
ZX bzr1456 takes the value in ad1456
ZY bzi1456 takes the value in ad1456
Zu azr1456 takes the value in bd1456
Zv azi1456 takes the value in bd1456
Zx bzr1456 takes the value in bd1456
Zy bzi1456 takes the value in bd1456

Let us continue by looking at those Z commands used in sending data into the complex registers, which also perform some calculation. These are Z* and Z/. These two instructions are provided so that a real number in bd1456 may be used to scale the data in az1456.

Z* az1456 is multiplied by the value in bd1456
Z/ az1456 is divided by the value in bd1456

Let us complete the Z commands by looking at those Z commands used in sending data from the complex register az1456 to ad1456, some of which also perform some calculation. These are ZR, ZI, Zr and Zt.

ZR ad1456 takes the real part of az1456
ZI ad1456 takes the imaginary part of az1456
Zr ad1456 takes the r part of the (r,theta) representation of az1456
Zt ad1456 takes the theta part of the (r,theta) representation of az1456

We may now look at the z commands, where the data is entirely complex numbers. These work in a similar manner to the way in which the commands for integers and doubles work. There are zw, z+, z-, z*, z/, zm, zd each of which alter az1456 depending what is in bz1456. These are summarized in the table.

zw az1456 takes the value of bz1456
z+ az1456 takes the value of az1456 + bz1456
z- az1456 takes the value of az1456 - bz1456
z* az1456 takes the value of az1456 * bz1456
z/ az1456 takes the value of az1456 / bz1456
zm az1456 takes the value of bz1456 - az1456
zd az1456 takes the value of bz1456 / az1456

The commands z> and z< are used for storing and retrieving complex numbers to and from the mz1456 memory locations.

z> az1456 is copied into mz1456[bi1456]
z< mz1456[bi1456] is copied into bz1456

In addition the 1456 object code provides a number of functions of a complex variable, where the value of az1456 is taken and replaced with the value of the chosen function for that argument.

zj az1456 takes the value of the complex conjugate of az1456
zr az1456 takes the value of the reciprocal of az1456, that is 1/az1456
zs az1456 takes the value of the sine of az1456
zc az1456 takes the value of the cosine of az1456
zt az1456 takes the value of the tangent of az1456
ze az1456 takes the value of the exponential of az1456
zn az1456 takes the value of the logarithm of az1456
zq az1456 takes the value of the square root of az1456
zi az1456 takes the value of the hyperbolic sine of az1456, that is the sinh function
zo az1456 takes the value of the hyperbolic cosine of az1456, that is the cosh function

In addition, it is also possible that other functions of a complex variable could be computed within a 1456 applet landscape by use of the software interrupt facility of 1456 object code. However, please note that there are no facilities provided for simulated direct memory access of complex numbers. In the event of such a function of a complex variable being desired, then the computation would need to be carried out by taking the complex argument out of the complex courtyard and passing it to the 1456 applet landscape as two doubles and returning the result as two doubles and then loading them into the complex courtyard. Thus, the desired effect could be achieved.

There are no comparison instructions provided for complex numbers. Comparisons are performed using the comparison commands for doubles, typically after either the real part of a complex number, or the imaginary part of a complex number, or the modulus value of a complex number have been produced in ad1456 using ZR, ZI or Zr respectively.

1456 object code

Copyright 2000 William Overington