Wynne
Wynne

Reputation: 210

Assuming that a symbol has an integer value in SymPy

I believe that the following should evaluate to 1, but it doesn't. Any hints on how to make it work?

n = Symbol('n')
with assuming(Q.integer(n)):
    print(cos(2*pi*n))

Upvotes: 2

Views: 695

Answers (1)

Rodrigo de Azevedo
Rodrigo de Azevedo

Reputation: 1143

>>> from sympy import *
>>> n = Symbol('n', integer=True)
>>> cos(2*pi*n) 
1
>>> sin(2*pi*n) 
0

Upvotes: 2

Related Questions