code: public static double bound(double x, double min, double max) {
          if (x > max) {
              return max;
          }
          if (x < min) {
              return min;
          }
          return x;
      }
docs: Returns `x` bounded in `[\min,\max]`
  
  @param x is the value to be bounded
  @param min is the minimum value of the range
  @param max is the maximum value of the range
  @return ` \begin{cases} \min & \mbox{if $x < \min$} \cr
  \max & \mbox{if $x > \max$} \cr x & \mbox{otherwise} \end{cases}
  `