**complex_numbers_test**,
a Python code which
demonstrates some of the features of using complex numbers.

The first issue is how to declare a complex variable, including the choice of precision, whether the variable is a scalar, vector, or array, and whether the variable is initialized with a value, or assigned one.

A second issue concerns the question of how a complex variable is to be printed out.

Another issue concerns how a complex variable is to operated on by the arithmetic operators of addition, subtraction, multiplication, division, and exponentiation.

The language also provides a number of intrinsic functions that can be applied to a complex variable. The names of these functions can sometimes be easy to forget.

Another issue concerns the details of double precision calculation. Even a single accidental use of a single precision function name in a double precision computation can result in the loss of half the digits of accuracy.

An unusual feature of the implementation of complex numbers in Python is that a complex number can be defined by a statement like

z = 1 + 2j;where the string "2j" is interpreted as "2 times the imaginary unit". But this does NOT mean that j by itself means the imaginary unit. No, the imaginary unit is represented by "1j". So you cannot set the imaginary unit by

a = j;Instead, you would have to write

a = 1j;

The computer code and data files described and made available on this web page are distributed under the MIT license

**complex_numbers_test** is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.

c8lib, a Python code which implements certain elementary functions for "C8" or double precision complex variables;

- complex_numbers_test.py, the source code.
- complex_numbers_test.sh, runs all the tests.
- complex_numbers_test.txt, the output file;