Yes, my code is viewable in here-
https://github.com/orielmalihi/Final-Project/blob/main/my%20functions/inequalities%20functions.py

On Friday, 18 June 2021 at 00:09:11 UTC+3 Oscar wrote:

> That's great. I suggest not trying to add everything at once. Probably 
> some changes will need to be made and there are other steps like tests and 
> so on that would need to be added if there aren't already tests in the 
> right format.
>
> Is your code publicly viewable already? For example if you put it in a 
> github repo/gist then you can send a link here.
>
> Oscar
>
> ‪On Thu, 17 Jun 2021 at 20:17, ‫אוריאל מליחי‬‎ <[email protected]> 
> wrote:‬
>
>> Hello everyone!
>>
>> I finally completed implementing these functions.
>>
>>
>> *Quick reminder:* The main function is called *is_implied_by* and it 
>> gets a set of linear inequalities and a target linear inequality and return 
>> whether the target is implied by the set or not.
>>
>> Two other functions are *find_values_interval *and 
>> *simplify_linear_inequalities.*
>>
>> * find_values_interval* gets a set of linear inequalities and a target 
>> expression (expr) and returns an interval of [min possible value for expr, 
>> max possible value for expr].
>>
>> *simplify_linear_inequalities* gets a set of linear inequalities and 
>> returns a simplified set (redundant inequalities are removed).
>>
>> Now I would like to know what are the next steps for me to do in order to 
>> get my implementation into sympy. This is my first time contributing so 
>> detailed explanation would be really helpful.
>>
>>
>>
>> On Thursday, 18 February 2021 at 18:28:38 UTC+2 [email protected] 
>> wrote:
>>
>>> Den tors 18 feb. 2021 kl 14:36 skrev Oscar Benjamin <
>>> [email protected]>:
>>>
>>>> On Thu, 18 Feb 2021 at 11:32, Oscar Gustafsson
>>>> <[email protected]> wrote:
>>>> >
>>>> > After currently using Mathematica for similar things, I would just 
>>>> like to encourage you to provide some nice method to simplify constraints 
>>>> of piecewise functions using your simplifier, including additional 
>>>> constraints on the range of variables (as SymPy doesn't have a way to put 
>>>> ranges on variables). That doesn't really exist in Mathematica 
>>>> (Assuming[..., Simplify[piecewise]) doesn't always seems to simplify as 
>>>> far 
>>>> as possible).
>>>> >
>>>> > Something like
>>>> > simplify_piecewise_range(piecewisefunction, common_constraints)
>>>> > That adds the common_constraints to each region constraint and 
>>>> applies your method. (Possibly, optionally, removing the 
>>>> common_constraints 
>>>> from the final regions if feasible.)
>>>>
>>>> I imagined that this would be something that the new assumptions could
>>>> handle in refine. Something like:
>>>>
>>>> p = Piecewise((x, x < 1), (x**2, True))
>>>> p = refine(p, abs(x) < 1)
>>>>
>>>> The idea would then be that e.g. when you have Integral(f, (x, a, b))
>>>> then the integration routine can do
>>>>
>>>> f = refine(f, (a < x) & (x < b))
>>>>
>>> Yes, a different assumption system will also do the trick. But until 
>>> that is in place, this would be a useful short-cut for a specific use case.
>>>
>>>
>>> > There is an old PR which may be useful to revive in relation to this: 
>>>> https://github.com/sympy/sympy/pull/17443 although sort of independent.
>>>> >
>>>> > It will also be useful to have a function that can replace Min/Max 
>>>> expressions with linear inequalities (and possibly back again). Right now 
>>>> there is some logic to convert from linear inequalites to Min/Max, but not 
>>>> back. As far as I recall. (There may be a PR doing the Min/Max to linear 
>>>> as 
>>>> well, but not really sure.)
>>>>
>>>> Is this what you mean?
>>>>
>>>> In [1]: Min(x, y).rewrite(Piecewise)
>>>> Out[1]:
>>>> ⎧x  for x ≤ y
>>>> ⎨
>>>> ⎩y  otherwise
>>>>
>>>> Perhaps there could be a rewrite(Max) for Piecewise.
>>>>
>>>> I seem to recall that I did something that rewrote/simplified, probably 
>>> as part of the pattern based logic simplification,
>>> And(x <= y, x <= z)
>>> to
>>> x <= Min(y, z)  
>>>
>>> At some later stage I realized it was sometimes a bad idea (as the logic 
>>> simplification sometimes worked better without the Min/Max, do not recall 
>>> exactly) and I sort of regretted introducing that rewrite, but cannot 
>>> recall if the reverse operation was ever introduced. Piecewise may work 
>>> though, but I believe that for the linear inequality simplifier it may be 
>>> better to rewrite x <= Min(y, z)  back to  And(x <= y, x <= z) .
>>>
>>> BR 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/07668755-217b-4487-805d-1faefd70191bn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/07668755-217b-4487-805d-1faefd70191bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/6ae5a93d-5976-479d-ad87-017a0c82b603n%40googlegroups.com.

Reply via email to