code: public static double[] sequence (double start, double end, int length) {
          // Declare and initialize the return value:
          double[] retval = new double[length];
  
          // Calculate step:
          double step = (end - start) / (length == 1 ? 1 : length - 1);
  
          // Iterate and fill:
          for (int i = 0; i < length; i++) {
              retval[i] = start + (i * step);
          }
  
          // Done, return;
          return retval;
      }
docs: Generates a sequence of specified length from specified start to specified end.
  
  @param start The number to start with.
  @param end The number to end with.
  @param length The length of the desired sequence.
  @return A sequence of length {@code length} starting with {@code start} and ending with {@code end}.