[Date Index]
[Thread Index]
[Author Index]
Re: Cannot Factor an expression
*To*: mathgroup at smc.vnet.net
*Subject*: [mg87587] Re: Cannot Factor an expression
*From*: "David Park" <djmpark at comcast.net>
*Date*: Mon, 14 Apr 2008 05:40:39 -0400 (EDT)
*References*: <ftscum$b7o$1@smc.vnet.net>
step1 = Sum[(Subscript[z, i] - 1)*(\[Mu] - Subscript[x, i])^2, {i, 1, 3}]
step2 = Expand[step1]
The problem is how to return step2 to the form of step1. The difficulty with
the step2 expression is that the -mu^2 terms from each expansion have been
added together into a single term and Mathematica doesn't know how to split
it apart again. What we need to do is pick out the three sets of terms that
contain the subscripts 1, 2 and 3, partition the -3 mu^2 term between them
and factor.
One method is to write a rule that matches the 5 terms without the -mu^2
term and then adds it back in to factor. Since by this rule mu^2 is being
subtracted out three times we add 3 mu^2 to the original expression to
compensate.
factorrule =
term : (Expand[(Subscript[z, i_] - 1)*(\[Mu] - Subscript[x, i_])^2] +
\[Mu]^2) :>
Factor[term - \[Mu]^2]
step2 + 3 \[Mu]^2 //. factorrule
giving...
(\[Mu] - Subscript[x, 1])^2 (-1 + Subscript[z, 1]) + (\[Mu] -
Subscript[x, 2])^2 (-1 + Subscript[z, 2]) + (\[Mu] - Subscript[x,
3])^2 (-1 + Subscript[z, 3])
The present developmental version of Presentations, which will be released
in a few weeks and purchasers will receive updates, has a new section called
Manipulations. It contains a set of routines that are extremely convenient
for manipulating algebraic expressions. Two of these routines are
MapLevelParts and MapLevelPatterns. These provide a method for applying a
function to a level subset of items. This is most commonly a subset of terms
in a sum. It might also be a subset of factors in a product or a subset of
items in a list. The function is applied to the entire subset and not to the
individual items. Then we could use MapLevelPatterns to affect the same
transformation. Here we pick out subsets that are not free of specific
subscript expressions.
Needs["Presentations`Master`"]
Fold[Function[{e, i},
e // MapLevelPatterns[Factor[# - \[Mu]^2] &, {{_?(\[Not] FreeQ[#,
Subscript[z, i] | Subscript[x, i]] &)}}]],
step2 + 3 \[Mu]^2, {1, 2, 3}]
giving...
(\[Mu] - Subscript[x, 1])^2 (-1 + Subscript[z, 1]) + (\[Mu] -
Subscript[x, 2])^2 (-1 + Subscript[z, 2]) + (\[Mu] - Subscript[x,
3])^2 (-1 + Subscript[z, 3])
--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
"Francogrex" <franco at grex.org> wrote in message
news:ftscum$b7o$1 at smc.vnet.net...
> If Factor is effectively the reverse of expand, then how come factor
> cannot find back the expression below?
>
> Expand[Sum[(Subscript[z, i] - 1)*(\[Mu] - Subscript[x, i])^2, {i, 1,
> 3}]]
>
> Factor[-3*\[Mu]^2 + 2*\[Mu]*Subscript[x, 1] - Subscript[x, 1]^2 +
> 2*\[Mu]*Subscript[x, 2] - Subscript[x, 2]^2 + 2*\[Mu]*Subscript[x,
> 3] -
> Subscript[x, 3]^2 + \[Mu]^2*Subscript[z, 1] -
> 2*\[Mu]*Subscript[x, 1]*Subscript[z, 1] + Subscript[x, 1]^2*
> Subscript[z, 1] + \[Mu]^2*Subscript[z, 2] -
> 2*\[Mu]*Subscript[x, 2]*Subscript[z, 2] + Subscript[x, 2]^2*
> Subscript[z, 2] + \[Mu]^2*Subscript[z, 3] -
> 2*\[Mu]*Subscript[x, 3]*Subscript[z, 3] + Subscript[x, 3]^2*
> Subscript[z, 3]]
>
> Is there some additional arguments to the function factor so that it
> can find back the original:
> Sum[(Subscript[z, i] - 1)*(\[Mu] - Subscript[x, i])^2, {i, 1, 3}]
>
> Thanks for help with this
>
Prev by Date:
**Parallel Computing Toolkit with ssh tunnels**
Next by Date:
**Re: Frametick Orientation (2 Questions)**
Previous by thread:
**Re: Re: Re: Cannot Factor an expression**
Next by thread:
**Any One have an idea?**
| |