/**
 * Calculate the combined apparent magnitude when two celestial objects are observed together.
 *
 * @param apparentMagnitude1 The apparent magnitude of the first celestial object.
 * @param apparentMagnitude2 The apparent magnitude of the second celestial object.
 * @return The combined apparent magnitude of the two celestial objects.
 */
import kotlin.math.log10
import kotlin.math.pow


fun calculateObservationMagnitude(apparentMagnitude1: Double, apparentMagnitude2: Double): Double {

    val combinedMagnitude = -2.5 * log10(10.0.pow(-0.4 * apparentMagnitude1) + 10.0.pow(-0.4 * apparentMagnitude2))
    return combinedMagnitude.round(2)
}

fun Double.round(decimals: Int): Double = "%.${decimals}f".format(this).toDouble()
import kotlin.math.log10
import kotlin.math.pow

/**
 * Calculate the combined apparent magnitude when two celestial objects are observed together.
 *
 * @param apparentMagnitude1 The apparent magnitude of the first celestial object.
 * @param apparentMagnitude2 The apparent magnitude of the second celestial object.
 * @return The combined apparent magnitude of the two celestial objects.
 */
fun calculateObservationMagnitude(apparentMagnitude1: Double, apparentMagnitude2: Double): Double {
import kotlin.math.log10
import kotlin.math.pow

/**
 * Calculate the combined apparent magnitude when two celestial objects are observed together.
 *
 * @param apparentMagnitude1 The apparent magnitude of the first celestial object.
 * @param apparentMagnitude2 The apparent magnitude of the second celestial object.
 * @return The combined apparent magnitude of the two celestial objects.
 */
fun calculateObservationMagnitude(apparentMagnitude1: Double, apparentMagnitude2: Double): Double {

    val combinedMagnitude = -2.5 * log10(10.0.pow(-0.4 * apparentMagnitude1) + 10.0.pow(-0.4 * apparentMagnitude2))
    return combinedMagnitude.round(2)
}

fun Double.round(decimals: Int): Double = "%.${decimals}f".format(this).toDouble()