Complex

@Serializable
data class Complex(val real: Double, val imaginary: Double)(source)

Represents a complex number with a real and imaginary part.

Provides functionality to perform common mathematical operations with complex numbers, such as addition, subtraction, multiplication, division, and more. Includes utility functions for magnitude, argument, and conversions between polar and rectangular forms.

Constructors

Link copied to clipboard
constructor(real: Double, imaginary: Double)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The imaginary part of the complex number.

Link copied to clipboard

The real part of the complex number.

Functions

Link copied to clipboard

Computes the argument (or angle) of the complex number in polar coordinates. The argument is the angle formed by the positive real axis and the line representing the complex number in the complex plane, measured in radians.

Link copied to clipboard

Computes the conjugate of the complex number. The conjugate of a complex number is formed by changing the sign of its imaginary part.

Link copied to clipboard
operator fun div(other: Double): Complex
operator fun div(other: Complex): Complex
Link copied to clipboard

Calculates the magnitude (or absolute value) of the complex number. The magnitude is computed as the square root of the sum of the squares of the real and imaginary parts.

Link copied to clipboard
operator fun minus(other: Complex): Complex
Link copied to clipboard

Normalizes the complex number to a unit magnitude. The normalized complex number retains the same direction in the complex plane but has a magnitude of 1.

Link copied to clipboard
operator fun plus(other: Complex): Complex
Link copied to clipboard
fun pow(exponent: Double): Complex

Raises the current complex number to the power of the given exponent. The operation is performed in polar form, where the magnitude is raised to the exponent and the argument is multiplied by the exponent.

Link copied to clipboard

Computes the squared magnitude (or squared absolute value) of the complex number. The squared magnitude is determined as the sum of the squares of the real and imaginary parts.

Link copied to clipboard
fun sqrt(): Complex

Computes the principal square root of the complex number. The square root is calculated based on the polar representation of the complex number.

Link copied to clipboard
operator fun times(other: Double): Complex
operator fun times(other: Complex): Complex
Link copied to clipboard
operator fun unaryMinus(): Complex