It was really interesting! I think there is also a solution with fourier series.