Contents - Index

Complex Numbers


EES is able to solve equations involving complex variables in the Main program and in SubprogramsFunctions, Modules, and Procedures cannot operate in complex mode.  Procedures (but not functions) can be called from the main program or Subprogram regardless of whether or not they are in complex mode.  


EES will solve equations involving complex variables of the form a+b*i if the Do Complex Algebra control in the Complex tab of the Preferences dialog is checked or if a $COMPLEX ON directive is placed within the equations of the main program.  The imaginary number operator may be set to either i or j in the Preferences dialog or with the $COMPLEX directive, although i is used in the following discussion.


Whet set in complex mode, every (non-string) EES variable is represented internally as two variables corresponding to the real and imaginary parts.  The real part is identified by appending _r to the variable name.  The imaginary part has an appended _i.  If, for example, you enter the equation




EES will create variables X_r, X_i, Y_r and Y_i corresponding to the real and imaginary components of the variables.  You will normally not have to refer to the renamed variables, although they will appear with these names in the Variable Info and New Parametric Table dialogs, as well as in column headers of the Parametric Table.  However, you can set the value of a real or imaginary part of a complex number by entering the real or imaginary variable name on the left of an equation in the Equations window. For example, the following equation will set the imaginary part of variable omega to 0.  




Any later attempt to set the imaginary part of omega will cause EES to display an error message.  If, for example, you also enter the equation, omega = 3 in the Equations window, EES will present an error message when you attempt to solve because the omega=3 equation sets both the real and imaginary parts of omega and the imaginary part would have already been set.  You could, of course, enter omega_r=3.


Complex numbers can be entered in either rectangular or polar form.  In rectangular form, the complex number is entered using the imaginary number operator (i or j) with a multiplication symbol (*) separating the imaginary number operator from variables or constants.  A complex constant can be entered in polar form by entering the magnitude (also called absolute value) of the number and the angle separated with the < symbol.  The < character will be displayed in the Solution and Formatted Equations windows as .  Alternatively, the CIS function can be employed in place of the < symbol, as shown in the example below.  The angle can be entered in either degrees or radians.  If no designation is provided, the angle is assumed to be in the same units as indicated for trigonometric functions in the Unit System dialog.  However, you can ensure that the angle you enter is in degrees or radians regardless of the unit system setting by appending deg or rad to the number (with no spaces).  For example, the value of Y can be set to the same complex constant in any one of the following four ways.


Y=2 + 3 * i


Y=3.606 < 56.31deg




Y=3.606 <0.9828rad


The use of deg or rad to indicate the units of the angle is strongly recommended for three reasons.  First, the value of the constant you enter will not be changed by the unit system setting.  Second, you can do all calculations with the unit setting in radians which is more efficient.  Third, if you designate the angle to be in degrees, the degree sign will be shown with the angle in the Formatted Equations window.  The output display of the number in the Solution Window can be set for degrees or radians (in polar notation) independent of how the number is entered.  The display is changed by clicking the right mouse button on the value and selecting the display options from the Format Variable dialog.


Internally, EES creates two equations for each equation that is entered in the Equations window.  One equation is used to equate the real parts of the variables whereas the second equation equates the imaginary parts.  The actual set of equations used in complex mode is most clearly seen by viewing the Residuals window which displays the residual and blocking order for each equation.  Equations used for the real and imaginary parts are identified with (r) and (i), respectively.  


When configured in complex mode, some EES functions, such as Min and Max, are not accessible.  However, most of the mathematical functions have been modified for complex number evaluations.  For example, the sin, cos, ln, and exp functions will accept and return appropriate complex numbers.  User-written functions, procedures, and external routines can be used but they will accept and return real numbers only.  (Modules are currently not supported in complex mode.)  Only the real part of a complex variable will be placed in the argument list of internal or external functions, procedures, and modules.  


There are a few built-in functions that operate only in complex number mode.  They are Real, Imag, Magnitude, Angle, AngleDeg, AngleRad, Cis and Conj. These functions all take one (complex number) argument and set the real part of the complex variable to the selected value.


One limitation of the manner in which EES implements complex numbers is that EES can only return one solution, although two or more solutions may exist.  There is, however, a simple way to coax EES into providing multiple solutions.  Consider the problem of determining the five roots to the complex equation  z^5 + 9 + 9*i = 0.  Entering this equation into the Equations window and solving with the default guess values will produce a solution of z=1.176+1.176 i.  or 1.663<45 in polar coordinates.  This is a correct solution to the equation, but there are others.  To find a different solution (without changing guess values), divide the equation by the difference between z and the value of this root.  This can be done by entering the following equations.





Solving a second time will produce a different root equal to 1.663<(-99deg).  This process can be repeated to find all five roots.