Hi
is there a simplest way to get the cleaned solution below ?
startP=[1,2,3,4,5]
endP=[1,4,2,5,3]
n=len(startP)-1
varsX=var(["x_%d%d"%(c,r) for c in [0..n] for r in [0..n]])
varsY=var(["y_%d"%(c) for c in [0..n+1] ] )
#show(varsX)
#show(varsY)
eq0=y_1 == x_00*y_1 + x_01*y_2 + x_02*y_3 + x_03*y_4 + x_04*y_5
S=solve(eq0,varsX[0:5])[0]
for s in S:
print(s)
## get the solution x_00==1,x_01==0,x_02==0,x_03==0,x_04==0
cleanedS=[]
for s in S :
#print(s)
varsR=[]
for v in (s.variables()) :
if v not in varsX+varsY :
#print('r : ',v)
varsR.append(v==0)
#print(varsR)
cleanedS.append(s.subs(varsR))
print('the cleaned solution : ',cleanedS)