Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am creating Taylor polynomials and exporting them using TeXForm. When a polynomial p[x] is displayed in Mathematica, it shows, for instance, 1+x+x^2+x^3. However, TeXForm always reverses the polynomial, giving it with largest power first:

TeXForm[p[x]] = x^3+x^2+x+1.

How can I keep the polynomial in the same order? Taylor polynomials are generally thought of as being constructed from low-to-high powers, so reading them in the generated format is a bit confusing to some.

share|improve this question
    
A related question that might be of interest: how to keep “collect” result in order? –  Jens Dec 18 '12 at 17:31
add comment

2 Answers

up vote 5 down vote accepted

Use HoldForm:

In[]:= TeXForm[HoldForm[1 + x + x^2 + x^3]]

Out[]//TeXForm= 1+x+x^2+x^3

Or for a function p[x] evaluating to a polynomial:

In[9]:= TeXForm[HoldForm[Evaluate[p[x]]]]

Out[9]//TeXForm=
1+x+x^2+x^3
share|improve this answer
    
This works if I copy/paste the output into TeXForm[HoldForm[...]]; I'd rather it be done automatically. Using "TeXForm[HoldForm[p[x]]]" just returns "p(x)". –  GregH Dec 18 '12 at 16:48
1  
How about TeXForm[HoldForm[Evaluate[p[x]]]]? –  Joel Klein Dec 18 '12 at 17:19
    
Your answer works. If it were a separate answer, I'd accept it; it is more elegant than using an undocumented command. –  GregH Dec 18 '12 at 17:45
    
Answer edited to add the form for a function p[x]. –  Joel Klein Dec 18 '12 at 17:54
add comment

You can also use the undocumented (and probably deprecated, so beware!) PolynomialForm.

poly = Expand[(1+x)^10]

TeXForm@PolynomialForm[poly, TraditionalOrder -> False]

(* ==> "1+10 x+45 x^2+120 x^3+210 x^4+252 x^5+210 x^6+120 x^7+45 x^8+10 x^9+x^{10}" *)
share|improve this answer
    
Thanks. This works, but using TeXForm[HoldForm[Evaluate[p[x]]]] is probably better. –  GregH Dec 18 '12 at 17:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.