--- /dev/null
+function [p,delta] = partition(integerN, a, b)
+ ## Partition the interval [a,b] into integerN subintervals. We do not
+ ## requite that a<b.
+ ##
+ ## INPUTS:
+ ##
+ ## * integerN - The number of subintervals.
+ ##
+ ## * a - The "left" endpoint of the interval to partition.
+ ##
+ ## * b - The "right" endpoint of the interval to partition.
+ ##
+ ##
+ ## OUTPUTS:
+ ##
+ ## * p - The resulting partition, as a vector of length integerN+1.
+ ##
+ ## * delta - The distance between x_i and x_{i+1} in the partition.
+ ##
+ ##
+
+ ## We don't use abs() here because `b` might be less than `a`. In that
+ ## case, we want delta negative so that when we add it to `a`, we move
+ ## towards `b`.
+ delta = (b - a)/integerN;
+
+ p = [a : delta : b];
+end