       Re: manipulating expressions

• To: mathgroup at smc.vnet.net
• Subject: [mg4312] Re: manipulating expressions
• From: Xah Lee <xah at best.com>
• Date: Tue, 9 Jul 1996 00:48:49 -0400
• Organization: Best Internet Communications
• Sender: owner-wri-mathgroup at wolfram.com

```Xah Lee wrote:
> I have an expression, for example
> (16 a^4 - 8 a^2 m^2 + m^4 - 8 a^2 n^2 + 2 m^2 n^2 + n^4 -
>   8 a^2 p^2 - 2 m^2 p^2 - 2 n^2 p^2 + p^4 - 8 a^2 q^2 -
>   2 m^2 q^2 - 2 n^2 q^2 + 2 p^2 q^2 + q^4 )
> that I want to write in a concise form, namely, as a sum of a few
> products. There are many possibilities and it's tedious to form each.
> How would you write a Mathematica program that would take such an
> expression and spits out a few choicy forms for the user?

I posted the above problem and only one person replied with a code.
Here's killough at wagner.convex.com (Lee D. Killough)'s solution:

simple[x_,v_]:=Sum[v^i Factor[Coefficient[#,v,i]],
{i,0,Exponent[#,v]}]&[Expand[x]]

simple[x_] := First @ Sort[simple[x,#]& /@ Variables[x],
Less @@ ( StringLength @ ToString @ # & /@ {##} )& ]

Here's a quick documentation

simple::usage = "simple[expr] returns the concise expression as a sum of
factors. simple[expr,x] returns the expression as a sum of factors of
x."

Xah
xah at best.com; 74631.731 at compuserve.com
http://www.best.com/~xah/SpecialPlaneCurves_dir/specialPlaneCurves.html
Mountain View, CA, USA
URL of the day: All Philosophers love you in N.Y.
http://nifty.bookstore.uidaho.edu/Philosophy/Default.htm

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Re: Mandelbrot & Julia sets
• Next by Date: Re: Help: Column/Row Vector
• Previous by thread: Re: Mandelbrot & Julia sets
• Next by thread: Re: Display of 3D contours in 2D