/**
 * This function takes a list of complex numbers in polar representation and converts them to rectangular representation.
 *
 * @param polarNums A list of complex numbers in polar form, where each complex number is represented as a Pair (r, theta).
 * @return A list of complex numbers in rectangular form, where each complex number is represented as a Pair (realPart, imaginaryPart).
 */
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.PI


fun polarToRectangular(polarNums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {

    val rectangularNums = mutableListOf<Pair<Double, Double>>()
    
    for (polarNum in polarNums) {
        val (r, theta) = polarNum
        
        // Calculate the rectangular coordinates
        val realPart = r * cos(theta)
        val imaginaryPart = r * sin(theta)
        
        // Add the rectangular coordinates to the list
        rectangularNums.add(Pair(realPart, imaginaryPart))
    }
    
    return rectangularNums
}

// Example usage
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.PI

/**
 * This function takes a list of complex numbers in polar representation and converts them to rectangular representation.
 *
 * @param polarNums A list of complex numbers in polar form, where each complex number is represented as a Pair (r, theta).
 * @return A list of complex numbers in rectangular form, where each complex number is represented as a Pair (realPart, imaginaryPart).
 */
fun polarToRectangular(polarNums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.PI

/**
 * This function takes a list of complex numbers in polar representation and converts them to rectangular representation.
 *
 * @param polarNums A list of complex numbers in polar form, where each complex number is represented as a Pair (r, theta).
 * @return A list of complex numbers in rectangular form, where each complex number is represented as a Pair (realPart, imaginaryPart).
 */
fun polarToRectangular(polarNums: List<Pair<Double, Double>>): List<Pair<Double, Double>> {

    val rectangularNums = mutableListOf<Pair<Double, Double>>()
    
    for (polarNum in polarNums) {
        val (r, theta) = polarNum
        
        // Calculate the rectangular coordinates
        val realPart = r * cos(theta)
        val imaginaryPart = r * sin(theta)
        
        // Add the rectangular coordinates to the list
        rectangularNums.add(Pair(realPart, imaginaryPart))
    }
    
    return rectangularNums
}

// Example usage