Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

code snippet resp. simplify and factor

# 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 '--------------------'

code snippet resp. simplify and factor

# this doesn't work work

var('c')
mat=matrix([[1,0],[0,c]])
xy0=vector([c,1])
r0=-matxy0
r0=-mat*xy0
p0=r0
for k in range(2):
    la=r0p0/(p0matp0)
    xy1=xy0+lap0
la=r0*p0/(p0*mat*p0)
    xy1=xy0+la*p0
    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
r1=(r0-la*mat*p0)
    p1=r1+r1*r1/(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
r0=-mat*xy0
p0=r0
for k in range(2):
    la=r0p0/(p0matp0)
    xy1=xy0+lap0
la=r0*p0/(p0*mat*p0)
    xy1=xy0+la*p0
    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
r1=(r0-la*mat*p0)
    p1=r1+r1*r1/(r0.dot_product(r0))*p0
    p1=p1.simplify_full()
    p0=p1
    r0=r1
    xy0=xy1
    print '--------------------'

'--------------------'