eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Complex':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Complex


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--ArithmeticValue
         |
         +--Number
            |
            +--Complex

Package:
stx:libbasic
Category:
Magnitude-Numbers
Version:
rev: 1.96 date: 2024/04/23 13:34:10
user: stefan
file: Complex.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


This class implements complex numbers.
A complex number has real and imaginary parts which must be manipulated simultaneously
in any numeric processing.
Complex numbers can be used in many of the same places that regular numbers
can be used with one major exception of comparisons, since complex numbers cannot
be directly compared for size (except through lengths of vectors, see absolute value; or if both are real numbers).

[Instance variables:]
   real        <Number> the part of the number which can be expressed as a Real number
   imaginary   <Number> the part of the number which, in terms of how the number behaves,
                        has been multiplied by 'i' (-1 sqrt)

[Constructors:]                         
    5 i
    6 + 7 i.
    5.6 - 8 i.
    Complex real: 10 imaginary: 5.
    Complex abs: 5 arg: (Float pi / 4)

NOTE (from porter):
    The original author's Complex class did not inherit from Number and had therefore to reimplement
    a lot of useful code (reading, testing, mathematical functions, etc.)
    Therefore we chose to place it under the number hierarchy, blocking some of the methods
    (eg. comparing, floor, ceiling, etc.)

copyright

This is a Manchester Goodie. It is distributed freely on condition that you observe these conditions in respect of the whole Goodie, and on any significant part of it which is separately transmitted or stored: * You must ensure that every copy includes this notice, and that source and author(s) of the material are acknowledged. * These conditions must be imposed on anyone who receives a copy. * The material shall not be used for commercial gain without the prior written consent of the author(s). For more information about the Manchester Goodies Library (from which this file was distributed) send e-mail: To: goodies-lib@cs.man.ac.uk Subject: help This is an additional goody-class, which is NOT covered by the ST/X license. It has been packaged with the ST/X distribution to make your live easier instead. NO WARRANTY.

Class protocol:

coercing & converting
o  coerce: aNumber
convert the argument aNumber into an instance of the receiver (class) and return it.

constants
o  i
Answer the imaginary i

o  unity
Answer the value which allows, for any given arithmetic value, the following to be true:
aNumber * aNumber class unity = aNumber
This must be true regardless of how a given subclass chooses to define #*

o  zero
Answer the value which allows, for any given arithmetic value, the following to be true:
aNumber + aNumber class zero = aNumber
This must be true regardless of how a given subclass chooses to define #+

instance creation
o  abs: length arg: angle
construct a complex from absolute value (length) and argument (angle in radians)

Usage example(s):

     self abs:10 arg:2 -> (-4.16146836547142387+9.092974268256816954i)
     self abs:2 sqrt arg:45 degreesToRadians -> (1.0+1.0i)
     self abs:2 sqrt arg:-45 degreesToRadians -> (1.0-1.0i)

o  fromReal: aNumber
Create a new complex number from the given real number.

Usage example(s):

     Complex fromReal:1.0 

o  imaginary: v
Create a new complex number with 0 as real and given imaginary parts.
If the imaginary part is zero, return the real part of the number (i.e. zero).

Usage example(s):

     Complex imaginary:1.0 
     (0.0 % 1.0)

o  random
( an extension from the stx:libbasic2 package )
Answers a random number with abs between 0 and 1.

Usage example(s):

     Complex random

o  readFrom: aStringOrStream onError: exceptionBlock
return the next Number from the (character-)stream aStream;
skipping all whitespace first; return the value of exceptionBlock,
if no number can be read.
This method is less strict than the smalltalk number reader; it
allows for prefixed + and also allows missing fractional part after eE.
It also allows garbage after the number - i.e. it reads what it can.
See #fromString: , which is more strict and does not allow garbage at the end.

o  real: aNumber
Create a new complex number from the given real number.

Usage example(s):

     Complex real:1.0 
     Complex real:0.0 

o  real: u imaginary: v
Create a new number with the given real and imaginary parts.
If the imaginary part is zero, return the real part of the number;
otherwise, return a complex instance

Usage example(s):

     Complex real:1.0 imaginary:2.0
     (1.0 % 2.0)  
     (1.0 + 2.0i) 


Instance protocol:

accessing
o  imaginary
Return the imaginary part of the complex number.

o  imaginaryPart
Return the imaginary part of the complex number.
An alias for imaginary (for compatibility with other complex implementations)

o  real
Return the real part of the complex number.

o  realPart
Return the real part of the complex number.
An alias for real (for compatibility with other complex implementations)

arithmetic
o  * aNumber
Return the product of the receiver and the argument.

o  + aNumber
Return the sum of the receiver and the argument.

o  - aNumber
Return the difference of the receiver and the argument.

Usage example(s):

Modified (comment): / 10-11-2021 / 19:52:24 / cg

o  / aNumber
Return the quotient of the receiver and the argument.

Usage example(s):

Modified (comment): / 10-11-2021 / 19:52:18 / cg

o  abs
Return the magnitude (or absolute value) of the complex number
that's the distance from zero (the origin in the complex plane).

Usage example(s):

     (1 + 1i) abs  -> 1.4142135623731
     (0 + 1i) abs  -> 1.0
     (1 + 0i) abs  -> 1
     (-1 + 0i) abs -> 1
     (0 - 1i) abs  -> 1
     (-1 - 1i) abs -> 1.4142135623731

o  absSecure
Answer the distance of the receiver from zero (0 + 0 i).
Try avoiding overflow and/or underflow

Usage example(s):

     (10 + 4i) abs          -> 10.770329614269
     (10 + 4i) absSecure    -> 10.770329614269

o  absSquared
(comment from inherited method)
who needs this???

o  conjugated
Return the complex conjugate of this complex number
(i.e. with imaginary part negated).

Usage example(s):

     (10+3i) conjugated => (10-3i)

o  divideFastAndSecureBy: anObject
Answer the result of dividing receiver by aNumber

o  divideSecureBy: anObject
Answer the result of dividing receiver by aNumber

o  i
Answer the result of multiplying the receiver with pure imaginary.
^ self * 1 i
This is an obvious extension of method i implemented in Number.

Usage example(s):

     (10+4i)i -> (-4+10i)
     1i * 1i  -> -1
     1i i     -> -1
     (3+4i) raisedTo: 2 -> (-7+24i)
     (3+4i)*(3+4i)      -> (-7+24i)
     (3+4i) squared     -> (-7+24i)

Usage example(s):

Modified (comment): / 10-11-2021 / 19:55:32 / cg

o  inverse

o  magnitude
answer my magnitude (length from self as point to origin

o  modulus

o  negated
return a new complex with both real and imaginary parts negated

Usage example(s):

     (0.0-10000000000.0i) = (0.0+10000000000.0i) negated   -> true 
     (-0.0-10000000000.0i) = (0.0+10000000000.0i) negated  -> true  
     (0.0-10000000000.0i) = (-0.0+10000000000.0i) negated  -> true  
     (1.0-1.0i) = (-1.0+1.0i) negated                      -> true  
     (1.0-1.0i) + (1.0-1.0i) negated
     (1.0-1.0i) - (1.0-1.0i) negated

coercing & converting
o  asComplex
I am a complex - so return the receiver

o  asFloat
return a float with same value.
Raises an error if there is an imaginary part

Usage example(s):

    (Complex real:10.0 imaginary:0) asFloat   -> 10.0
    (4 + 0i) asFloat                          -> 4.0
    (4 + 3i) asFloat                          error

o  asInteger
return an integer with my truncated real value.
Raises an error if there is an imaginary part

Usage example(s):

     (Complex real:10.0 imaginary:0) asInteger   -> 10
     (Complex real:10.5 imaginary:0) asInteger   -> 10
     (Complex real:-10.5 imaginary:0) asInteger  -> -10

o  asLongFloat
return a long float with same value.
Raises an error if there is an imaginary part

Usage example(s):

    (4 + 3i) asLongFloat

o  asPoint
Return the complex number as a point.

o  asShortFloat
return a short float with same value.
Raises an error if there is an imaginary part

Usage example(s):

    (Complex real:10 imaginary:0) asFloat      -> 10.0
    (Complex real:10 imaginary:0) asShortFloat -> 10.0

    (4 + 3i) asFloat          error
    (4 + 3i) asShortFloat     error
    (4 + 3i) asInteger        error

o  generality

o  i: aNumber
Form a complex number with
receiver as realPart
aNumber as imaginaryPart
this is the same as (self + aNumber i) but a little bit more efficient.
Blocked to avoid sending another i: to an already complex

o  reduceGeneralityIfPossible
Answer the receiver transformed to a lower generality, if such a
transformation is possible without losing information.
If not, answer the receiver

comparing
o  < aNumber
raises an error - complex numbers are not well ordered (unless both imaginary parts are zero)

Usage example(s):

     1 < (2 + 2i)
     (2 + 2i) < 1

o  = anObject
return true, if the argument represents the same numeric value
as the receiver, false otherwise.

Usage example(s):

     (Complex real:1.0 imaginary:2.0) = (Complex real:1.0 imaginary:2.0)
     (Complex real:1.0 imaginary:0) = 1.0
     (1.0 + 1i) - 1 i = 1.0

o  hash
Hash is implemented because = is implemented.
Notice:
because complex numbers with zero imaginary compare equal to the corresponding
real, the hashes of both must be the same

Usage example(s):

     1 hash    
     1.0 hash
     (1+0i) hash
     (1+1i) hash

o  lexicographicalLessThan: aNumber
redefined for complex numbers:
ordered by real or by imag, if reals are the same

double dispatching
o  differenceFromComplex: aComplex
Return the difference of the argument, aComplex and the receiver.

o  differenceFromFloat: aFloat
Return the difference of the argument, aFloat and the receiver.

o  differenceFromFraction: aFraction
Return the difference of the argument, aFraction and the receiver.

o  differenceFromInteger: anInteger
Return the difference of the argument, anInteger and the receiver.

o  differenceFromPoint: aPoint
return the difference from aPoint - self,
interpreting self as a point.

o  differenceFromScaledDecimal: aScaledDecimal
Return the difference of the argument, aScaledDecimal and the receiver.

o  equalFromComplex: aComplex
return true if aComplex represents the same number as myself

o  equalFromFloat: aFloat
return true if aFloat represents the same number as myself

o  productFromComplex: aComplex
Return the product of the receiver and the argument, aComplex.

o  productFromFloat: aFloat
Return the product of the receiver and the argument, aFloat.

o  productFromFraction: aFraction
Return the product of the receiver and the argument, aFraction.

o  productFromInteger: anInteger
sent when an integer does not know how to multiply the receiver, a complex.
Return the product of the receiver and the argument, anInteger.

o  productFromPoint: aPoint
return the product of aPoint * self,
interpreting self as a point.
This is a coordinate multiplication - not complex multiplication!

o  productFromScaledDecimal: aScaledDecimal
Return the product of the receiver and the argument, aScaledDecimal.

o  quotientFromComplex: aComplex
Return the quotient of the argument, aComplex and the receiver.

o  quotientFromFloat: aFloat
Return the quotient of the argument, aFloat and the receiver.
Sent when aFloat does not know how to divide by the receiver.
Return aFloat / self

o  quotientFromFraction: aFraction
Return the quotient of the argument, aFraction and the receiver.

o  quotientFromInteger: anInteger
Return the quotient of the argument, anInteger and the receiver.

o  quotientFromPoint: aPoint
return the quotient of aPoint / self,
interpreting self as a point.
This is a coordinate division - not complex division!

o  quotientFromScaledDecimal: aScaledDecimal
Return the quotient of the argument, aScaledDecimal and the receiver.

o  raisedFromFloat: aNumber
2 raisedTo:(2 + 2i)
2 ** (2 + 2i)

2.0 raisedTo:(2 + 2i)
2.0 ** (2 + 2i)

o  raisedFromNumber: aNumber
see http://www.math.toronto.edu/mathnet/questionCorner/complexexp.html

o  sumFromComplex: aComplex
Return the sum of the receiver and the argument, aComplex.

o  sumFromFloat: aFloat
Return the sum of the receiver and the argument, aFloat.

o  sumFromFraction: aFraction
Return the sum of the receiver and the argument, aFraction.

o  sumFromInteger: anInteger
Return the sum of the receiver and the argument, anInteger.

o  sumFromPoint: aPoint
return the sum of aPoint + self,
interpreting self as a point

o  sumFromScaledDecimal: aScaledDecimal
Return the sum of the receiver and the argument, aScaledDecimal.

inspecting
o  inspectorExtraAttributes
( an extension from the stx:libtool package )
extra (pseudo instvar) entries to be shown in an inspector.

mathematical functions
o  angle
Return the radian angle for this Complex number.
Raises a division by zero error if the real part is zero

Usage example(s):

     (1 + 1i) angle radiansToDegrees -> 45.0
     (1 - 1i) angle radiansToDegrees -> -45.0
     (1 + (Number infinity)i) angle radiansToDegrees -> 90.0
     (1 - (Number infinity)i) angle radiansToDegrees -> -90.0
     (0 + 1i) angle radiansToDegrees -> error

o  arg
Answer the argument of the receiver.
See https://en.wikipedia.org/wiki/Argument_(complex_analysis)

Usage example(s):

the argument of zero is undefined 

Usage example(s):

     (0+1i) arg       
     (0-1i) arg       

o  exp
Return the complex exponential of the receiver.

Usage example(s):

     (10+4i) exp -> (-14397.45885694595768-16669.6842763244522i)

o  ln
Answer the natural log of the receiver.

o  log10
return the base-10 logarithm of the receiver.
Raises an exception, if the receiver is less or equal to zero.
Here, fallback to the general logarithm code.

o  log: base
Answer the log base aNumber of the receiver.

o  norm

o  raisedTo: aNumber
Answer the receiver raised to aNumber.

Usage example(s):

     (2 + 0i) raisedTo: 2

o  raisedToInteger: operand
return the receiver raised to the power operand, an Integer.
The caller must ensure that the arg is actually an integer.

Usage example(s):

     (0+2i) raisedToInteger:2   -> -4
     (0+2i) raisedToInteger:3   -> (0-8i)
     (0+2i) raisedToInteger:4   -> 16
     (0+2i) raisedToInteger:5   -> (0+32i)
     (0+2i) raisedToInteger:6   -> -64
     (0+2i) raisedToInteger:8   -> 256

     (2+2i) raisedToInteger:2   -> (0+8i)
     (2+2i) raisedToInteger:3   -> (-16+16i)

o  sqrt
Return the square root of the receiver

o  squaredNorm
Answer the square of receiver's norm.

printing & storing
o  displayOn: aGCOrStream
Complex real:1 imaginary:1
(Complex real:1 imaginary:1) printString
Complex readFrom:( (Complex real:1 imaginary:1) storeString )
Number readFrom:( (Complex real:1 imaginary:1) storeString )
(Complex real:1 imaginary:1) displayString

o  printOn: aGCOrStream
Complex real:1 imaginary:1
(Complex real:1 imaginary:1) printString
(Complex real:1 imaginary:1) displayString

(1 + 3i) printString
(1 - 3i) printString

o  storeOn: aStream
(comment from inherited method)
append a string for storing the receiver onto the argument, aStream
- since numbers are literals,they store as they print.

private
o  setReal: u setImaginary: v

testing
o  isComplex
Answer whether the receiver has an imaginary part
(i.e. if it is a complex number). Always true here.
Notice that isComplex is only understood inside the number hierarchy,
whereas isComplexNumber is understood by everyone

o  isComplexNumber
return true, if the receiver is a complex number.
Notice that isComplex is only understood inside the number hierarchy,
whereas isComplexNumber is understood by everyone

o  isExact
Answer whether the receiver performs exact arithmetic.

o  isReal
Return true if this Complex number has a zero imaginary part.
Notice that isReal is only understood inside the number hierarchy,
whereas isRealNumber is understood by everyone

o  isRealNumber
return true, if the receiver is a real number.
Reredefined, because here complex inherits from Number (which returns true).
Notice that isReal is only understood inside the number hierarchy,
whereas isRealNumber is understood by everyone

o  isZero
Answer whether 'self = self class zero'.
We can't use #= because #= is defined in terms of #isZero

o  sign
return the sign of the receiver (-1, 0 or 1)

Usage example(s):

^ real sign

Usage example(s):

return a new complex, consisting of the signs of the real and imaginary parts.

Usage example(s):

^ self class real:(real sign) imaginary:(imaginary sign)

Usage example(s):

this is consistent with Wolfram's output:
   
    (Complex new setReal:1 setImaginary:0) sign -> 1
    (Complex new setReal:-1 setImaginary:0) sign -> -1
    (Complex new setReal:0 setImaginary:0) sign -> 0

    (Complex new setReal:1 setImaginary:1) sign -> (0.707106781186547+0.707106781186547i)
    (Complex new setReal:0 setImaginary:1) sign -> (0.0+1.0i)
    (Complex new setReal:-1 setImaginary:1) sign -> (-0.707106781186547+0.707106781186547i)

    (Complex new setReal:1 setImaginary:-1) sign -> (0.707106781186547-0.707106781186547i)
    (Complex new setReal:0 setImaginary:-1) sign -> (0.0-1.0i)
    (Complex new setReal:-1 setImaginary:-1) sign -> (-0.707106781186547-0.707106781186547i)

trigonometric
o  arcCos
Answer the arc cosine of the receiver.
This is the inverse function of cos.

Usage example(s):

     (10+4i) cos (-22.91356068209214107-14.84629106966035727i)
     (10+4i) cos arcCos 
     (Complex real:1.5 imaginary:0) arcCos    -> (0+0.962423650119207i)
     (Complex real:-1.5 imaginary:0) arcCos   -> (3.14159265358979-0.962423650119207i)
     (Complex real:1.5 imaginary:2) arcCos    -> (0.964284808595142-1.62249414887159i)
     (Complex real:-1.5 imaginary:2) arcCos   -> (2.17730784499465-1.62249414887159i)

Usage example(s):

     (10 + 4i) cos  
        -> (-22.9135606820921+14.8462910696604i)
     (10 - 4i) cos 
        -> (-22.9135606820921-14.8462910696604i)

     (-22.9135606820921+14.8462910696604i) arcCos 
        -> (2.56637061435917-4.0i)

     (2.56637061435917-4.0i) cos   
        -> (-22.9135606820921+14.8462910696604i)

o  arcSin
Answer the arc sine of the receiver.
This is the inverse function of sin.

Usage example(s):

     (10 + 4i) sin 
        -> (-14.8562551638753-22.8981925509638i)
     (10 - 4i) sin 
        -> (-14.8562551638753+22.8981925509638i)

     (-14.8562551638753-22.8981925509638i) arcSin 
        -> (-0.575222039230621-4.0i)

     (-0.57522203923062-4.0i) sin 
        -> (-14.8562551638752-22.8981925509638i)

o  arcTan
Answer the arc tangent of the receiver.
This is the inverse function of tan.

o  arcTan: denominator
Answer the four quadrants arc tangent of receiver over denominator.

Usage example(s):

shouldn't it be an error ? ^DomainError signal: '0 arcTan: 0'

o  cos
Answer the receiver's cosine.

Usage example(s):

^ self i cosh

Usage example(s):

     (10+4i) cos   -> (-22.91356068209214107+14.84629106966035727i) 
     (0+1000i) cos -> (9.850355570085234969E+433+-0.0i)

o  sin
Answer the receiver's sine.

Usage example(s):

^ self i sinh i negated.

Usage example(s):

sin(x + iy) = sin(x)cos(iy) + cos(x)sin(iy)

Usage example(s):

^ (real sin * imaginary cosh)

Usage example(s):

     (10+4i) sin    -> (-14.85625516387525498-22.89819255096375875i)
     (0+1000i) sin  -> (0.0+9.850355570085235467E+433i)
     (0+1000i) cos  -> (9.850355570085234969E+433+0.0i)

     (0+10000i) sin  -> (0.0+4.403409112831460306e+4342i)
     (0+100000i) sin  -> (0.0+4.403409112831460306e+4342i)

o  tan
Answer the receiver's tangent.

Usage example(s):

     (0+0i) tan    ->  0.0
     (0+1i) tan    ->  (0.0+0.761594155955765i)
     (1+1i) tan    ->  (0.271752585319512+1.08392332733869i)
     (1+0i) tan    ->  1.5574077246549

     (0+1000i) tan -> (0.0+1.0i)

     (10+4i) tan -> (0.0006123503000121616919+0.9997260574022127583i)
     (10+4i) cos -> (-14.85625516387525498-22.89819255096375875i) 

     (10+4i) tan -> 
        (0.000612350300012162+0.999726057402213i)
     (10 asQDouble + 4 asQDouble i) tan  
        (0.00061235030001+0.9997260574i)
     (10 asLongFloat + 4 asLongFloat i) tan  
        (0.00061235030001216187+0.9997260574022127579i)

     (10 asQuadFloat + 4 asQuadFloat i) tan  
        (0.0006123503+0.999726057i)
     (10 asOctaFloat + 4 asOctaFloat i) tan    
        (0.00061235030001+0.9997260574i)
     (10 asLargeFloat + 4 asLargeFloat i) tan  
        (0.000612350300+0.999726057402i)

trigonometric - hyperbolic
o  arCosh
Answer the receiver's hyperbolic area cosine.
That is the inverse function of cosh.

Usage example(s):

     (10 + 4i) arCosh   => (3.06838131635695+0.381999687056349i)
     (10q + 4i) arCosh  => (3.068381316356950975+0.3819996870563488037i)
     (10Q + 4i) arCosh  => (3.06838131635695097543902211718+0.381999687056348803757234419236i)
     (10QD + 4i) arCosh => (3.06838131635695097543595211142530843062559142708778381347656+0.381999687056348803757682697224140611069742590188980102539062i)

o  arCoth
there might be a complex sqrt inside...

Usage example(s):

     (0 + 0i) coth                          -> error
     Number trapInfinity:[(0 + 0i) coth]    -> inf
     Number trapInfinity:[ ( 0 - 0i) coth]  -> inf
     Number trapInfinity:[ ( -0 - 0i) coth] -> inf

     (0 + 0.0000000001i) coth  -> (0.0-10000000000.0i) = -(0.0+10000000000.0i)

     (0.5 + 0i) arCoth
     Number trapImaginary:[ (0.5 + 0i) arCoth ](0.549306144334055+1.5707963267949i)

o  arCsch
there might be a complex sqrt inside...

o  arSech
there might be a complex sqrt inside...

o  arSinh
Answer receiver's hyperbolic area sine.
That is the inverse function of sinh.

Usage example(s):

imaginary = 0 ifTrue:[^ real arSinh].

Usage example(s):

     (10 + 4i) sinh         -> (-7198.729413635291604 - 8334.842155341616165i)
     (10 + 4i) sinh arSinh  -> (-10.0 - 0.8584073464102067614i)
     (0 + 2i) arSinh        -> (-10.0 - 0.8584073464102067614i)

o  arTanh
Answer the receiver's hyperbolic area tangent.
That is the inverse function of tanh.

Usage example(s):

     (10+4i) tanh arTanh

o  cosh
Answer the receiver's hyperbolic cosine (interpreted as radians).
Hyperbolic cosine is defined by same power series expansion as for real numbers,
that is in term of exponential:
^ (self exp + self negated exp) / 2.
This implementation avoids creating intermediate objects.

Usage example(s):

     (10+4i) cosh => (-7198.729443310666079 - 8334.842120982836036i) 
     (10-4i) cosh => (-7198.729443310666079 + 8334.842120982836036i) 

o  coth
Answer the hyperbolic cotangent of the receiver taken as an angle in radians.

o  csch
Answer the hyperbolic cosecant of the receiver taken as an angle in radians.

o  sech
Answer the hyperbolic secant of the receiver taken as an angle in radians.

o  sinh
Answer the receiver's hyperbolic sine.
Hyperbolic sine is defined by same power series expansion as for real numbers,
that is in term of exponential:
^ (self exp - self negated exp) / 2.
This implementation avoids creating intermediate objects.

Usage example(s):

     10 sinh -> 11013.23287470339338
     (10+4i) sinh (-7198.729413635291604-8334.842155341616165i)

o  tanh
Answer the receiver's hyperbolic tangent.

Usage example(s):

     (10+4i) tanh

truncation & rounding
o  ceiling
(comment from inherited method)
return the integer nearest the receiver towards positive infinity.

o  floor
distribute

o  roundTo: aNumber
here, we round both real and imaginary parts to the nearest aNumber

o  roundUpTo: quantum
distribute.

o  truncateTo: aNumber
distribute.

o  truncated
distribute.


Examples:


-25 sqrt                                  -> error
Complex trapImaginary:[ -25 sqrt ]        -> 5i (0.0+5.0i)
Complex trapImaginary:[ -25 integerSqrt ] -> 5i (0+5i)

(Complex trapImaginary:[ -5397346292805549782720214077673687804022210808238353958670041357153884304 integerSqrt ])
    squared

1 + 3i

Number i + 1
1 + Number i

1 i + 1
1 + 1 i

1i * 1i
Number i * Number i

(5 + 7i) real
(5 + 7i) imaginary
(5 + 7i) = 5
(5 + 0i) = 5
(5.0 + 0i) = 5

(1 + 0i) + (2 + 0i)
(1 + 0i) + (0 + 2i)
(1 + 0i) + (2 + 3i)

(1 + 0i) * (2 + 0i)
(1 + 0i) * (0 + 2i)
(1 + 0i) * (2 + 3i)

(1 + 2i) + 2
(1 + 2i) * 2
2 + (1 + 2i)
2 * (1 + 2i)

(Number i raisedTo:-3) -> Number i
(Number i raisedTo:-2) -> -1
(Number i raisedTo:-1) -> Number i negated

(Number i raisedTo:0) -> 1
(Number i raisedTo:1) -> Number i
(Number i raisedTo:2) -> -1
(Number i raisedTo:3) -> Number i negated
(Number i raisedTo:4) -> 1
(Number i raisedTo:6) -> -1

3 raisedTo:Number i
3 i raisedTo:Number i

5i * 5i     -> -25
5i squared  -> -25 
(5i raisedTo:2) -> -25 


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 00:17:36 GMT