implementation of sqrt algorithms