def final_temp(t_i, p_f, p_i, gamma):
    """
    Computes the final temperature of adiabatic expansion
    :param t_i: initial temperature (K)
    :param p_f: total final pressure
    :param p_i: total initial pressure
    :param gamma: heat capacity ratio ("adiabaattivakio")
    :return: final temperature (K)
    """
    return t_i * (p_f / p_i)**((gamma-1)/gamma)