A complex math in C++