# Display symbolic expressions without expansion

I'm trying to write symbolic expressions with many intermediate variables. When I use the "show" function to display the final symbolic expression, it always shows the expression with the intermediate variables fully expanded. How can I show the final expression in terms of intermediate variables? Here is a simplified example:

var('t')
cc=matrix(SR, 3, 3, t)
I1=cc.trace()
Q=exp(I1)

show(Q)


With the above code, the output would be

$$Q=e^{3t}$$

How can I generate an output as $$Q=e^{I1}$$

edit retag close merge delete

Sort by ยป oldest newest most voted

The problem here is that I1 is a Python name whose value is the symbolic expression 3*t, so they are not of the same nature at all, and the symbolic system of Sage is not able to make symbolic expressions with arbitrary Sage objects while keeping the information of their name and meaning (e.g. the log of a graph named G).

An unsatisfactory solution to your problem would be, if it is only about printing, to define I1 as a symbol (independenly of its meaning):

sage: var('I1')
I1
sage: Q=exp(I1)
sage: show(Q)


It is not clear to me what you would like to achieve, but i am not sure you can expect more.

more

Thank you for the suggestion. What I want to achieve is to have a "normal" symbolic expression that can be displayed in an easily readable form. Normal here means it can be differentiated or integrated etc. My final expression involves many very complicated functions of the matrix "cc" and displaying with all those functions fully expanded would make the final outcome almost impossible for human to understand.

( 2016-03-08 00:44:28 +0200 )edit