def energy(disp, stiff):
    """
    Computes the potential energy for the current solution.

    Parameters
    ----------
    disp : ndarray (float)
        Array with the computed displacements.
    stiff : ndarray (float)
        Global stiffness matrix.

    Returns
    -------
    el_energy : scalar (float)
        Total energy in the system. :math:`-\\frac{1}{2} U^T K U`

    """
    force = stiff.dot(disp)
    el_energy = -0.5 * force.dot(disp)
    return el_energy
