4
$\begingroup$

I'm trying to represent the following table using the command regionplot. The rectangle (0,0), (0.5,0), (0,1),(0.5,1) should be covered, however it is not. Does anyone know what the problem is? Thank you.

tabla = Table[{1/(k + 1) <= b && 1/k > b}, {k, 2, 30, 1}]

RegionPlot[tabla, {b, 0, 1}, {a, 0, 1}]

enter image description here

$\endgroup$
5
$\begingroup$

The rectangle (0,0), (0.5,0), (0,1),(0.5,1) should be covered, however it is not.

The 29 rectangles in your original tabla cover the region 1/31 <=b < 1/2 && 0 <= a <= 1.

ClearAll[tabla]
tabla[n_] := Table[{1/(k + 1) <= b && 1/k > b}, {k, 2, n, 1}];

You can specify a large enough value for PlotPoints to see all 29 rectangles:

RegionPlot[Evaluate[tabla[30]], {b, 0, 1}, {a, 0, 1}, 
 PlotPoints -> 200]

Mathematica graphics

Or plot each rectangle separately and combine then using Show:

Show[RegionPlot[#[[1]], {b, 0, #[[1, 2, 1]]}, {a, 0, 1}] & /@ tabla[30],
    PlotRange -> {{0, 1}, {0, 1}}]

Mathematica graphics

Show[RegionPlot[#[[1]], {b, 0, #[[1, 2, 1]]}, {a, 0, 1}] & /@ tabla[90], 
    PlotRange -> {{0, 1}, {0, 1}}]

Mathematica graphics

Alternatively, combine the conditions using Or to get a single rectangle:

RegionPlot[Or @@ Join @@ tabla[30], {b, 0, 1}, {a, 0, 1}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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