First time here? Check out the FAQ!

Ask Your Question
0

Is it possible to change the default ordering of added terms?

asked 1 year ago

Smrz gravatar image

sage seems to have a default ordering for terms added together in an expression. E.g. if I enter

(1-b)

it will be displayed as

-(b -1)

I.e. the variable is always first and the number always second. While -(b - 1) is correct, in some contexts (1-b) is clearer and more conventional. Is there anyway to change the ordering of terms so that entering (1-b) displays as (1-b)?

thanks

Preview: (hide)

Comments

How b is defined?

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )

b = var("b")

Smrz gravatar imageSmrz ( 1 year ago )

1 Answer

Sort by » oldest newest most voted
1

answered 1 year ago

Emmanuel Charpentier gravatar image

updated 1 year ago

(Answer added to make it easier to find it while perusing this site)

Is there anyway to change the ordering of terms so that entering (1-b) displays as (1-b)?

Nope.

Sage insists on displaying symbolic expressions in its "preferred order" :

sage: foo=1-x ; foo
-x + 1

This Very Frequently Asked Question has already caused much tears, wails and teeth gnashing ; the examples quoted by Max Alexeyev are but a small sample... As pointed out in one of these, acting on this defaul format woul require deep surgery in ginac code, which is a minefield (with rusty, unstable mines...).

Since the problem is stricly cosmetic, this difficult task is deemed low priority...

HTH,

Preview: (hide)
link

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: 1 year ago

Seen: 247 times

Last updated: Sep 28 '23