On Mon, 1 Mar 2021 at 20:01, Bruno Nicenboim <[email protected]> wrote: > > ``` > cset = ConditionSet(t, t < 1/(mu_1 * tau**2)).intersect(ConditionSet(t, t < > 1/(mu_1 * tau**2))) > s_x = solveset(K_p - x, t, domain=cset) > ``` > As follows. > ``` > Intersection(ConditionSet(t, t < 1/(mu_1*tau**2)), {(-2*mu_1*mu_2 + mu_1*x + > mu_2*x)/(2*mu_1*mu_2*tau**2*x) - sqrt(4*mu_1**2*mu_2**2 + mu_1**2*x**2 - > 2*mu_1*mu_2*x**2 + mu_2**2*x**2)/(2*mu_1*mu_2*tau**2*x), (-2*mu_1*mu_2 + > mu_1*x + mu_2*x)/(2*mu_1*mu_2*tau**2*x) + sqrt(4*mu_1**2*mu_2**2 + > mu_1**2*x**2 - 2*mu_1*mu_2*x**2 + mu_2**2*x**2)/(2*mu_1*mu_2*tau**2*x)}) \ > Intersection(ConditionSet(t, t < 1/(mu_1*tau**2)), {1/(mu_2*tau**2)}) > ``` > > I understand correctly that this is the right approach, but solveset is just > unable to find the right solution given the specific domain?
The output from solveset is I think correct in a formal sense. It is just possible that solveset could do a better job of simplifying it to get the result into a usable form. Conversely the input you are providing to solveset is correct in a formal sense but is also not in a form that solveset can easily use. That's essentially because you're trying to use it for something that it has not really been designed for. The primary purpose of the domain argument to solveset is really to be explicit about whether you want to solve over the reals or the complex numbers for example. When you pass a complicated domain like this all solveset will do is: 1. Check if the domain is a subset of the reals and if so compute solutions over the reals 2. Return the intersection of the solution set with the domain The intersection code will simplify the solution set where possible but it only tries to handle simple cases. While it is possible to pass an interval with symbolic conditions or a conditionset as the domain that is not really intended as an alternative to having a solver that can handle systems of inequalities. It might work in simple cases but I wouldn't expect it to work in complicated cases. I would approach this by solving the equation without any constraints and then checking the conditions afterwards. That is at best all that solveset does in this case but actually the way solveset approaches this is more indirect and less likely to work because the conditions are encoded in the domain. Checking the conditions yourself means you can do it more systematically and you don't have the awkwardness of trying to extract the expressions from the sets. -- Oscar -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxRkpN7S90wYhtsVUvPbrKkHsgu2iEBxK6wuPXJNrC7DWQ%40mail.gmail.com.
