Ask Your Question

# 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

\begin{equation} Q=e^{3t} \end{equation}

How can I generate an output as \begin{equation} Q=e^{I1} \end{equation}

edit retag close merge delete

## 1 answer

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

## Comments

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.

## Your Answer

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

Add Answer

## Stats

Asked: 2016-03-07 14:12:02 -0500

Seen: 134 times

Last updated: Mar 07 '16