From: Yaroslav Bulatov on
I'd like to solve the system of equations below and Mathematica gets
stuck, are the tricks I can do to help it solve this kind of system?
It should produce solution q1=p1, q2=p2, q3=p3, q4=p4

lagr = p1 (Log[q1/(q1 + q3)] + Log[q1/(q1 + q2)]) +
p2 (Log[q2/(q1 + q2)] + Log[q2/(q2 + q4)]) +
p3 (Log[q3/(q1 + q3)] + Log[q3/(q3 + q4)]) +
p4 (Log[q4/(q2 + q4)] + Log[q4/(q3 + q4)]) - \[Lambda] (q1 + q2 +
q3 + q4 - 1);
vars = {q1, q2, q3, q4, \[Lambda]};

Assuming[{p1 > 0 && p2 > 0 && p3 > 0 && p4 > 0 &&
p1 + p2 + p3 + p4 == 1 && q1 > 0 && q2 > 0 && q3 > 0 && q4 > 0},
Solve[D[lagr, #] == 0 & /@ vars, vars]]

Motivation: I'm trying to show consistency of some pseudo-likelihood
estimators, this example is the simplest case where PL applies

From: Andrzej Kozlowski on
First: Assuming does nothing at all with Solve. You would need to use FullSimplify or Simplify for assuming to be of any use.

Second: how can you expect to obtain your solution if:

In[45]:== Simplify[(D[lagr, #1] ==== 0 & ) /@ vars /. {q1 -> p1,
q2 -> p2, q3 -> p3,
q4 -> p4}]

Out[45]== {\[Lambda] ==== 0, \[Lambda] ==== 0, \[Lambda] ==== 0, \[Lambda] ====
0,
p1 + p2 + p3 + p4 ==== 1}

Note that for your solution to be valid lambda would have to be zero.

Third, even if this involves a simple mistake or a misunderstanding, you have a non-linear system of equations and unknowns with at least 8 variables, and since all relevant algorithms have very high complexity with respect to the number of variables is it ery unlikely that Mathematica can solve this system in a reasonable time.

Andrzej Kozlowski


Andrzej Kozlowski

On 10 Aug 2010, at 09:55, Yaroslav Bulatov wrote:

> I'd like to solve the system of equations below and Mathematica gets
> stuck, are the tricks I can do to help it solve this kind of system?
> It should produce solution q1==p1, q2==p2, q3==p3, q4==p4
>
> lagr == p1 (Log[q1/(q1 + q3)] + Log[q1/(q1 + q2)]) +
> p2 (Log[q2/(q1 + q2)] + Log[q2/(q2 + q4)]) +
> p3 (Log[q3/(q1 + q3)] + Log[q3/(q3 + q4)]) +
> p4 (Log[q4/(q2 + q4)] + Log[q4/(q3 + q4)]) - \[Lambda] (q1 + q2 +
> q3 + q4 - 1);
> vars == {q1, q2, q3, q4, \[Lambda]};
>
> Assuming[{p1 > 0 && p2 > 0 && p3 > 0 && p4 > 0 &&
> p1 + p2 + p3 + p4 ==== 1 && q1 > 0 && q2 > 0 && q3 > 0 && q4 > 0},
> Solve[D[lagr, #] ==== 0 & /@ vars, vars]]
>
> Motivation: I'm trying to show consistency of some pseudo-likelihood
> estimators, this example is the simplest case where PL applies
>

From: Sjoerd C. de Vries on
Couldn't solve your system, but AFAIK Solve doesn't accept
Assumptions, so setting up an Assuming environment for Solve won't
work. You should resort to Reduce which can solve systems of
equalities and inequalities (but doesn't yield a quick solution either
in this case).

Cheers -- Sjoerd

On Aug 10, 9:55 am, Yaroslav Bulatov <yarosla...(a)gmail.com> wrote:
> I'd like to solve the system of equations below and Mathematica gets
> stuck, are the tricks I can do to help it solve this kind of system?
> It should produce solution q1=p1, q2=p2, q3=p3, q4=p4
>
> lagr = p1 (Log[q1/(q1 + q3)] + Log[q1/(q1 + q2)]) +
> p2 (Log[q2/(q1 + q2)] + Log[q2/(q2 + q4)]) +
> p3 (Log[q3/(q1 + q3)] + Log[q3/(q3 + q4)]) +
> p4 (Log[q4/(q2 + q4)] + Log[q4/(q3 + q4)]) - \[Lambda] (q1 + q2 +
> q3 + q4 - 1);
> vars = {q1, q2, q3, q4, \[Lambda]};
>
> Assuming[{p1 > 0 && p2 > 0 && p3 > 0 && p4 > 0 &&
> p1 + p2 + p3 + p4 == 1 && q1 > 0 && q2 > 0 && q3 > 0 && q4 > 0=
},
> Solve[D[lagr, #] == 0 & /@ vars, vars]]
>
> Motivation: I'm trying to show consistency of some pseudo-likelihood
> estimators, this example is the simplest case where PL applies


From: Yaroslav Bulatov on
First, thanks for the tip
Second, you are right, lambda is always 0 at the solution, so we use
this fact to simplify our set of equations, getting 4 equations
instead of 5, but it still seems to take forever
Third: it seems difficult in general, I was just wondering if there
are tricks to make it feasible for this particular form. For instance,
I earlier had a similar problem with system of equations and the trick
was to solve for one variable at a time, then back-substitute in the
right order http://groups.google.com/group/comp.soft-sys.math.mathematica/msg/8c8c976c37e36fe9

On Tue, Aug 10, 2010 at 8:47 AM, Andrzej Kozlowski <akoz(a)mimuw.edu.pl> wrot=
e:
> First: Assuming does nothing at all with Solve. You would need to use Ful=
lSimplify or Simplify for assuming to be of any use.
>
> Second: how can you expect to obtain your solution if:
>
> In[45]:== Simplify[(D[lagr, #1] ==== 0 & ) /@ vars /. {q1 -> p1,
> q2 -> p2, q3 -> p3,
> q4 -> p4}]
>
> Out[45]== {\[Lambda] ==== 0, \[Lambda] ==== 0, \[Lambda] ==== 0, \[Lambda=
] ====
> 0,
> p1 + p2 + p3 + p4 ==== 1}
>
> Note that for your solution to be valid lambda would have to be zero.
>
> Third, even if this involves a simple mistake or a misunderstanding, you =
have a non-linear system of equations and unknowns with at least 8 variable=
s, and since all relevant algorithms have very high complexity with respect=
to the number of variables is it ery unlikely that Mathematica can solve t=
his system in a reasonable time.
>
> Andrzej Kozlowski
>
>
> Andrzej Kozlowski
>
> On 10 Aug 2010, at 09:55, Yaroslav Bulatov wrote:
>
>> I'd like to solve the system of equations below and Mathematica gets
>> stuck, are the tricks I can do to help it solve this kind of system?
>> It should produce solution q1==p1, q2==p2, q3==p3, q4==p4
>>
>> lagr == p1 (Log[q1/(q1 + q3)] + Log[q1/(q1 + q2)]) +
>> p2 (Log[q2/(q1 + q2)] + Log[q2/(q2 + q4)]) +
>> p3 (Log[q3/(q1 + q3)] + Log[q3/(q3 + q4)]) +
>> p4 (Log[q4/(q2 + q4)] + Log[q4/(q3 + q4)]) - \[Lambda] (q1 + q2 +
>> q3 + q4 - 1);
>> vars == {q1, q2, q3, q4, \[Lambda]};
>>
>> Assuming[{p1 > 0 && p2 > 0 && p3 > 0 && p4 > 0 &&
>> p1 + p2 + p3 + p4 ==== 1 && q1 > 0 && q2 > 0 && q3 > 0 && q4 > 0},
>> Solve[D[lagr, #] ==== 0 & /@ vars, vars]]
>>
>> Motivation: I'm trying to show consistency of some pseudo-likelihood
>> estimators, this example is the simplest case where PL applies
>>
>
>