Implementations of Gradient Descent, Newton Methods, and Primal-Dual Methods