Hi!; i've just today used sage for the first time in my life in order to do this one thing described below. I failed, so if anyone would share some helpful thoughts, Id be very grateful.

I have: four real variables: a,b,c,d, each one satisfying: 0=< a,b,c,d,a+b,a+c,...,c+d=<1, (so that m, the 3x3 matrix, is doubly stochastic:) m=[(a,b,1-a-b), (c,d, 1-c-d), (1-a-c, 1-b-d, a+b+c+d-1)]. I do some simple algerba with m end its elements, ending up with a 4x4, (a,b,c,d)-dependent matrix, A. I want to have a look at a plot of an implicit function det(A)==0. I figured i could use implicit_plot3d e.g. in (a,b,c) space with fixed d.

Yet something went wrong; last line of the error message says:

here's, what I've typed from the top:

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]);
var('a,b,c,d')
m=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-b, 1-a-c, 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] ])
d=0.5
f(a,b,c)=A.determinant()
implicit_plot3d(f, (a, 0,1), (b, 0,1), (c, 0,1))

edit retag close merge delete

Sort by » oldest newest most voted

You just reassigned d too early. d needs to be a variable to do anything with it, and your determinant now has a variable that isn't a variable - d refers to .5, but the symbolic expression doesn't know you did this.

Change the last bit to

f(a,b,c)=A.determinant()
implicit_plot3d(f(d=.5), (a, 0,1), (b, 0,1), (c, 0,1),plot_points=100)


and you should get a pleasing graphic (the plot_points because otherwise it's a bit pixelly at some singularities of the surface. Cool stuff!

more