Re: Rearranging expressions in a user-defined form
- To: mathgroup at smc.vnet.net
- Subject: [mg94097] Re: Rearranging expressions in a user-defined form
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 5 Dec 2008 05:27:52 -0500 (EST)
- Organization: Uni Leipzig
- References: <gh8hms$r38$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, lets try the examples expr = a*b + a*c + c*d + c*a - g*d - g*a and (expr /. a*x_ + a*2 c :> a*(x + c) + a*c) /. a*q_Plus + g_ :> a*q + Factor[g] gives: a (b + c) + (a + d) (c - g) and expr //. (q : a | d)*x_ + (q : a | d)*y_ :> q*(x + y) gives: d (c - g) + a (b + 2 c - g) and "third,fourth... form" gives: "third,fourth... form" just as you wish. Regards Jens Alexei Boulbitch wrote: > Dear MathGroup, > > in symbolic transformations of mathematical expressions I often need to > group or transform differently different parts > of these expression, just to make them more visible , or more easy to > analyze or so. Just to give a simplest example, > assume that we have an expression: > > expr = ab + ac + cd + ca- gd - ga > > and I need to have it once in the form like say, > > expr=a (b + c) + (c - g) (d + a) > > and another time in the form say, > > expr=a (b + 2 c - g) + d (c - g) > > or I will need to group it in some third, fourth ... form. You indeed > understand that I gave the example easily treatable without computer, > while I have in mind much more complex transformations of real interest. > > This evidently may be done by copy-pasting parts of the expression in > question and > transforming then separately and then again copy-pasting and thus, > collecting the results together. That's exactly what I do in such a case. > However, this may easily become a source of errors: such as copying > without a sign, or copying a part of the expression, rather than the > whole one and so on. > Finally it considerably slows you down. > > Could you think of tricks to instruct Mathematica to group only certain > terms and not others, and to take certain > factors out of parentheses, while leave others, according to your choice? > > Thank you, Alexei > > > > > >