code: def square(x):
      
  
      def H(x):
          """Heaveside step function"""
  
          if x < 0.:
              return 0.
          if x == 0.:
              return 0.5
          if x > 0.:
              return 1.
      return 2 * (H(x / L) - H(x / L - 1)) - 1
docs: Square wave of period 2*L