implemented power method from section 9.1