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))

> Btw, the corresponding Mathematica-function is called Reduce 
> https://reference.wolfram.com/language/ref/Reduce.html

That does look nice. It seems to use many primitives that sympy
doesn't have yet though... I think quantifiers are still some way off
in sympy.

> 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.


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/CAHVvXxS1g%2BLhWMrNPAv71fUdutnuqBw5pS5cPNuAQ_rqvPFDpg%40mail.gmail.com.

Reply via email to