1 | initial version |
There were a few issues with your code.
There is no solution when c=1.
var('n u c') sltns=solve([n + u==0, n + c*u - 1==0], n, u) print sltns L = [0, 1/4, 1/2, 3/4, 5/4, 6/4, 7/4, 2] for c1 in L: print (c1,sltns[0][0].rhs().subs(c==c1),sltns[0][1].rhs().subs(c==c1) )
2 | No.2 Revision |
There were a few issues with your code.
Here is the corrected code.
var('n u c')
sltns=solve([n + u==0, n + c*u - 1==0], n, u)
print sltns
L = [0, 1/4, 1/2, 3/4, 5/4, 6/4, 7/4, 2]
for c1 in L:
print (c1,sltns[0][0].rhs().subs(c==c1),sltns[0][1].rhs().subs(c==c1) 3 | No.3 Revision |
There were a few issues with your code.
Here is the corrected code.
var('n u c')
sltns=solve([n + u==0, n + c*u - 1==0], n, u)
print sltns
L = [0, 1/4, 1/2, 3/4, 5/4, 6/4, 7/4, 2]
for c1 in L:
print (c1,sltns[0][0].rhs().subs(c==c1),sltns[0][1].rhs().subs(c==c1) )
To answer your second question, you can collect the information into a list of the rows and then convert to a matrix.
var('n u c')
sltns=solve([n + u==0, n + c*u - 1==0], n, u)
print sltns
L = [0, 1/4, 1/2, 3/4, 5/4, 6/4, 7/4, 2]
rows=[]
for c1 in L:
print (c1,sltns[0][0].rhs().subs(c==c1),sltns[0][1].rhs().subs(c==c1) )
rows.append([c1,sltns[0][0].rhs().subs(c==c1),sltns[0][1].rhs().subs(c==c1)] )
m=matrix(rows)
m