Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: Cannot Factor an expression


Syd,

Formally you are right but, if you evaluate my input (without 
{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}) you will see that 
it actually works. The "official" syntax for PolynomialReduce was 
changed in version 6, and now you are supposed to list the variables. 
In version 5 this was optional. In any case, if you do not list the 
variables, in other words, if you use the syntax 
PolynomialReduce[f[x,y,..],g[x,y,...]] instead of 
PolynomialReduce[f[x,y,..],g[x,y,...],{x,y,...}] Mathematica will 
itself deduce the variables and evaluate the output correctly.  This 
is, in principle, less reliable, which is the reason for the change in 
version 6, but the old way still works. Partly through laziness and 
partly thorugh getting used to the older syntax I often forget to list 
the variables.
Anyway, thanks for reminding me, it's a bad habit which may one day 
get me into trouble although so far it never has ;-)

Andrzej




On 16 Apr 2008, at 08:02, Syd Geraghty wrote:
> Andrzej,
>
> There was a syntax problem with your PolynomialReduce  function 
> below ... (complete inputs) should have been:-
>
> q = Sum[(Subscript[z, i] - 1)*(=CE=BC - Subscript[x, i])^2, {i, 1, 3}]
>
> p = Expand[q]
>
> Factor[First[
> PolynomialReduce[
>  p, {Subscript[z, 1] - 1, Subscript[z, 2] - 1,
>   Subscript[z, 3] - 1}, {Subscript[x, 1], Subscript[x, 2], 
> Subscript[x,
>   3]}]]].{Subscript[z, 1] - 1, Subscript[z, 2] - 1, Subscript[z, 3] 
> - 1}
>
>
> There is a missing ", {Subscript[x, 1], Subscript[x, 2], 
> Subscript[x, 3]}]"
>
> It seems your postings are sometimes missing lines because I am sure 
> you would have tested your function yet it clearly fails 6.0.2's 
> syntax checking.
>
> HTH Syd
>
>
> Syd Geraghty B.Sc, M.Sc.
>
> sydgeraghty at mac.com
>
> My System
>
> Mathematica 6.0.1 for Mac OS X x86 (64 - bit) (June 19, 2007)
> MacOS X V 10.5 .20
> MacBook Pro 2.33 Ghz Intel Core 2 Duo  2GB RAM
>
>
>
>
> On Apr 15, 2008, at 2:55 AM, Andrzej Kozlowski wrote:
>
>> I got my p's and q's mixed up in addition to having some garbled
>> input. So here we go again:
>>
>>
>> q = Sum[(Subscript[z, i] - 1)*
>>   (\[Mu] - Subscript[x, i])^2, {i, 1, 3}]
>>
>> (Subscript[z, 1] - 1)*(\[Mu] - Subscript[x, 1])^2 +
>> (\[Mu] - Subscript[x, 2])^2*(Subscript[z, 2] - 1) +
>> (\[Mu] - Subscript[x, 3])^2*(Subscript[z, 3] - 1)
>> In[2]:=
>> p = Expand[q];
>>
>>
>> Factor[First[PolynomialReduce[p,
>>    {Subscript[z, 1] - 1, Subscript[z, 2] - 1,
>>     Subscript[z, 3] - 1}]]] .
>> {Subscript[z, 1] - 1, Subscript[z, 2] - 1,
>>  Subscript[z, 3] - 1}
>>
>> (Subscript[z, 1] - 1)*(\[Mu] - Subscript[x, 1])^2 +
>> (\[Mu] - Subscript[x, 2])^2*(Subscript[z, 2] - 1) +
>> (\[Mu] - Subscript[x, 3])^2*(Subscript[z, 3] - 1)
>>
>>
>> All free and no need to load any Add On packages ;-)
>>
>> Andrzej Kozlowski
>>
>>
>> On 14 Apr 2008, at 18:46, Andrzej Kozlowski wrote:
>>> Factor is not "effectively the reverse of Expand", except in the 
>>> case
>>> of when you expand an expression that has been factored in *the 
>>> usual
>>> sense*, in other words, into multiplicative factors (don't forget 
>>> that
>>> a "factor" is the same thing as a "divisor"). Other kinds of 
>>> "pseudo-
>>> factorizations", like the one you want, are not unique, and
>>> Mathematica can't read your mind to find out which one you like 
>>> best.
>>> For example:
>>>
>>> q = Sum[(Subscript[z, i] - 1)*(=CE=BC - Subscript[x, i])^2, {i, 1, 
>>> 3}]
>>>
>>> (Subscript[z, 1] - 1)*(=CE=BC - Subscript[x, 1])^2 +
>>> (=CE=BC - Subscript[x, 2])^2*(Subscript[z, 2] - 1) +
>>> (=CE=BC - Subscript[x, 3])^2*(Subscript[z, 3] - 1)
>>>
>>> p = Expand[q];
>>>
>>> FullSimplify[p]
>>>
>>> (Subscript[z, 1] + Subscript[z, 2] + Subscript[z, 3] - 3)*\[Mu]^2 -
>>> 2*Subscript[x, 1]*(Subscript[z, 1] - 1)*\[Mu] -
>>> 2*Subscript[x, 2]*(Subscript[z, 2] - 1)*\[Mu] -
>>> 2*Subscript[x, 3]*(Subscript[z, 3] - 1)*\[Mu] +
>>> Subscript[x, 1]^2*(Subscript[z, 1] - 1) +
>>> Subscript[x, 2]^2*(Subscript[z, 2] - 1) +
>>> Subscript[x, 3]^2*(Subscript[z, 3] - 1)
>>>
>>> in by many criteria not worse then the one you want.
>>>
>>> However, there is, in fact, a way to get the form  q by starting 
>>> from
>>> p, as long as you know that that is what you want:
>>>
>>>
>>> Factor[First[PolynomialReduce[q, {Subscript[z, 1] - 1,
>>>    Subscript[z, 2] - 1, Subscript[z, 3] - 1}]]] .
>>> {Subscript[z, 1] - 1, Subscript[z, 2] - 1, Subscript[z, 3] - 1}
>>>
>>> (Subscript[z, 1] - 1)*(\[Mu] - Subscript[x, 1])^2 +
>>> (\[Mu] - Subscript[x, 2])^2*(Subscript[z, 2] - 1) +
>>> (\[Mu] - Subscript[x, 3])^2*(Subscript[z, 3] - 1)
>>>
>>> Andrzej Kozlowski
>>>
>>>
>>> On 13 Apr 2008, at 16:31, Francogrex wrote:
>>>> 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: Re: Extending Integrate[]
  • Next by Date: Re: A Problem with Simplify
  • Previous by thread: Re: Re: Re: Cannot Factor an expression
  • Next by thread: Re: Cannot Factor an expression