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/af07b541-f205-4b81-b3f1-521aab99774co%40googlegroups.com.

Reply via email to