MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Order of coefficients in output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29960] Re: Order of coefficients in output
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 20 Jul 2001 03:28:25 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <9j64s1$2d9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,


http://support.wolfram.com/mathematica/mathematics/algebra/polynomialsorting.html


or

Unprotect[MakeBoxes]

makeSignPair[-a_] /; ! NumericQ[a] := {"-", MakeBoxes[a]}
makeSignPair[b_?NumericQ*a_] /; b < 0 := {"-", MakeBoxes @@ {-b*a}}
makeSignPair[a_?NumericQ] /; a < 0 := {"-", MakeBoxes @@ {-a}}
makeSignPair[a_] := {"+", MakeBoxes[a]}

MakeBoxes[poly_Plus /; PolynomialQ[poly], form_:StandardForm] := 
  Module[{lst},
      lst = Reverse[List @@ poly];
    lst = Flatten[makeSignPair /@ lst];
    If[lst[[1]] == "+", lst = Rest[lst]];
    RowBox[lst]
    ]

Protect[MakeBoxes] 

will do that.

Regards
  Jens

Martin Harborth wrote:
> 
> Mathematica puts expressions like x^2+2x+1 into the following result:
> 1+2x+x^2. Is there a way to change these standard behaviour so that I get
> the order of coefficients in the output as in the first expression?
> 
> Martin.


  • Prev by Date: RE: notation help: f(x) = (sin x)^(1/3)
  • Next by Date: Re: [Q] Generalized Partitions
  • Previous by thread: Re: Order of coefficients in output
  • Next by thread: Re: Order of coefficients in output