docs: def from_function(self, f, domain=None, N=None):
          """
          Initialise from a function to sample.
          N: optional parameter which indicates the range of the dichotomy
          """
          # rescale f to the unit domain
          domain = self.get_default_domain(domain)
          a,b = domain[0], domain[-1]
          map_ui_ab = lambda t: 0.5*(b-a)*t + 0.5*(a+b)
          args = {'f': lambda t: f(map_ui_ab(t))}
          if N is not None: # N is provided
              nextpow2 = int(np.log2(N))+1
              args['kmin'] = nextpow2
              args['kmax'] = nextpow2+1
              args['raise_no_convergence'] = False
          else:
              args['raise_no_convergence'] = True
  
          # Find out the right number of coefficients to keep
          coeffs = self.dichotomy(**args)
  
          return self.from_coeff(coeffs, domain)