/**
 * This function takes a set of polar numbers and converts them to their cartesian representation.
 *
 * @param polarNumbers A set of polar numbers in the form of (magnitude, angle).
 * @return A set of cartesian numbers in the form of (realPart, imaginaryPart).
 */
import kotlin.math.cos
import kotlin.math.sin


fun polarToCartesian(polarNumbers: Set<Pair<Double, Double>>): Set<Pair<Double, Double>> {

    val cartesianNumbers = mutableSetOf<Pair<Double, Double>>()

    for (number in polarNumbers) {
        val magnitude = number.first
        val angle = number.second

        // Calculate the real and imaginary parts
        val realPart = magnitude * cos(angle)
        val imaginaryPart = magnitude * sin(angle)

        cartesianNumbers.add(Pair(realPart, imaginaryPart))
    }

    return cartesianNumbers
}
import kotlin.math.cos
import kotlin.math.sin

/**
 * This function takes a set of polar numbers and converts them to their cartesian representation.
 *
 * @param polarNumbers A set of polar numbers in the form of (magnitude, angle).
 * @return A set of cartesian numbers in the form of (realPart, imaginaryPart).
 */
fun polarToCartesian(polarNumbers: Set<Pair<Double, Double>>): Set<Pair<Double, Double>> {
import kotlin.math.cos
import kotlin.math.sin

/**
 * This function takes a set of polar numbers and converts them to their cartesian representation.
 *
 * @param polarNumbers A set of polar numbers in the form of (magnitude, angle).
 * @return A set of cartesian numbers in the form of (realPart, imaginaryPart).
 */
fun polarToCartesian(polarNumbers: Set<Pair<Double, Double>>): Set<Pair<Double, Double>> {

    val cartesianNumbers = mutableSetOf<Pair<Double, Double>>()

    for (number in polarNumbers) {
        val magnitude = number.first
        val angle = number.second

        // Calculate the real and imaginary parts
        val realPart = magnitude * cos(angle)
        val imaginaryPart = magnitude * sin(angle)

        cartesianNumbers.add(Pair(realPart, imaginaryPart))
    }

    return cartesianNumbers
}