Testing cost function, and testing code from projected gradient paper.