I want to write in sage a 2pi periodic even function defined by f(t) = -t + pi, for t in [0, pi). I already checked Defining a periodic function and defining periodic functions on this plateform, but none of the provided solutions works for me. My main issue is that I need a way to transform any real number x into its unique representative in the interval [-pi, pi). For that I used frac and % but they both raise errors. Could anyone help me out?