root finding algorithim in C, and test tool