In my previous question, How to partition $[a,b]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with a subset of $[a,b]$?, I was given an answer to my specific example but I'm not sure how to apply it to arbitrary $A_1$.

For example, if we had a set in the form,


Which is a subset of $[a,b]=[0,1]$, where $z:x,y,z\to \mathbb{R}$; how would we partition $[a,b]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with this form of $A_1$?

Would the code be fast enough for large $m$?

How about other general forms such as $\left\{z(x_1,x_2,...,x_n):x_1,x_2,...,x_n\in\mathbb{Z}\right\}$?

Here is another general example:


  • 1
    $\begingroup$ Your last question is too general. Which other forms? $\endgroup$
    – MarcoB
    Commented Jul 10, 2020 at 14:34
  • $\begingroup$ @MarcoB Such as $\left\{z(x_1,x_2,x_3,x_4,...,x_n):x_1,x_2,x_3,x_4...,x_n\in\mathbb{Z}\right\}\cap[0,1]$. Any countable set that can be written in terms of an $n$-variable function using multiplication, division and exponentiation of variables. $\endgroup$
    – Arbuja
    Commented Jul 10, 2020 at 16:32

1 Answer 1


If interest is in a Partition of an interval most probable an equidistant subinterval sequence will be selected where the interval are direct additive. Direct additive means the sum is the interval and the interval do not overlap, have just the upper and lower in common. There is usually an exhaustion parameter n. This can be used to making the intervals smaller and the sum longer: a_i_n={a+i(b-a)/n),a+(i+1)(b-a)/n)} with i=0...n. For real intervals, each Partition can be mapped onto another.

The given functions looks nice, but it is hard to map on the interval [0,1]. For x,x integer the function covers [0,1]. The size of the intervals vary very much starting with a maximal integer 2.

ListPlot3D[Table[(x + y)/(x^2 + x y + y^2), {x, -2, 2}, {y, -2, 2}], 
 Mesh -> None, InterpolationOrder -> 0, 
 ColorFunction -> "SouthwestColors"] 

Plot3D of A_1

In the referenced question this is the cause for the long term run too.

To avoid this problem the partition generating functions is in need to be modified according to the already given schema.

n=1: A_11={A_1:0<=x,y<=1}={0/0,1/0,0/1,1/1}={0,1} restricted to [0,1] in intervals {{0,1}}. n=2: A_12={A_::0<=x,y<=2} Table[(x + y)/(x^2 + x y + y^2), {x, 0, 2}, {y, 0, 2}] {{Indeterminate, 1, 1/2}, {1, 2/3, 3/7}, {1/2, 3/7, 1/3}}

Partition[ Flatten@Append[Partition[ Flatten@Prepend[ Partition[ Sort@Flatten@ Table[(x + y)/(x^2 + x y + y^2), {x, 0, 2}, {y, 0, 2}], 2], {{0, 1/3}}], 2],{{2/3,1}}],2] {{0, 1/3}, {1/3, 3/7}, {3/7, 1/2}, {1/2, 2/3}, {2/3, 1}}

and so on.

The function A_1 is insufficient for being a good generator of a Partition of the interval [0,1]. The function generates too many duplicates and singularities.

Making the interval coverage finer with this function produces a lot of effort extra despite the fact that the mapping to make the values unique, ordered and a complete coverage of the interval can be generalized to n.

Compare the speed to the built-in Subdivide.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.