/**
 * This function iteratively searches for the convergence of a floating-point number.
 *
 * @param iterations The number of iterations to perform the search.
 * @param tolerance The acceptable tolerance for convergence.
 * @return The final converged value.
 */
fun searchConvergence(iterations: Int, tolerance: Double): Double {

    var x = 0.5  // Initial value
    var i = 0  // Iteration counter

    while (i < iterations) {
        x = (x + 1) / 2  // Update the value using a formula

        if (Math.abs(x - 0.5) < tolerance) {  // Check if the value has converged
            break
        }

        i++  // Increment the iteration counter
    }

    return x
}
/**
 * This function iteratively searches for the convergence of a floating-point number.
 *
 * @param iterations The number of iterations to perform the search.
 * @param tolerance The acceptable tolerance for convergence.
 * @return The final converged value.
 */
fun searchConvergence(iterations: Int, tolerance: Double): Double {
/**
 * This function iteratively searches for the convergence of a floating-point number.
 *
 * @param iterations The number of iterations to perform the search.
 * @param tolerance The acceptable tolerance for convergence.
 * @return The final converged value.
 */
fun searchConvergence(iterations: Int, tolerance: Double): Double {

    var x = 0.5  // Initial value
    var i = 0  // Iteration counter

    while (i < iterations) {
        x = (x + 1) / 2  // Update the value using a formula

        if (Math.abs(x - 0.5) < tolerance) {  // Check if the value has converged
            break
        }

        i++  // Increment the iteration counter
    }

    return x
}