function separate_intervals(interval1, interval2) {
  var decrement = find_smallest_change(interval1[0], interval2[0]);
  var increment = find_smallest_change(interval2[1], interval1[1]);

  // If interval1 is included in interval2
  if (
    interval2[0] <= interval1[0] &&
    interval1[0] <= interval2[1] &&
    (interval2[0] <= interval1[1] && interval1[1] <= interval2[1])
  ) {
    // Return the 1 in-interval and nothing is out
    return [interval1, null, null];
  }
  // If only the beginning part of interval1 is in interval2
  else if (interval2[0] <= interval1[0] && interval1[0] <= interval2[1]) {
    // Return the 1 in-interval and 1 out-interval
    return [[interval1[0], interval2[1]], [round(interval2[1] + increment, 2), interval1[1]], null];
  }
  // If only the ending part of interval1 is in interval2
  else if (interval2[0] <= interval1[1] && interval1[1] <= interval2[1]) {
    // Return the 1 in-interval and 1 out-interval
    return [[interval2[0], interval1[1]], [interval1[0], round(interval2[0] - decrement, 2)], null];
  }
  // If interval2 is completely in interval1
  else if (
    interval1[0] <= interval2[0] &&
    interval2[0] <= interval1[1] &&
    (interval1[0] <= interval2[1] && interval2[1] <= interval1[1])
  ) {
    // Return 1 in-interval and 2 out-intervals
    return [
      interval2,
      [interval1[0], round(interval2[0] - decrement, 2)],
      [round(interval2[1] + increment, 2), interval1[1]]
    ];
  }
  // If two interval does not overlap at all
  else {
    // Return 1 out-interval and nothing is ins
    return [null, interval1, null];
  }
}
// Return the in-interval and out-interval

Return the in-interval and out-interval
Return the in - interval and out - interval
function separate_intervals(interval1, interval2) {
  var decrement = find_smallest_change(interval1[0], interval2[0]);
  var increment = find_smallest_change(interval2[1], interval1[1]);
  if (
    interval2[0] <= interval1[0] &&
    interval1[0] <= interval2[1] &&
    (interval2[0] <= interval1[1] && interval1[1] <= interval2[1])
  ) {
    return [interval1, null, null];
  }
  else if (interval2[0] <= interval1[0] && interval1[0] <= interval2[1]) {
    return [[interval1[0], interval2[1]], [round(interval2[1] + increment, 2), interval1[1]], null];
  }
  else if (interval2[0] <= interval1[1] && interval1[1] <= interval2[1]) {
    return [[interval2[0], interval1[1]], [interval1[0], round(interval2[0] - decrement, 2)], null];
  }
  else if (
    interval1[0] <= interval2[0] &&
    interval2[0] <= interval1[1] &&
    (interval1[0] <= interval2[1] && interval2[1] <= interval1[1])
  ) {
    return [
      interval2,
      [interval1[0], round(interval2[0] - decrement, 2)],
      [round(interval2[1] + increment, 2), interval1[1]]
    ];
  }
  else {
    return [null, interval1, null];
  }
}
function separate_intervals ( interval1 , interval2 ) { var decrement = find_smallest_change ( interval1 [ 0 ] , interval2 [ 0 ] ) ; var increment = find_smallest_change ( interval2 [ 1 ] , interval1 [ 1 ] ) ; if ( interval2 [ 0 ] <= interval1 [ 0 ] && interval1 [ 0 ] <= interval2 [ 1 ] && ( interval2 [ 0 ] <= interval1 [ 1 ] && interval1 [ 1 ] <= interval2 [ 1 ] ) ) { return [ interval1 , null , null ] ; } else if ( interval2 [ 0 ] <= interval1 [ 0 ] && interval1 [ 0 ] <= interval2 [ 1 ] ) { return [ [ interval1 [ 0 ] , interval2 [ 1 ] ] , [ round ( interval2 [ 1 ] + increment , 2 ) , interval1 [ 1 ] ] , null ] ; } else if ( interval2 [ 0 ] <= interval1 [ 1 ] && interval1 [ 1 ] <= interval2 [ 1 ] ) { return [ [ interval2 [ 0 ] , interval1 [ 1 ] ] , [ interval1 [ 0 ] , round ( interval2 [ 0 ] - decrement , 2 ) ] , null ] ; } else if ( interval1 [ 0 ] <= interval2 [ 0 ] && interval2 [ 0 ] <= interval1 [ 1 ] && ( interval1 [ 0 ] <= interval2 [ 1 ] && interval2 [ 1 ] <= interval1 [ 1 ] ) ) { return [ interval2 , [ interval1 [ 0 ] , round ( interval2 [ 0 ] - decrement , 2 ) ] , [ round ( interval2 [ 1 ] + increment , 2 ) , interval1 [ 1 ] ] ] ; } else { return [ null , interval1 , null ] ; } }
Return the in-interval and out-interval
Return the in - interval and out - interval
// If interval1 is included in interval2
 // Return the 1 in-interval and nothing is out
 // If only the beginning part of interval1 is in interval2
 // Return the 1 in-interval and 1 out-interval
 // If only the ending part of interval1 is in interval2
 // Return the 1 in-interval and 1 out-interval
 // If interval2 is completely in interval1
 // Return 1 in-interval and 2 out-intervals
 // If two interval does not overlap at all
 // Return 1 out-interval and nothing is ins
