       Re: Ordering polynomials from highest to lowest order

• To: mathgroup at smc.vnet.net
• Subject: [mg25972] Re: [mg25933] Ordering polynomials from highest to lowest order
• From: BobHanlon at aol.com
• Date: Tue, 14 Nov 2000 03:47:05 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```In a message dated 11/10/00 3:44:14 AM, krautschikc at intel.co.jp writes:

>Actually I export the polynomials to another program. So I am using
>FortranForm before I export the List of polynomials to an ASCII file.
>However, after I apply TraditionForm to z37 and then use FortranForm the
>polynomial conversion no longer seem to work as FortranForm canot be applied
>to get rid of Head TraditionalForm. That works expect that I now get back
>what I originally started with, e.g. a polynomial from lowest to highest
order.
>
>Any ideas how to fix this?
>

Use brute force:

Module[{cl = Reverse[CoefficientList[poly, var]], n, pairs, ff},
n = Length[cl] - 1;
pairs = Select[Transpose[{cl, Range[n, 0, -1]}], #[] != 0 &];
ff = StringReplace[StringJoin[
If[#[] > 1,
" + " <> ToString[#[]] <> "*" <> ToString[var] <> "**" <>
ToString[#[]],
If[#[] > 0, " + " <> ToString[#[]] <> "*" <> ToString[var],
" + " <> ToString[#[]]]
] & /@ pairs], {"+ -" -> "- "}];
If[StringTake[ff, 2] == " +", StringDrop[ff, 3], ff]];

zernike = 1 - 42r^2 + 420r^4 - 1680r^6 + 3150r^8 - 2772r^10 + 924r^12;