/**
 * This function takes a list of complex numbers in polar form and returns their cartesian representation.
 * Each complex number is represented as a pair in the format (magnitude, angle).
 * The magnitude is a positive real number and the angle is in radians.
 *
 * @param nums a list of pairs representing complex numbers in polar form
 * @return a list of pairs representing complex numbers in cartesian form
 *
 * Example:
 * If the input is [(1, 0), (2, 3.14159)], the output should be [(1, 0), (-2, 3.14159)].
 */
import kotlin.math.cos
import kotlin.math.sin


fun polarToCartesian(nums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {

    val cartesianNums = mutableListOf<Pair<Double, Double>>()
    for (num in nums) {
        val (magnitude, angle) = num
        val realPart = magnitude * cos(angle)
        val imaginaryPart = magnitude * sin(angle)
        cartesianNums.add(Pair(realPart, imaginaryPart))
    }
    return cartesianNums
}
import kotlin.math.cos
import kotlin.math.sin

/**
 * This function takes a list of complex numbers in polar form and returns their cartesian representation.
 * Each complex number is represented as a pair in the format (magnitude, angle).
 * The magnitude is a positive real number and the angle is in radians.
 *
 * @param nums a list of pairs representing complex numbers in polar form
 * @return a list of pairs representing complex numbers in cartesian form
 *
 * Example:
 * If the input is [(1, 0), (2, 3.14159)], the output should be [(1, 0), (-2, 3.14159)].
 */
fun polarToCartesian(nums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {
import kotlin.math.cos
import kotlin.math.sin

/**
 * This function takes a list of complex numbers in polar form and returns their cartesian representation.
 * Each complex number is represented as a pair in the format (magnitude, angle).
 * The magnitude is a positive real number and the angle is in radians.
 *
 * @param nums a list of pairs representing complex numbers in polar form
 * @return a list of pairs representing complex numbers in cartesian form
 *
 * Example:
 * If the input is [(1, 0), (2, 3.14159)], the output should be [(1, 0), (-2, 3.14159)].
 */
fun polarToCartesian(nums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {

    val cartesianNums = mutableListOf<Pair<Double, Double>>()
    for (num in nums) {
        val (magnitude, angle) = num
        val realPart = magnitude * cos(angle)
        val imaginaryPart = magnitude * sin(angle)
        cartesianNums.add(Pair(realPart, imaginaryPart))
    }
    return cartesianNums
}