C++ code for newtonian equations