/**
 * Converts a complex number in polar representation to its Cartesian representation.
 *
 * @param polarDict A dictionary representing the polar form of a complex number.
 *                  The dictionary should have keys "magnitude" and "angle".
 * @return A dictionary representing the Cartesian form of the complex number.
 *         The dictionary has keys "real" and "imaginary".
 */
fun polarToCartesian(polarDict: Map<String, Double>): Map<String, Double> {

    val cartesianDict = mutableMapOf<String, Double>()
    
    // Extract magnitude and angle from the polarDict
    val magnitude = polarDict["magnitude"] ?: 0.0
    val angle = polarDict["angle"] ?: 0.0
    
    // Compute the real and imaginary parts using trigonometric functions
    cartesianDict["real"] = magnitude * Math.cos(angle)
    cartesianDict["imaginary"] = magnitude * Math.sin(angle)
    
    return cartesianDict
}
/**
 * Converts a complex number in polar representation to its Cartesian representation.
 *
 * @param polarDict A dictionary representing the polar form of a complex number.
 *                  The dictionary should have keys "magnitude" and "angle".
 * @return A dictionary representing the Cartesian form of the complex number.
 *         The dictionary has keys "real" and "imaginary".
 */
fun polarToCartesian(polarDict: Map<String, Double>): Map<String, Double> {
/**
 * Converts a complex number in polar representation to its Cartesian representation.
 *
 * @param polarDict A dictionary representing the polar form of a complex number.
 *                  The dictionary should have keys "magnitude" and "angle".
 * @return A dictionary representing the Cartesian form of the complex number.
 *         The dictionary has keys "real" and "imaginary".
 */
fun polarToCartesian(polarDict: Map<String, Double>): Map<String, Double> {

    val cartesianDict = mutableMapOf<String, Double>()
    
    // Extract magnitude and angle from the polarDict
    val magnitude = polarDict["magnitude"] ?: 0.0
    val angle = polarDict["angle"] ?: 0.0
    
    // Compute the real and imaginary parts using trigonometric functions
    cartesianDict["real"] = magnitude * Math.cos(angle)
    cartesianDict["imaginary"] = magnitude * Math.sin(angle)
    
    return cartesianDict
}