/**
 * Given a polar representation of a complex number, convert it into a dictionary
 * where the keys represent the components of the complex number.
 *
 * @param polarNum A tuple containing the polar representation of a complex number in the form (magnitude, phase).
 * @return A dictionary containing the components 'real', 'imaginary', 'magnitude', 'phase' of the complex number.
 *
 * Example:
 * For polarNum = Pair(2.0, 1.5708), the output should be mapOf("real" to 0.0, "imaginary" to 2.0, "magnitude" to 2.0, "phase" to 1.5708).
 */
import kotlin.math.cos
import kotlin.math.sin


fun polarToDictionary(polarNum: Pair<Double, Double>): Map<String, Double> {

    val realPart = polarNum.first * cos(polarNum.second)
    val imaginaryPart = polarNum.first * sin(polarNum.second)

    return mapOf("real" to realPart, "imaginary" to imaginaryPart, "magnitude" to polarNum.first, "phase" to polarNum.second)
}
import kotlin.math.cos
import kotlin.math.sin

/**
 * Given a polar representation of a complex number, convert it into a dictionary
 * where the keys represent the components of the complex number.
 *
 * @param polarNum A tuple containing the polar representation of a complex number in the form (magnitude, phase).
 * @return A dictionary containing the components 'real', 'imaginary', 'magnitude', 'phase' of the complex number.
 *
 * Example:
 * For polarNum = Pair(2.0, 1.5708), the output should be mapOf("real" to 0.0, "imaginary" to 2.0, "magnitude" to 2.0, "phase" to 1.5708).
 */
fun polarToDictionary(polarNum: Pair<Double, Double>): Map<String, Double> {
import kotlin.math.cos
import kotlin.math.sin

/**
 * Given a polar representation of a complex number, convert it into a dictionary
 * where the keys represent the components of the complex number.
 *
 * @param polarNum A tuple containing the polar representation of a complex number in the form (magnitude, phase).
 * @return A dictionary containing the components 'real', 'imaginary', 'magnitude', 'phase' of the complex number.
 *
 * Example:
 * For polarNum = Pair(2.0, 1.5708), the output should be mapOf("real" to 0.0, "imaginary" to 2.0, "magnitude" to 2.0, "phase" to 1.5708).
 */
fun polarToDictionary(polarNum: Pair<Double, Double>): Map<String, Double> {

    val realPart = polarNum.first * cos(polarNum.second)
    val imaginaryPart = polarNum.first * sin(polarNum.second)

    return mapOf("real" to realPart, "imaginary" to imaginaryPart, "magnitude" to polarNum.first, "phase" to polarNum.second)
}