First time here? Check out the FAQ!

Ask Your Question
5

Prevent sage from simplifying

asked 14 years ago

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

Preview: (hide)

Comments

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

twk gravatar imagetwk ( 14 years ago )

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

niles gravatar imageniles ( 14 years ago )

3 Answers

Sort by » oldest newest most voted
8

answered 14 years ago

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

Preview: (hide)
link

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 ( 13 years ago )

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 ( 13 years ago )

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 ( 10 years ago )

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

kcrisman gravatar imagekcrisman ( 10 years ago )
1

answered 14 years ago

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.

Preview: (hide)
link

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 ( 14 years ago )

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 ( 14 years ago )

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 ( 14 years ago )

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 ( 14 years ago )
1

answered 14 years ago

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.

Preview: (hide)
link

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 ( 14 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: 14 years ago

Seen: 3,148 times

Last updated: Feb 10 '11