ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 07 Mar 2016 17:44:28 -0600Display symbolic expressions without expansionhttp://ask.sagemath.org/question/32729/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}
Mon, 07 Mar 2016 14:12:02 -0600http://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/Answer by tmonteil for <p>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:</p>
<pre><code>var('t')
cc=matrix(SR, 3, 3, t)
I1=cc.trace()
Q=exp(I1)
show(Q)
</code></pre>
<p>With the above code, the output would be</p>
<p>\begin{equation}
Q=e^{3t}
\end{equation}</p>
<p>How can I generate an output as
\begin{equation}
Q=e^{I1}
\end{equation}</p>
http://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/?answer=32730#post-id-32730The 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.
Mon, 07 Mar 2016 15:04:22 -0600http://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/?answer=32730#post-id-32730Comment by Liang for <p>The problem here is that <code>I1</code> is a <em>Python name</em> whose value is the <em>symbolic expression</em> <code>3*t</code>, 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).</p>
<p>An unsatisfactory solution to your problem would be, if it is only about printing, to define <code>I1</code> as a symbol (independenly of its meaning):</p>
<pre><code>sage: var('I1')
I1
sage: Q=exp(I1)
sage: show(Q)
</code></pre>
<p>It is not clear to me what you would like to achieve, but i am not sure you can expect more.</p>
http://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/?comment=32732#post-id-32732Thank 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.Mon, 07 Mar 2016 17:44:28 -0600http://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/?comment=32732#post-id-32732