Ask Your Question

Revision history [back]

I disagree: the output consists, in this order, of the simplified q[0], ..., q[3], followed by the 5-tuple (q, (), (), (), ()).

Here is what happens when you run the command in your question.

Your command consists in 3 instructions.

  • The first instruction defines variables k, a, b, c, d.

  • The second instruction defines q.

  • The third and last instruction is a 5-tuple, let us analyse this 5-tuple.

    • The first element in the tuple is q

    • The 2nd to 5th elements in the tuple are 'show(...)'.

A command such as 'show(...)' has a side-effect (show the object) and a return value, which is (). (In this case, of course, the "side-effect" is what you are most interested in.)

So while constructing the 5-tuple, the last 4 elements of the 5-tuple produce side-effects, and this is why in the output you first see the 4 displayed equations q[0] to q[3]. Finally, when the tuple is constructed, it is displayed. Since, by this time, the side-effects of the 'show(...)' commands have already caused q[0] to q[3] to be displayed, the tuple itself is printed last. You can observe that this is a tuple consisting of the list q as its first entry, followed by 4 times '()' (the results of the 'show(...)' commands).

([x == ..., x == ..., x = ..., x = ...],
 None,
 None,
 None,
 None)

For the output you were aiming to get, I would suggest the following input in the Sage Cell Server.

var('k a b c d')
q = solve(k*x^4+a*x^3+b*x^2+c*x+d==0,x)
print(q)
for s in q: show(s.simplify_full())