The interval [0,1] of the real line, which we call C0, and divide it into three equal subintervals. In this way we obtain the following intervals [0,1/3],[1/3,2/3], [2/3,1] and we interval rid [1/3,2/3]. Then, obtain the set C1=[0,1/3]U[2/3,1]. Now repeat the above process on each of the intervals C1, then C2=[0,1/9]U[2/9,3/9]U[6/9,7/9]U[8/9,1] Proceeding in the same way we obtain C3,C4,C5,C6,... Thus we define the Cantor set as the intersection of all Ci constructed before. Now the goal is to obtain the graph of the Cantor set in the different steps


You can also use new-in-version-10 NumberLinePlot. The last example in NumberLinePlot >> Applications slightly modified:

NumberLinePlot[NestList[# /. {a_, b_} :>
   Sequence[{a,2 a/3 + b/3}, { a/3 + 2 b/3, b}] &,
   Interval[{0, 1}], 5], {x, 0, 1},AspectRatio->1/4, 
 PlotStyle -> Directive[CapForm["Butt"],Thick]]/. Point[x_]:>Sequence[]

enter image description here


It may be an available answer:


n = 5;
f = #/3 &; g = #/3 + 2/3 &;
Fission[list_] := Flatten@Through[{f, g}@list]
intervals = NestList[Fission, {Interval[{0, 1}]}, n];
segments[n_] := 
 intervals[[n]] /. Interval[{a_, b_}] :> Line[{{a, 0.1 n}, {b, 0.1 n}}]
Graphics[{Black, Array[segments, n + 1]}]


enter image description here


If you are in 11.1,CantorMesh will make your life easer:

NumberLinePlot[Interval @@@ (MeshPrimitives[#, 1] &@*CantorMesh /@ Range[4] /. 
    Line -> Flatten), PlotRange -> {0, 1}, AspectRatio -> 1, 
 PlotStyle -> Directive[PointSize[0], Black]]

Mathematica graphics


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.