# this doesn't work var('c') mat=matrix([[1,0],[0,c]]) xy0=vector([c,1]) r0=-matxy0 p0=r0 for k in range(2): la=r0p0/(p0matp0) xy1=xy0+lap0 print xy1 if xy1[0]!=0: xy1[0]=xy1[0].factor() if (xy1[1])!=0: xy1[1]=xy1[1].factor() print xy1 r1=(r0-lamatp0) p1=r1+r1r1/(r0.dot_product(r0))*p0 p1=p1.simplify_full() p0=p1 r0=r1 xy0=xy1 print '--------------------'
but this works
var('c') mat=matrix([[1,0],[0,c]]) xy0=vector([c,1]) r0=-matxy0 p0=r0 for k in range(2): la=r0p0/(p0matp0) xy1=xy0+lap0 print xy1 xy1=xy1.simplify_full() # <<<<<<<<< inserted this command if xy1[0]!=0: xy1[0]=xy1[0].factor() if (xy1[1])!=0: xy1[1]=xy1[1].factor() print xy1 r1=(r0-lamatp0) p1=r1+r1r1/(r0.dot_product(r0))*p0 p1=p1.simplify_full() p0=p1 r0=r1 xy0=xy1 print '--------------------'