3
$\begingroup$

I am trying to solve a system of non-linear equations using some easy assumptions. My code is:

ClearAll[a, b, x, y, a12, a22]
Assuming[
    {a > 0, b > 0, a12 > 0, a22 > 0},
    Solve[a12 == (x*(x + y))/(a*(a + b)) && a22 == (y*(x + y))/(b*(a + b)) && x > 0 && y > 0, {x, y}, Reals]
]

Unfortunately Mathematica basically ignores the assumptions and also spits out invalid conditions:

{
    {x->ConditionalExpression[
        -(((a a22^2 b^2+a22^2 b^3)/(a a12+a22 b)-a a22 b-a22 b^2)/Sqrt[((a a22^2 b^2+a22^2 b^3)/(a a12+a22 b))]),
        (a>0\[And]a+b<0\[And]a12<0\[And]b<0\[And]a22>0)\[Or]
        (a>0\[And]a12>0\[And]b>0\[And]a22>0)\[Or]
        (a<0\[And]a+b>0\[And]a12<0\[And]b>0\[And]a22>0)\[Or]
        (a<0\[And]a12>0\[And]b<0\[And]a22>0)\[Or]
        (a+b>0\[And]a12>0\[And]b<0\[And]a22<0)\[Or]
        (a+b<0\[And]a12>0\[And]b>0\[And]a22<0)],
    y->ConditionalExpression[Sqrt[(a a22^2 b^2+a22^2 b^3)/(a a12+a22 b)],
        (a>0\[And]a+b<0\[And]a12<0\[And]b<0\[And]a22>0)\[Or]
        (a>0\[And]a12>0\[And]b>0\[And]a22>0)\[Or]
        (a<0\[And]a+b>0\[And]a12<0\[And]b>0\[And]a22>0)\[Or]
        (a<0\[And]a12>0\[And]b<0\[And]a22>0)\[Or]
        (a+b>0\[And]a12>0\[And]b<0\[And]a22<0)\[Or]
        (a+b<0\[And]a12>0\[And]b>0\[And]a22<0)]
    }
}

I realize that I can get rid of the unneeded solutions by adding the assumptions directly to the Solve command like

Solve[a12 == (x*(x + y))/(a*(a + b)) && a22 == (y*(x + y))/(b*(a + b)) && x > 0 && y > 0 && a>0 && b>0 && a12>0 && a22>0, {x, y}, Reals]

But the result is still a conditional expression:

{
    {x->ConditionalExpression[
        -(((a a22^2 b^2+a22^2 b^3)/(a a12+a22 b)-a a22 b-a22 b^2)/Sqrt[((a a22^2 b^2+a22^2 b^3)/(a a12+a22 b))]),
         b>0\[And]a>0\[And]a22>0\[And]a12>0],
     y->ConditionalExpression[
        Sqrt[(a a22^2 b^2+a22^2 b^3)/(a a12+a22 b)],
        b>0\[And]a>0\[And]a22>0\[And]a12>0]
    }
}

I feel like I missed something fundamentally. Any help would be appreciated.

Cheers

$\endgroup$
4
  • $\begingroup$ Try using Simplify: Assuming[{a > 0, b > 0, a12 > 0, a22 > 0}, Simplify[Solve[ a12 == (x*(x + y))/(a*(a + b)) && a22 == (y*(x + y))/(b*(a + b)) && x > 0 && y > 0, {x, y}, Reals]]] $\endgroup$ – Anjan Kumar Mar 16 '17 at 8:59
  • $\begingroup$ Works like a charm! Thanks! $\endgroup$ – Lxndr Mar 16 '17 at 9:08
  • $\begingroup$ Duplicate: (81004). Similar, but older, answer: (a/1064). Related: (a/23213). $\endgroup$ – Michael E2 Mar 16 '17 at 20:37
  • 1
    $\begingroup$ Possible duplicate of Add assumptions to Solve command $\endgroup$ – MarcoB Mar 17 '17 at 1:01
3
$\begingroup$

From the documentation:

Assuming[assum,expr] evaluates expr with assum appended to $Assumptions, so that assum is included in the default assumptions used by functions such as Refine, Simplify, and Integrate.

This means that

Assuming[assum,Solve[eqn]]

is the same as

Solve[eqn,Assumptions->assum]

But Assumptions is not part of the options of Solve. Hence, your assumptions are ignored. You can wrap Solve with any function that understands Assumptions, such as Simplify.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.