﻿ User Guide > Complex Variables

Complex Variables   In previous versions of FlexPDE, it has been possible to treat complex variables and equations by declaring each component as a VARIABLE and writing a real PDE for each complex component.

In version 6 and later, FlexPDE understands complex variables and makes provision for treating them conveniently.

The process starts by declaring a variable to be COMPLEX, and naming its components:

VARIABLES

C = COMPLEX(Cr,Ci)

Subsequently, the complex variable C can be referenced by name, or its components can be accessed independently by their names.

In the EQUATIONS section, each complex variable can be given an equation, which will be interpreted as dealing with complex quantities.  The complex equation will be processed by FlexPDE and reduced to two real component equations, by taking the real and imaginary parts of the resulting complex equation.

For example, the time-harmonic representation of the heat equation can be presented as

EQUATIONS

C:   DIV(k*GRAD(C)) - COMPLEX(0,1)*C = 0

Alternatively, the individual components can be given real equations:

EQUATIONS

Cr: DIV(k*GRAD(Cr)) + Ci = 0
Ci: DIV(k*GRAD(Ci)) - Cr = 0

In a similar way, boundary conditions may be assigned either to the complex equation or to each component equation individually:

VALUE(C) = COMPLEX(1,0)        assigns 1 to the real part and 0 to the imaginary part of C

or

VALUE(Cr) = 0   NATURAL(Ci) = 0

Any parameter definition in the DEFINITIONS section may be declared COMPLEX as well:

DEFINITIONS

complexname = COMPLEX(realpart, imaginarypart)

FlexPDE recognizes several fundamental complex operators:

 REAL ( complex ) Extracts the real part of the complex number. IMAG ( complex ) Extracts the imaginary part of the complex number. CARG ( complex ) Computes the Argument (or angular component) of the complex number, implemented as CARG(complex(x,y)) = Atan2(y,x). CONJ ( complex ) Returns the complex conjugate of the complex number. CEXP ( complex ) Computes the complex exponential of the complex number, given by CEXP(complex(x,y)) = exp(x+iy) = exp(x)*(cos(y)+i*sin(y)).

COMPLEX quantities can be the arguments of PLOT commands, as well.  Occurrence of a complex quantity in a PLOT statement will be interpreted as if the real and imaginary parts had been entered separately in the PLOT command.

ELEVATION(C) FROM A TO B

will produce a plot with two traces, the real and imaginary parts of C.