Ask Your Question
4

Prevent sage from simplifying

asked 2010-08-18 20:45:10 +0100

twk gravatar image

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 flag offensive close merge delete

Comments

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

twk gravatar imagetwk ( 2011-02-10 04:36:17 +0100 )edit

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

niles gravatar imageniles ( 2011-02-10 07:12:18 +0100 )edit

3 Answers

Sort by ยป oldest newest most voted
7

answered 2011-01-03 22:09:52 +0100

kcrisman gravatar image

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?.

edit flag offensive delete link more

Comments

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!

twk gravatar imagetwk ( 2011-05-18 18:23:57 +0100 )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.

kcrisman gravatar imagekcrisman ( 2011-05-19 10:47:21 +0100 )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

Stochastic gravatar imageStochastic ( 2015-01-28 12:04:46 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2015-01-28 16:23:59 +0100 )edit
1

answered 2010-08-18 20:55:40 +0100

Harald Schilly gravatar image

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.

edit flag offensive delete link more

Comments

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... ;)

twk gravatar imagetwk ( 2010-08-18 21:04:06 +0100 )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.

Mike Hansen gravatar imageMike Hansen ( 2010-08-19 05:20:19 +0100 )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?

twk gravatar imagetwk ( 2010-08-25 05:32:27 +0100 )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.?

twk gravatar imagetwk ( 2010-08-25 05:32:32 +0100 )edit
1

answered 2010-08-18 20:46:25 +0100

William Stein gravatar image

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.

edit flag offensive delete link more

Comments

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

twk gravatar imagetwk ( 2010-08-18 20:51:37 +0100 )edit

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: 2010-08-18 20:45:10 +0100

Seen: 3,004 times

Last updated: Feb 10 '11