I'm trying to find the fourier series of the following piecewise
f_t = sym.Piecewise(
(sym.sin(t), (t >= -2 * sym.pi) & (t <= 2 * sym.pi))
)
This is the code I already have, but I'm not able to get some terms because it's stuck. Maybe there is another way to do the calculations and get some terms of the series?
import sympy as sym
t = sym.symbols('t', real = True)
#piecewise function
f_t = sym.Piecewise(
(sym.sin(t), (t >= -2 * sym.pi) & (t <= 2 * sym.pi))
)
#3 terms
num_terms = 3
approx_fourier_series = sym.fourier_series(f_t, (t, -2 * sym.pi, 2 * sym.pi)).truncate(n=num_terms)
#result
print("Fourier Series with", num_terms, "terms:")
print(approx_fourier_series)
I've tried doing this code but I'm not able to get the terms because it seems stuck, so maybe there's another way to calculate the fourier series.