Discussion:
Descending order
(too old to reply)
Bruno Campanini
2006-11-27 09:55:20 UTC
Permalink
After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?

I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4

Bruno
Jean-Marc Gulliet
2006-11-28 11:16:43 UTC
Permalink
Post by Bruno Campanini
After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?
I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4
Bruno
In[1]:=
x+x^2+x^3+x^4//TraditionalForm

Out[1]
x^4 + x^3 + x^2 + x

For more detail explanations and alternatives solutions, see the
technical FAQ titled "How can I change the order of the terms in a
polynomial?" at
http://support.wolfram.com/mathematica/mathematics/algebra/polynomialsorting.html

Regards,
Jean-Marc
David Park
2006-11-28 11:24:53 UTC
Permalink
Bruno,

Use TraditionalForm.

x + x^2 + x^3 + x^4
% // TraditionalForm

David Park
***@earthlink.net
http://home.earthlink.net/~djmp/

From: Bruno Campanini [mailto:***@gmail.com]


After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?

I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4

Bruno
Damian Longree
2006-11-28 11:39:01 UTC
Permalink
Use:

x + x^2 + x^3 + x^4//TraditionalForm
Post by Bruno Campanini
After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?
I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4
Bruno
Bob Hanlon
2006-11-28 11:49:07 UTC
Permalink
Set your Default Output FormatType (Cell menu) to TraditionalForm or explicitly use TraditionalForm

x+x^2+x^3+x^4//TraditionalForm

x^4 + x^3 + x^2 + x


Bob Hanlon
Post by Bruno Campanini
After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?
I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4
Bruno
Bruno Campanini
2006-12-01 11:26:01 UTC
Permalink
Post by Bob Hanlon
Set your Default Output FormatType (Cell menu) to TraditionalForm or
explicitly use TraditionalForm
x+x^2+x^3+x^4//TraditionalForm
x^4 + x^3 + x^2 + x
Bob Hanlon
Ok, that's what I was looking for!

Many thanks to you and to other people who
replied to the question.

Bruno

dimitris
2006-11-28 11:51:08 UTC
Permalink
The trivial answer is: Use TraditionalForm

FrontEndExecute[{HelpBrowserLookup["MainBook", "1.10.9"]}]

defpol=x^4+x^3+x^2+x

\!\(x + x\^2 + x\^3 + x\^4\)

TraditionalForm[defpol]

\!\(TraditionalForm\`x\^4 + x\^3 + x\^2 + x\)

The clever answer is to use the following lines below which ensure a
polynomial is written in the opposite order from the usual Format.

These lines have taken from the following link
http://www.verbeia.com/mathematica/tips/HTMLLinks/Tricks_A-K_32.html

Unprotect[Plus];
HoldPattern[Plus[p__]] := Module[{s1, s2}, s1 = Hold[p]; s2 =
Reverse[s1];
ReplacePart[HoldForm[Evaluate[s2]], Plus, {1, 0}] /;
OrderedQ[s1] && s1 =!= s2];


Expand[defpol]
\!\(\*
TagBox[\(x\^4 + x\^3 + x\^2 + x\),
HoldForm]\)

Note however that

FullForm[%]
HoldForm[Plus[Power[1,4],Power[1,3],Power[1,2],1]]

The normal convention is restored by

HoldPattern[Plus[p__]] =. ;
Protect[Plus];

I higly suggest you to download the Supplementary Help Browser of Ted
Ersek
(which above code belong to) from the following link

http://library.wolfram.com/infocenter/MathSource/4557/

If you want you can make this to be part of your help browser.

Contact me for more details.

Regards
Dimitris
Post by Bruno Campanini
After Evaluation, is it possible to have Mathematica 5.2
ordering descending instead of ascending?
I.e.
x^4 + x^3 + x^2 + x
instead of
x + x^2 + x^3 + x^4
Bruno
Continue reading on narkive:
Loading...