Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
f(t) = -t + pi        # interval  [0, pi]
g(t) = 1/2*f(t*pi)    # transformed to interval  [-1, 1]
h = lambda x: 2*g(RR(x/pi).frac())   # including retransformation
plot(h,0,3*pi)

EDITED

f(t) = -t + pi        # interval  [0, pi]
g(t) = 1/2*f(t*pi)    # transformed to interval  [-1, 1]
# h = lambda x: 2*g(RR(x/pi).frac())   # including retransformation
plot(h,0,3*pi)
h = lambda x: (heaviside(x)-1)*pi + 2*g(RR(x/pi).frac())
plot(h,-3*pi,3*pi)

EDITED

f(t) = -t + pi        # interval  [0, pi]
g(t) = 1/2*f(t*pi)    # transformed to interval  [-1, 1]
# h = lambda x: 2*g(RR(x/pi).frac())   # including retransformation
h = lambda x: (heaviside(x)-1)*pi + 2*g(RR(x/pi).frac())
plot(h,-3*pi,3*pi)

UPDATE 2 --- a symbolic function:

f(x) = 1/2*(sign(sin(2*x))*arccos(cos(2*x-pi)) + pi)
plot(f,-3*pi,3*pi,aspect_ratio=1)