SpreadJS Documentation
Complex Numbers

Many of the engineering functions involve complex numbers. A complex number consists of two parts, a real part and an imaginary part. Consider a complex number as being a point (x,y) in a plane. The real number is similar to a point (x,0) on the x-axis of the plane. Note that real numbers are a subset of complex numbers with zero for the coefficient of the imaginary part.

There is not a complex number data type. Instead, complex numbers are represented using strings of the form "x+yi" where x and y are real numbers and x is the real part and yi is the imaginary part. For example:

     "2+3i"

     "1.23E4+5.67E8i"

Note that if either the real part or the imaginary part is zero then the zero part can be optionally omitted from the text representation. For example:

"3" is equivalent to "3+0i"

"4i" is equivalent to "0+4i"

Since real numbers are a subset of complex numbers, a real number can be used in place of a string of the form "x+yi". For example:

3 is equivalent to "3+0i"

The functions that return a complex number return a string of the form "x+yi". For example:

COMPLEX(3,5) returns "3+5i"

The functions that accept a complex number can accept either a number or a string of the form "x+yi". For example:

IMSUM("1+2i", "3+4i") returns "4+6i"

IMSUM(1, 3) returns "4"

When a string cannot be converted to a number Spread returns a #VALUE error. For example:

COS("abc") returns #VALUE!

IMCOS("abc") returns #VALUE!

Spread allows either suffix "j" or the suffix "i" to denote the imaginary part. For example:

"3+4j" is equivalent to "3+4i"

Spread allows mixed suffixes in the a given formula and always returns the "i" suffix. For example:

IMSUM("1+2i","3+4i") returns "4+6i"

IMSUM("1+2j","3+4j") returns "4+6i"

IMSUM("1+2i","3+4j") returns "4+6i"

Spread does not allow spaces before the real part or before the imaginary part. For example:

IMABS("3+4i") returns 5

IMABS(" 3+4i") returns #VALUE!

IMABS("3 +4i") returns #VALUE!

IMABS("3+4i ") returns #VALUE!

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.