Skip to content

Complex Number type #281

Closed
Closed

Description

@wojciechczerniak

Description

There is another type that is used by a few functions that we have not yet implemented.

Complex Number

4.4 Complex Number
A complex number (sometimes also called an imaginary number) is a pair of real numbers including a real part and an imaginary part. In mathematics, complex numbers are often written as x + iy, where x (the real part) and y (the imaginary part) are real numbers and i is
− 1
. A complex number can also be written as reiθ = rcos(θ) + irsin(θ), where r is the modulus of the complex number (a real number) and θ is the argument or phase (a real number representing an angle in radians).

A complex number may, but need not be, represented as a Number or Text. The results of the functions ISNUMBER() 6.13.22 and ISTEXT() 6.13.25 are implementation-defined when applied to a complex number.

Functions and operators that accept complex numbers shall accept Text values as complex numbers (Conversion to Complex Number 6.3.10), as well as Numbers that are not complex numbers.

Note 1: IMSUM("3i";4) will produce the same result as COMPLEX(4;3).

Note 2: Expression authors should be aware that use of functions that are not defined by OpenFormula as accepting complex numbers as input may impair interoperability.

Equality can be tested using IMSUB to compute the difference, use IMABS to find the absolute difference, and then ensure the absolute difference is smaller than or equal to some nonnegative value (for exact equality, compare for equality with 0).

Complex Number conversion

6.3.10 Conversion to Complex Number
An evaluator may accept complex numbers as Text, Number, or a different distinguishable type.

If the value is:
•Number that is not complex, use the Number with 0 as the imaginary part.
•Text, attempt to convert to complex number using VALUE 6.13.34. If it is a number that is not complex, use it. If the text matches one of these patterns, accept it:
([+-]?Number [+-])?Number[ij]
[+-]?Number[ij]
•Logical, convert to Number and then handle as Number.
•reference: Convert to Scalar 6.3.2, then use the rules above. If the reference is to an empty cell, consider it equal to 0.

Functions that require Complex Number type

6.8.2 COMPLEX
6.8.3 IMABS
6.8.4 IMAGINARY
6.8.5 IMARGUMENT
6.8.6 IMCONJUGATE
6.8.7 IMCOS
6.8.8 IMCOSH
6.8.9 IMCOT
6.8.10 IMCSC
6.8.11 IMCSCH
6.8.12 IMDIV
6.8.13 IMEXP
6.8.14 IMLN
6.8.15 IMLOG10
6.8.16 IMLOG2
6.8.17 IMPOWER
6.8.18 IMPRODUCT
6.8.19 IMREAL
6.8.20 IMSIN
6.8.21 IMSINH
6.8.22 IMSEC
6.8.23 IMSECH
6.8.24 IMSQRT
6.8.25 IMSUB
6.8.26 IMSUM
6.8.27 IMTAN

Links

Complex number: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#Complex_Number
https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017998_715980110
https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1018090_715980110

Activity

  1. added
    Feature
    on Mar 29, 2020
  2. self-assigned this
    on Apr 2, 2020
  3. added this to the Next milestone on Apr 6, 2020
  4. added
    Verified
    on Jun 23, 2020
  5. wojciechczerniak commented on Dec 17, 2020

    @wojciechczerniak
    ContributorAuthor

    Done in #580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureVerified

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions