Optimization and Stability Theory for Economic Analysis