Ask Your Question

implicit_plot3d(A(a,b,c,d).determinant()==0,...), variable not found

asked 2012-07-30 14:52:07 +0200

ozik gravatar image

updated 2015-01-13 18:23:11 +0200

FrédéricC gravatar image

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:

ValueError: Variable 'd' not found

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]);
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])
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] ])
implicit_plot3d(f, (a, 0,1), (b, 0,1), (c, 0,1))
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2012-07-30 15:10:25 +0200

kcrisman gravatar image

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

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!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-07-30 14:52:07 +0200

Seen: 692 times

Last updated: Jul 30 '12