Complex functions in True Basic?

How can I run complex functions in True Basic? Suppose
Z is a complex function, i.e., Z = A + i*B where
i = sqr(-1) and A and B are real numbers. I would like to define Z(,) as COMPLEX [i.e., Z(A,B)], and perform complex math (including functions), such as:

Z(A,B) = X(C,D)*Y(E,F) as well as

T(G,H) = tanh(Z(A,B)), where Z(,) X(,) Y(,) and T(,) are all complex numbers

I remember doing this in Fortran a long time ago

Comments

Bob_in_NM ... The text below is

Bob_in_NM ... The text below is what one sees on one's monitor when the complex number math program listing is RUN. Regards ... Tom M

1 0
0 1

0 -1
1 0

mat(i)+mat(j) = :
1 -1
1 1

mat(i)*mat(j) = :
0 -1
1 0

mat(i)/mat(j) = :
0 1
-1 0

mat [3*i] + mat[4*j] = :
3 -4
4 3

sqr([3*i] + [4*j]) = :
Magnitude = : 5
Angle = : 53.130102 deg

TB Complex number algebra revealed!!

! Bob_in_NM ... here's the TB code lines to get set up for doing
! vector analysis with complex numbers. Lets see if you can
! understand what the code is doing. Regards ... Tom M

OPTION BASE 0
OPTION ANGLE degrees

! create temporary (reuseable) 2D arrays needed for complex vector analysis
DIM m1(1,1), m2(1,1), m3(1,1), m4(1,1), m5(1,1) ! for "scratch" 2D arrays

! create unit-length complex number 2D arrays, i and j
DIM i(1,1), j(1,1) ! for unit-length real and imaginary 2D vector arrays
DATA 1, 0, 0, 1, 0, -1, 1, 0
MAT READ i, j
! All of the above program lines should be at the top of every
! complex algebra TB program
! Here we go ...
MAT PRINT i
MAT PRINT j
MAT m1=i+j
PRINT " mat(i)+mat(j) = :"
MAT PRINT m1
MAT m1=i*j
PRINT " mat(i)*mat(j) = :"
MAT PRINT m1
MAT m1=i
MAT m2=inv(j)
MAT m3=m2*i
PRINT " mat(i)/mat(j) = :"
MAT PRINT m3
PRINT
MAT m1=(3)*i
MAT m2=(4)*j
MAT m3=m1+m2
PRINT " mat [3*i] + mat[4*j] = :"
MAT PRINT m3
PRINT " sqr([3*i] + [4*j]) = :"
PRINT " Magnitude = :"; sqr(det(m3))
PRINT " Angle = :"; angle(m3(0,0),m3(1,0)); "deg"
END

Re: complex functions ...

Bob_in_NM ... Finally, there's someone else out there who works with complex number algebra!! That's the main reason I've stuck with True BASIC since 1987!

Even though past TB Gold versions come with a complex number "toolkit", it's really simple to do complex algebra (incluing graphics) with ANY version of TB, because every version of TB comes with MATRIX statements & functions.

It turns out that ANY complex number or variable, (a+j*b) or ( x+j*y) - (where j is the complex operator), can be represented as a 2-by-2 square matrix (array). Rather than replying to your TB Forum message with answers to all of your questions, I would rather reply to an email from you to me. I will answer your questions - and - attach TB program plain-text-listing(s) of programs I have written. I'm sure you will enjoy my SMITH CHART graphics program SMITH_D2.TRU, which prints a Smith Chart on your computer screen.

With complex number matrices, we can ADD, MULTIPLY & INVERT matrices, the three FUNDAMENTAL operations in matrix algebra.

I am an 82-year-old retired electrical engineer. I had a 40-year career in the aerospace industry, as a RF/microwave circuit designer for communication satellite & radio telermetry equipment. Regards ... Tom M