Complex class

Represents an immutable complex number z = re + im*i.

The class stores the number in Cartesian form (re, im) and in polar form (modulus, theta) to optimize operations.

Constructors

Complex(double re, double im)
Default constructor Cartesian form (z = re + im*i)
Complex.fromString(String input)
Factory to create a complex number from a representation in String.
factory
Complex.polar(double modulus, double theta)
Factory for creating complex numbers in polar or exponential form.
factory
Complex.polarDegrees(double modulus, double degrees)
Factory for creating trigonometric shapes using degrees.
factory

Properties

conjugate Complex
Returns the conjugate complex number (re - im*i).
no setter
hashCode int
Hash code of the complex number (based on real and imaginary parts).
no setteroverride
im double
Returns the Imaginary Part (im).
no setter
modulus double
Returns the Modulus (|z|), stored in the constructor.
no setter
modulusCalculate double
Returns the recalculated modulus (for verification only).
no setter
opposite Complex
Returns the opposite complex number (-re - im*i).
no setter
re double
Returns the Real Part (re).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
theta1 double
Returns the Argument (phase) in radians in the interval (-π, π].
no setter
theta2 double
Returns the Argument (phase) in radians in the interval [0, 2π).
no setter

Methods

cos() Complex
Calculate the complex cosine function (cos(z)).
cosh() Complex
Calculate the complex hyperbolic cosine function (sinh(z)).
exp() Complex
Calculate the complex exponential (e^z).
inverse() Complex
Calculate the multiplicative inverse (1/z).
log() Complex
Formula: ln(z) = ln(|z|) + i*arg(z). Throws ArgumentError if the modulus is zero.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nthRoots(int n) List<Complex>
Calculate all nth roots of the complex number.
pow(int n) Complex
Raise the complex number to the integer power n.
printAll({int? p}) → void
Print all representations of the complex number on the console.
rotate(double angleRadians) Complex
Rotates the complex number by an angle angleRadians counterclockwise.
sin() Complex
Calculate the complex sine function (sin(z)).
sinh() Complex
Calculate the complex hyperbolic sine function (sinh(z)).
tan() Complex
Calculates the complex tangent function (tan(z)).
tanh() Complex
Calculates the complex hyperbolic tangent function (tanh(z)).
toExponentialString({bool use2piRange = false, int? precision}) String
Returns the exponential representation of the number.
toString({int? precision}) String
Returns the algebraic (Cartesian) representation of the number.
override
toStringTheta() String
Returns a string showing theta angles in radians and degrees.
toTrigonometricString({bool use2piRange = false, int? precision}) String
Returns the trigonometric representation of the number.

Operators

operator *(Complex other) Complex
Performs multiplication. Uses polar form for efficiency: r1*r2 * e^(i(theta1 + theta2))
operator +(Complex other) Complex
Performs the sum between this complex number and other.
operator -(Complex other) Complex
Subtracts this complex number from other.
operator /(Complex other) Complex
Performs division. If the denominator is zero, throws ArgumentError.
operator ==(Object other) bool
Compare two complex numbers for equality (real and imaginary).
override