Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

Display symbolic expressions without expansion

asked 9 years ago

Liang gravatar image

updated 9 years ago

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=e3t

How can I generate an output as Q=eI1

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

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.

Preview: (hide)
link

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.

Liang gravatar imageLiang ( 9 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 575 times

Last updated: Mar 07 '16