Interpretation of the Lavrentiev phenomenon by relaxation