working example: triangle function with periodic boundary