Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: manipulating expressions
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Xah Lee

Posts: 171
Registered: 12/4/04
Re: manipulating expressions
Posted: Jun 28, 1996 9:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@wagner.convex.com (Lee D. Killough)'s solution:

simple[x_,v_]:=Sum[v^i Factor[Coefficient[#,v,i]],

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

xah@best.com; 74631.731@compuserve.com
Mountain View, CA, USA
URL of the day: All Philosophers love you in N.Y.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.