See Vogel Approximation Method but its in C/C++