worked on generalized doubling algorithm