def scale(x)
      return nil if x.nil?
      x=x.to_f
      j=Rubyvis.search(@d, x)
      j=-j-2 if (j<0)
      j=[0,[@i.size-1,j].min].max
      # p @l
      # puts "Primero #{j}: #{@f.call(x) - @l[j]}"
      # puts "Segundo #{(@l[j + 1] - @l[j])}"
      @i[j].call((@f.call(x) - @l[j]) .quo(@l[j + 1] - @l[j]));
    end
def scale(x)
      return nil if x.nil?
      x=x.to_f
      j=Rubyvis.search(@d, x)
      j=-j-2 if (j<0)
      j=[0,[@i.size-1,j].min].max
      # p @l
      # puts "Primero #{j}: #{@f.call(x) - @l[j]}"
      # puts "Segundo #{(@l[j + 1] - @l[j])}"
      @i[j].call((@f.call(x) - @l[j]) .quo(@l[j + 1] - @l[j]));
    end
Transform value +x+ according to domain and range