Re: Question on Solve

• To: mathgroup at smc.vnet.net
• Subject: [mg112823] Re: Question on Solve
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Sat, 2 Oct 2010 05:44:06 -0400 (EDT)

Andrzej Kozlowski wrote:
> Actually, in Mathematica 7
>
> Simplify[Solve[eqs, vars]]
> During evaluation of In[6]:= Solve::svars:Equations may not give solutions for all "solve" variables. >>
>
>  {{v1 -> I*v8, v2 -> -v8, v3 -> -v8, v4 -> (-I)*v8,
>    v5 -> v8, v6 -> I*v8, v7 -> (-I)*v8}}
>
> which is the general answer, I believe (it includes the trivial case).
>
> So the question still remains why:
>
> Reduce[eqs, vars]
>
> v1 == 0 && v2 == 0 && v3 == 0 && v4 == 0 && v5 == 0 &&
>    v6 == 0 && v7 == 0 && v8 == 0
>
>
> Andrzej Kozlowski

This was tracked to a problem in our testing for zero (essential for
linear algebra, so we do not use a bogus pivot). It has been
provisionally fixed for the next release of Mathematica.

Daniel Lichtblau
Wolfram Research

> On 28 Sep 2010, at 16:21, Andrzej Kozlowski wrote:
>
>> I don't think one can fault Solve since it is not supposed to return complete solutions anyway. I don't have anymore Mathematica 5.2 installed but Mathematica 7 returns a very complex output to your second example and produces a warning that it may not give solutions for all Solve variables. The output is too complicated for me to try to check if it is correct (in some sense anyway) or not.
>>
>> However, here is something that does worry me a little more:
>>
>> eqs = {(-3*Sqrt[3]*v1 + v2 + 17*v3 + (8*I)*Sqrt[3]*v3 -
>>       9*Sqrt[3]*v4 + 9*v5 - Sqrt[3]*v6 - 3*Sqrt[3]*v7 + 9*v8)/16 ==
>>    0, (5*v1 - Sqrt[3]*v2 + 3*Sqrt[3]*v3 + 11*v4 + (8*I)*Sqrt[3]*v4 -
>>       5*Sqrt[3]*v5 + 3*v6 - 3*v7 - Sqrt[3]*v8)/16 ==
>>    0, (-(Sqrt[3]*v1) + 3*v2 + 3*v3 + 5*Sqrt[3]*v4 +
>>       11*v5 + (8*I)*Sqrt[3]*v5 - 3*Sqrt[3]*v6 - Sqrt[3]*v7 - 5*v8)/
>>     16 == 0, (-9*v1 - 3*Sqrt[3]*v2 + Sqrt[3]*v3 + 9*v4 +
>>       9*Sqrt[3]*v5 + 17*v6 + (8*I)*Sqrt[3]*v6 - v7 - 3*Sqrt[3]*v8)/
>>     16 == 0, (9*v1 - Sqrt[3]*v2 + 3*Sqrt[3]*v3 - 9*v4 +
>>       3*Sqrt[3]*v5 - v6 + 17*v7 + (8*I)*Sqrt[3]*v7 - 9*Sqrt[3]*v8)/
>>     16 == 0, (-5*Sqrt[3]*v1 + 3*v2 + 3*v3 + Sqrt[3]*v4 - 5*v5 +
>>       Sqrt[3]*v6 + 3*Sqrt[3]*v7 + 11*v8 + (8*I)*Sqrt[3]*v8)/16 ==
>>    0, ((11 + (8*I)*Sqrt[3])*v1 - 3*Sqrt[3]*v2 + Sqrt[3]*v3 + 5*v4 +
>>       Sqrt[3]*v5 - 3*v6 + 3*v7 + 5*Sqrt[3]*v8)/16 ==
>>    0, (9*Sqrt[3]*v1 + (17 + (8*I)*Sqrt[3])*v2 + v3 + 3*Sqrt[3]*v4 +
>>       9*v5 + 3*Sqrt[3]*v6 + Sqrt[3]*v7 + 9*v8)/16 == 0};
>> vars = {v1, v2, v3, v4, v5, v6, v7, v8};
>>
>>
>>
>> Reduce[eqs, vars]
>>
>> v1 == 0 && v2 == 0 && v3 == 0 && v4 == 0 && v5 == 0 &&
>>   v6 == 0 && v7 == 0 && v8 == 0
>>
>>
>> However, let's just add the condition that not all vi's are 0 and we get:
>>
>> Reduce[And @@ eqs &&  ! And @@ Thread[vars == 0], vars]
>>
>> v2 == I*v1 && v3 == I*v1 && v4 == -v1 &&
>>   v5 == (-I)*v1 && v6 == v1 && v7 == -v1 &&
>>   v8 == (-I)*v1 && v1 != 0
>>
>>
>> Note that your particular solution is a special case of this one. The general solution should be the disjunction of the trivial solution, that Reduce returned and this solutions. It seems to me that this is exactly what Reduce ought to have returned. Of course Solve could not return this since it can't return inequalities.
>>
>> Andrzej Kozlowski
>>
>> On 28 Sep 2010, at 12:04, carlos at colorado.edu wrote:
>>
>>> I have noticed some erratic behavior of Solve,
>>> illustrated in the following two examples.
>>> Suppose I have 8 homogenous linear equations
>>>
>>> eqs={(9*v1-3*Sqrt[3]*v2+v3+v4-(8*I)*Sqrt[3]*v4-
>>> 9*Sqrt[3]*v5+9*v6-Sqrt[3]*v7-3*Sqrt[3]*v8)/16==0,
>>> (-(Sqrt[3]*v1)+5*v2-Sqrt[3]*v3+3*Sqrt[3]*v4-5*v5-
>>> (8*I)*Sqrt[3]*v5-5*Sqrt[3]*v6+3*v7-3*v8)/16==0,
>>> (-5*v1-Sqrt[3]*v2+3*v3+3*v4+5*Sqrt[3]*v5-5*v6-
>>> (8*I)*Sqrt[3]*v6-3*Sqrt[3]*v7-Sqrt[3]*v8)/16==0,
>>> (-3*Sqrt[3]*v1-9*v2-3*Sqrt[3]*v3+Sqrt[3]*v4+9*v5+
>>> 9*Sqrt[3]*v6+v7-(8*I)*Sqrt[3]*v7-v8)/16==0,
>>> (-9*Sqrt[3]*v1+9*v2-Sqrt[3]*v3+3*Sqrt[3]*v4-9*v5+
>>> 3*Sqrt[3]*v6-v7+v8-(8*I)*Sqrt[3]*v8)/16==0,
>>> ((-5-(8*I)*Sqrt[3])*v1-5*Sqrt[3]*v2+3*v3+3*v4+
>>> Sqrt[3]*v5-5*v6+Sqrt[3]*v7+3*Sqrt[3]*v8)/16==0,
>>> (5*Sqrt[3]*v1+(-5-(8*I)*Sqrt[3])*v2-3*Sqrt[3]*v3+
>>> Sqrt[3]*v4+5*v5+Sqrt[3]*v6-3*v7+3*v8)/16==0,
>>> (9*v1+9*Sqrt[3]*v2+v3-(8*I)*Sqrt[3]*v3+v4+
>>> 3*Sqrt[3]*v5+9*v6+3*Sqrt[3]*v7+Sqrt[3]*v8)/16==0};
>>>
>>> The variables are
>>> v={v1,v2,v3,v4,v5,v6,v7,v8};
>>> Then
>>> sol=Solve[eqs,v]; Print[sol];
>>>
>>> gives the parametric solution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>
>>> and I get only the trivial solution
>>> {{v1->0,v2->0,v3->0,v4->0,v5->0,v6->0,v7->0,v8->0}};
>>>
>>> But the system has an infinity of nontrivial solutions,
>>> for example (this one was obtained with another method)
>>>
>>> vsol={v1->-I,v2->1,v3->1,v4->I,v5->-1,v6->-I,v7->I,v8->-1};
>>> Print[Simplify[eqs/.vsol]];
>>> gives {True,True,True,True,True,True,True,True};
>>>
>>> These 2 examples are extracted from several thousands
>>> similar ones.  Solve returns the trivial solution in
>>> about 1/3 of the instances.  Mathematica version used
>>> is 5.2 under Mac OS 10.5.9.
>>>
>>> Question: what do I have to do to get the correct
>>> parametric answers in all cases?
>>>
>

• Prev by Date: Re: Help to solve an integral by using Mathematica Integrate[Sqrt[t
• Next by Date: ScientificForm[], formating question
• Previous by thread: Re: Plotting feasible region of a linear programme
• Next by thread: ScientificForm[], formating question