0
$\begingroup$

I'd like to filter the results of a solve giving inequality conditions: let's say I have

Solve[f[x]==g[y],y]

since i want y as function of x, but I want only the results where x>k and y<k... Is there any way to specify this kind of constraints for the solve? How can I otherwise filter the results ?

$\endgroup$

1 Answer 1

5
$\begingroup$

Please look at the documentation page for Solve where states clearly that inequalities can be directly given as part of the equations. Here is a simple example:

In[23]:= Solve[x^2 + 2 x == y && y < 5 && x < 5, y]

Out[23]= {{y -> 
   ConditionalExpression[2 x + x^2, -1 - Sqrt[6] < x < -1 + Sqrt[6]]}}

You can filter (select) the results from Solve using Select function with appropriate conditions because the results from Solve are just a list of Rules. For instance:

In[24]:= sols = Flatten[y /. Solve[x^2 + 2 x == y^2 + 3, y]]

Out[24]= {-Sqrt[-3 + 2 x + x^2], Sqrt[-3 + 2 x + x^2]}

In[25]:= Select[sols /. x -> 3 , # > 2 &]

Out[25]= {2 Sqrt[3]}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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