I have lost years of time trying to do simple things in CAS, between Sympy's assumptions-documentation, Maxima's lack of support for lexical scoping, Maple's awfully designed and implemented user-interface and bad documentation, and Mathematica's flaws. I'd have paid $200,000 for a CAS done well if anyone had ever made one. On Tuesday, August 11, 2020 at 12:16:55 PM UTC-7 [email protected] wrote:
> On Tue, Aug 11, 2020 at 6:57 AM My Name <[email protected]> wrote: > > > > Thanks very much for the explanation. > > > > The assumptions issues in Sympy have deterred me from using Sympy almost > completely. It's not clear to me why the old assumption system had to be > replaced. It's not clear to me what's unimplemented in the new system. > > > > You say above, "The point about relations not being implemented is that > there is not currently a way to use the assumption that e.g. x > y but > that's not needed here so this should work". But your code shows Sympy > "using" the assumptions y > -∞ ∧ y < ∞, which are relations. I you are > using the word "use" in a way I don't understanding, and I'm left with this > vague warning about relations being unusable in Sympy, and I go back to > Maple. > > The old assumptions only implement a subset of possible intervals, > with adjectives like "positive", "negative", "finite". You can > represent something like x > 0 because that's the same thing as > "positive", but you can't represent x > y because that isn't > representable by the set of things that the old assumptions can > represent. The only way to represent more advanced relations like x > > y is to use a different syntax from what the old assumptions use, > which is the idea behind the new assumptions. > > Also, the old assumptions aren't going away. We originally were going > to do that, but the current plan is to keep it around as it works just > fine for those things that it can represent. > > Aaron Meurer > > > > > On Monday, August 10, 2020 at 3:53:01 AM UTC-7 Oscar wrote: > >> > >> You can use the old assumptions: > >> > >> In [10]: x = Symbol('x') > >> > >> > >> In [11]: y = Symbol('y') > >> > >> > >> In [12]: a = Symbol('a') > >> > >> > >> In [13]: integrate(cos(x*y), (x, 0, a)) > >> > >> Out[13]: > >> > >> ⎧sin(a⋅y) > >> > >> ⎪──────── for y > -∞ ∧ y < ∞ ∧ y ≠ 0 > >> > >> ⎨ y > >> > >> ⎪ > >> > >> ⎩ a otherwise > >> > >> > >> In [14]: y = Symbol('y', nonzero=True) > >> > >> > >> In [15]: integrate(cos(x*y), (x, 0, a)) > >> > >> Out[15]: > >> > >> sin(a⋅y) > >> > >> ──────── > >> > >> y > >> > >> > >> > >> The new assumptions and refine can handle nonzero. The point about > relations not being implemented is that there is not currently a way to use > the assumption that e.g. x > y but that's not needed here so this should > work: > >> > >> In [16]: y = Symbol('y') > >> > >> > >> In [17]: integrate(cos(x*y), (x, 0, a)) > >> > >> Out[17]: > >> > >> ⎧sin(a⋅y) > >> > >> ⎪──────── for y > -∞ ∧ y < ∞ ∧ y ≠ 0 > >> > >> ⎨ y > >> > >> ⎪ > >> > >> ⎩ a otherwise > >> > >> > >> In [18]: refine(_, Q.nonzero(y)) > >> > >> Out[18]: > >> > >> ⎧sin(a⋅y) > >> > >> ⎪──────── for y > -∞ ∧ y < ∞ ∧ y ≠ 0 > >> > >> ⎨ y > >> > >> ⎪ > >> > >> ⎩ a otherwise > >> > >> > >> > >> I guess that this just isn't implemented yet in refine. > >> > >> > >> Oscar > >> > >> > >> > >> On Monday, 10 August 2020 11:06:02 UTC+1, My Name wrote: > >>> > >>> I do this: > >>> > >>> import sympy > >>> sympy.srepr(sympy.integrate(S('cos(x * y)'), S('(x, 0, a)'))) > >>> > >>> It returns this: > >>> > >>> "Piecewise(ExprCondPair(Mul(Pow(Symbol('y'), Integer(-1)), > sin(Mul(Symbol('a'), Symbol('y')))), And(StrictGreaterThan(Symbol('y'), > -oo), StrictLessThan(Symbol('y'), oo), Unequality(Symbol('y'), > Integer(0)))), ExprCondPair(Symbol('a'), true))" > >>> > >>> How do I find the value of the Piecewise expression when y is nonzero? > I have tried using sympy.refine with Q.nonzero, but that has not worked. > Indeed the docs for refine warn, "Relations in assumptions are not > implemented (yet)". Does that mean there's no way to find the value of the > integral assuming y is nonzero? > > > > -- > > 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/1cf4691a-1092-42c2-b4c5-0eb8ff068404n%40googlegroups.com > . > -- 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/1cefc439-3321-45cb-88a7-c37109889d07n%40googlegroups.com.
