# Prevent sage from simplifying

Hi, When I enter a symbolic equation in sage, it always displays it simplified and not as I typed it in. Is there a way to make sage to keep the equation in that form I typed it?

Thanks, twk

edit retag close merge delete

Hi, any updates on this topic? I still think, that this is a big disadvantage in symbolic calculations in sage!

( 2011-02-09 21:36:17 -0500 )edit

is the "hold=True" option in Sage 4.6 not sufficient?

( 2011-02-10 00:12:18 -0500 )edit

Sort by ยป oldest newest most voted

Update: The following is now possible, and should work in Sage 4.6, thanks to Burcin:

sage: x*x
x^2
sage: x.mul(x, hold=True)
x*x
sage: sin(2*pi)
0
sage: sin(2*pi,hold=True)
sin(2*pi)


More documentation can be found in each symbolic function, and x.mul? and x.add?.

more

Hi, sorry for answering so late. It's very hard to type equations this way or am I wrong? This can basically be a solution but I've to to test it. Thanks for this suggestion!

( 2011-05-18 11:23:57 -0500 )edit

In theory we could create a global hold context - see http://trac.sagemath.org/sage_trac/ticket/10035. I don't think this will be done any time soon, though.

( 2011-05-19 03:47:21 -0500 )edit

What's the status of this issue? I agree with twk, that this is a little gnarly to type. Without this nicely implemented, it's almost impossible to know if the simplification makes sense, or even what your input was interpreted as. It's certainly barrier to new students, and even more experienced folks.

I do like the way WolframAlpha handles this. In this example, it checks to see if this expression is true (unsimplified on one side, simplified on the other):

 x*x*x == x**3


http://www.wolframalpha.com/input/?i=xxx+%3D%3D+x**3

( 2015-01-28 05:04:46 -0500 )edit

I agree on the "gnarly" nature, but it seems unlikely that a "hold" context will be implemented in the near term.

( 2015-01-28 09:23:59 -0500 )edit

I know it's not what you mean, but you can use strings:

sage: ex = "2*x+2*x"
sage: ex
'2*x+2*x'
sage: var('x')
sage: sage_eval(ex, locals = globals())
4*x


But for example you don't get the correct latex representation of ex when you do latex(ex), it's just typed as a string.

more

Could this be an easy start to contribute to sage or will it be more complicated to implement a real "hold" feature? Maybe next month, I'd have enough time to have a look at it if a sage-freshman has a chance to solve it... ;)

( 2010-08-18 14:04:06 -0500 )edit

The above code would not be the place to start for actually implementing this feature. To actually do this, you'd have to work on Pynac which is a C++ library based on GiNaC. It may have some internal assumptions that things are already simplified to a certain extent.

( 2010-08-18 22:20:19 -0500 )edit

Of course the above code could not be the start for implementing the feature. Is anybody else interested in getting this "hold" feature into sage?

( 2010-08-24 22:32:27 -0500 )edit

I think interactive symbolic calculations (for example in the notebook) in sage are only a viable alternative to calculating things on paper when I can control the shape of an equation. Is this possible in sympy? Or Mathematica etc.?

( 2010-08-24 22:32:32 -0500 )edit

No, there is no way to do this at present. A "hold" feature for symbolic expressions is something that has been requested a million times on sage-support. I know that Burcin has been thinking about implementing something like this. But it is current not possible.

more

Thanks for the fast reply. It would be great to have that function. Most times I calculate something symbolic sage cannot know what simplification makes sense for better readability. Are there already approaches and ideas how to implement that function? Cheers

( 2010-08-18 13:51:37 -0500 )edit