When trying to evaluate a function f(x) with Sympy, the final output appears to keep sin(n * pi) and cos (n * pi) in symbolic form but does not evaluate them as 0 and (-1)^n respectively when n is defined to be positive integers. However, Symbolab appears to be able to do the above behavior.
Is there a way to get Sympy evaluate expression similar to what Symbolab does?
Minimal example to generate the behavior in Sympy
# Load libraries
import sympy as sp
from sympy import*
from IPython.display import display
init_printing()
# To turn off bugging warnings
import warnings
warnings.filterwarnings('ignore')
x,L,pi = symbols('x, L, pi', real = True, positive = true)
n = symbols('n', positive = True, integer=True)
a_n_x = 2/L
a_n_in = x * cos((n*pi*x)/L)
display(a_n_in)
a_n = a_n_x * integrate(a_n_in, (x,0,2))
display(a_n)
a_n = a_n.subs(L,2)
display(a_n)