Revision history [back]

cannot evaluate symbolic expression numerically

I'm probably doing something wrong on a fundamental level, so: sorry for my ignorance. Yet i'd very much appreciate any suggestions, how to make this work:

I have me a function f, defined in somewhat lenghty way:

var('a,b,c,d')

i=matrix(SR,3,3, [1,0,0, 0,1,0, 0,0,1])

e_1=matrix(SR,3,3, [1,0,-1, 0,0,0, -1,0,1]) e_2=matrix(SR,3,3, [0,1,-1, 0,0,0, 0,-1,1]) e_3=matrix(SR,3,3, [0,0,0, 1,0,-1, -1,0,1]) e_4=matrix(SR,3,3, [0,0,0, 0,1,-1, 0,-1,1])

M=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-d, 1-a-c, 1-b-d,a+b+c+d-1])

M_1=e_1M+Me_1 M_2=e_2M+Me_2 M_3=e_3M+Me_3 M_4=e_4M+Me_4 A=matrix(SR,4,4, [ M_1[0,0], M_1[0,1],M_1[1,0],M_1[1,1], M_2[0,0], M_2[0,1],M_2[1,0],M_2[1,1], M_3[0,0], M_3[0,1],M_3[1,0],M_3[1,1], M_4[0,0], M_4[0,1],M_4[1,0],M_4[1,1] ])

f(a,b,c,d)=A.determinant()

And then I want a solution to f==0, after giving some random arguments to it

var('k,l,m,n,t,y')

for i in range(5): k=random(); n=random() if k>n: y=k else: y=n l=random()(1-y) m=random()(1-y) if k+l+m+n>1:
sols=solve([f(kt+1-t,lt,mt,nt+1-t)==0], t); sols[1]

A wild string of numbers pops out. But how do i get to see how much is it? Changing to sols[1].n() gives "TypeError: cannot evaluate symbolic expression numerically".

 2 No.2 Revision kcrisman 11857 ●36 ●119 ●237

cannot evaluate symbolic expression numerically

I'm probably doing something wrong on a fundamental level, so: sorry for my ignorance. Yet i'd very much appreciate any suggestions, how to make this work:

I have me a function f, defined in somewhat lenghty way:

way: var('a,b,c,d')

i=matrix(SR,3,3, [1,0,0, 0,1,0, 0,0,1])

e_1=matrix(SR,3,3, [1,0,-1, 0,0,0, -1,0,1]) e_2=matrix(SR,3,3, [0,1,-1, 0,0,0, 0,-1,1]) e_3=matrix(SR,3,3, [0,0,0, 1,0,-1, -1,0,1]) e_4=matrix(SR,3,3, [0,0,0, 0,1,-1, 0,-1,1])

M=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-d, 1-a-c, 1-b-d,a+b+c+d-1])

M_1=e_1M+Me_1 M_2=e_2M+Me_2 M_3=e_3M+Me_3 M_4=e_4M+Me_4 A=matrix(SR,4,4, [ M_1[0,0], M_1[0,1],M_1[1,0],M_1[1,1], M_2[0,0], M_2[0,1],M_2[1,0],M_2[1,1], M_3[0,0], M_3[0,1],M_3[1,0],M_3[1,1], M_4[0,0], M_4[0,1],M_4[1,0],M_4[1,1] ])

f(a,b,c,d)=A.determinant()

And then I want a solution to f==0, after giving some random arguments to it

var('k,l,m,n,t,y')

for i in range(5): k=random(); n=random() if k>n: y=k else: y=n l=random()(1-y) m=random()(1-y) if k+l+m+n>1:
sols=solve([f(kt+1-t,lt,mt,nt+1-t)==0], t); sols[1]

A wild string of numbers pops out. But how do i get to see how much is it? Changing to sols[1].n() gives "TypeError: cannot evaluate symbolic expression numerically".

 3 No.3 Revision kcrisman 11857 ●36 ●119 ●237

cannot evaluate symbolic expression numerically

I'm probably doing something wrong on a fundamental level, so: sorry for my ignorance. Yet i'd very much appreciate any suggestions, how to make this work:

I have me a function f, defined in somewhat lenghty way: var('a,b,c,d')

way:

var('a,b,c,d')

i=matrix(SR,3,3, [1,0,0, 0,1,0, 0,0,1]) 0,0,1])

e_1=matrix(SR,3,3, [1,0,-1, 0,0,0, -1,0,1])
e_2=matrix(SR,3,3, [0,1,-1, 0,0,0, 0,-1,1])
e_3=matrix(SR,3,3, [0,0,0, 1,0,-1, -1,0,1])
e_4=matrix(SR,3,3, [0,0,0, 0,1,-1, 0,-1,1]) 0,-1,1])

M=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-d, 1-a-c, 1-b-d,a+b+c+d-1]) M_1=e_1M+Me_1
M_2=e_2M+Me_2
M_3=e_3M+Me_3
M_4=e_4M+Me_4
1-b-d,a+b+c+d-1])

M_1=e_1*M+M*e_1
M_2=e_2*M+M*e_2
M_3=e_3*M+M*e_3
M_4=e_4*M+M*e_4
A=matrix(SR,4,4, [ M_1[0,0], M_1[0,1],M_1[1,0],M_1[1,1], M_2[0,0], M_2[0,1],M_2[1,0],M_2[1,1], M_3[0,0], M_3[0,1],M_3[1,0],M_3[1,1], M_4[0,0], M_4[0,1],M_4[1,0],M_4[1,1] ]) f(a,b,c,d)=A.determinant()])

f(a,b,c,d)=A.determinant()


And then I want a solution to f==0, after giving some random arguments to it

var('k,l,m,n,t,y')

var('k,l,m,n,t,y')

for i in range(5):
k=random(); n=random()
if k>n: y=k
else: y=n
l=random()(1-y)
m=random()(1-y)
l=random()*(1-y)
m=random()*(1-y)
if k+l+m+n>1:
sols=solve([f(kt+1-t,lt,mt,nt+1-t)==0],
sols=solve([f(k*t+1-t,l*t,m*t,n*t+1-t)==0], t);
sols[1]sols[1]


A wild string of numbers pops out. But how do i get to see how much is it? Changing to sols[1].n() gives "TypeError: cannot evaluate symbolic expression numerically".