How do you get to the second gym in Pokemon Omega Ruby?

Write back note on excess function for non- ideal solutions. How are excess functions determined experimentally?