data class ComplexNumber(val real: Double = 0.0, val imag: Double = 0.0){
    operator fun plus(other: ComplexNumber): ComplexNumber{
        return ComplexNumber(real = this.real + other.real, imag = this.imag + other.imag)
    }

    operator fun times(other: ComplexNumber): ComplexNumber{
        val a = this.real
        val b = this.imag
        val c = other.real
        val d = other.imag

        return ComplexNumber(a*c - b*d, b*c + a * d)
    }

    operator fun minus(other: ComplexNumber): ComplexNumber{
        return ComplexNumber(real = this.real - other.real, imag = this.imag - other.imag)
    }

    operator fun div(other: ComplexNumber): ComplexNumber{
        val a = this.real
        val b = this.imag
        val c = other.real
        val d = other.imag

        return ComplexNumber(real = (a * c + b * d)/(c * c + d * d), imag = (b * c - a * d)/(c * c + d * d))
    }

    val abs: Double = Math.sqrt((real * real) + (imag * imag))
    fun  conjugate(): ComplexNumber {
        return ComplexNumber(real = this.real, imag = this.imag.unaryMinus())
    }

    fun cos(): ComplexNumber{
        val x = this.real
        val y = this.imag
        return ComplexNumber(Math.cos(x) * Math.cosh(y), (Math.sin(x) * Math.sinh(y)).unaryMinus())
    }

    fun sin(): ComplexNumber{
        val x = this.real
        val y = this.imag
        return ComplexNumber(Math.sin(x) * Math.cosh(y), (Math.cos(x) * Math.sinh(y)))
    }
}

fun exponential(num: ComplexNumber): ComplexNumber{
    val x = num.real
    val y = num.imag

    return ComplexNumber(real = Math.pow(Math.E, x), imag = 0.0) * ComplexNumber(real = Math.cos(y), imag = Math.sin(y))
}