Definite version of contraction algorithms for week3