Ask Your Question

frnhr's profile - activity

2023-09-21 05:08:01 +0200 received badge  Famous Question (source)
2020-08-27 17:07:37 +0200 received badge  Student (source)
2018-09-28 07:25:52 +0200 received badge  Notable Question (source)
2015-10-29 13:11:53 +0200 received badge  Popular Question (source)
2013-10-30 16:24:16 +0200 marked best answer can sage stop ordering terms?

Short answer is "probably not, unless you want to muck about in the internals of Ginac/Pynac, our symbolics engine". Even this one reorders:

sage: B.add(A,hold=True)
A + B

I think that some symbolics programs find a semi-canonical ordering and stick with that... Interestingly,

sage: C - A*x
-A*x + C

so the minus sign comes out only with the fraction. It's conceivable that one could consider this inconsistency a bug, though I am not qualified to assess that.

That said, perhaps one could make a feature request to control this, though I suspect this would be harder than one thinks.

2013-10-30 16:24:16 +0200 received badge  Scholar (source)
2013-10-25 13:54:56 +0200 commented answer can sage stop ordering terms?

If I had to guess, I'd say that Sage tries to guess the order of each term and sorts them accordingly. `x^3` will probably come before `x^2`, etc.

2013-10-25 13:52:49 +0200 received badge  Supporter (source)
2013-10-24 13:15:23 +0200 commented answer can sage stop ordering terms?

We definitely want B+A+B to become 2A+B, but I'm in a situation that I don't want B+2A to become 2A+B. That pretty much sums it up :) Thanks for the effort on the function! Looks good for simple expressions, though I doubt this approach can be flexible enough for more complex expressions, e.g. fractions, several parenthesis etc.

2013-10-24 08:58:50 +0200 asked a question can sage stop ordering terms?

Noob question incoming...

sage: var('A B C x y')
(A, B, C, x, y)
sage: y == (C - Ax) / B
y == -(A
x - C)/B

What I would like/expect to get here is y == (C - Ax)/B. Is there a way to tell Sage to stop ordering terms?

Rationale - the expression ultimately goes to latex() and I'd like to be able to control how the result looks like.