Cantor's function

SMJepard shared this question 5 years ago
Answered

Hi,


Is it posssible to get graph of cantor's function for several iterations, like in this example? I suppose it can be made using "sequence", but I don't really how to do it.

Comments (3)

photo
1

Visit http://tube.geogebra.org and search for "Cantor." When you find an applet you like, click "Created with GeoGebra at the bottom", then click "Download" and "Download GeoGebra file". When you open the file in GeoGebra, you can "View" . . . "Construction Protocol" or "Algebra View" to see how it's done.


Here's one way to do it: In the Input bar, try these three commands:


1) n = slider[1, 10, 1]


2) f(x) = 0, (or anything, really)


2) list1 = {1, 7, 19, 25, 55, 61, 73, 79, 163, 169, 181, 187, 217, 223, 235, 241, 487, 493, 505, 511, 541, 547, 559, 565, 649, 655, 667, 673, 703, 709, 721, 727, 1459, 1465, 1477, 1483, 1513, 1519, 1531, 1537, 1621, 1627, 1639, 1645, 1675, 1681, 1693, 1699, 1945, 1951, 1963, 1969, 1999, 2005, 2017, 2023, 2107, 2113, 2125, 2131, 2161, 2167, 2179, 2185, 4375, 4381, 4393, 4399, 4429, 4435, 4447, 4453, 4537, 4543, 4555, 4561, 4591, 4597, 4609, 4615, 4861, 4867, 4879, 4885, 4915, 4921, 4933, 4939, 5023, 5029, 5041, 5047, 5077, 5083, 5095, 5101, 5833, 5839, 5851, 5857, 5887, 5893, 5905, 5911, 5995, 6001, 6013, 6019, 6049, 6055, 6067, 6073, 6319, 6325, 6337, 6343, 6373, 6379, 6391, 6397, 6481, 6487, 6499, 6505, 6535, 6541, 6553, 6559, 13123, 13129, 13141, 13147, 13177, 13183, 13195, 13201, 13285, 13291, 13303, 13309, 13339, 13345, 13357, 13363, 13609, 13615, 13627, 13633, 13663, 13669, 13681, 13687, 13771, 13777, 13789, 13795, 13825, 13831, 13843, 13849, 14581, 14587, 14599, 14605, 14635, 14641, 14653, 14659, 14743, 14749, 14761, 14767, 14797, 14803, 14815, 14821, 15067, 15073, 15085, 15091, 15121, 15127, 15139, 15145, 15229, 15235, 15247, 15253, 15283, 15289, 15301, 15307, 17497, 17503, 17515, 17521, 17551, 17557, 17569, 17575, 17659, 17665, 17677, 17683, 17713, 17719, 17731, 17737, 17983, 17989, 18001, 18007, 18037, 18043, 18055, 18061, 18145, 18151, 18163, 18169, 18199, 18205, 18217, 18223, 18955, 18961, 18973, 18979, 19009, 19015, 19027, 19033, 19117, 19123, 19135, 19141, 19171, 19177, 19189, 19195, 19441, 19447, 19459, 19465, 19495, 19501, 19513, 19519, 19603, 19609, 19621, 19627, 19657, 19663, 19675, 19681, 39367, 39373, 39385, 39391, 39421, 39427, 39439, 39445, 39529, 39535, 39547, 39553, 39583, 39589, 39601, 39607, 39853, 39859, 39871, 39877, 39907, 39913, 39925, 39931, 40015, 40021, 40033, 40039, 40069, 40075, 40087, 40093, 40825, 40831, 40843, 40849, 40879, 40885, 40897, 40903, 40987, 40993, 41005, 41011, 41041, 41047, 41059, 41065, 41311, 41317, 41329, 41335, 41365, 41371, 41383, 41389, 41473, 41479, 41491, 41497, 41527, 41533, 41545, 41551, 43741, 43747, 43759, 43765, 43795, 43801, 43813, 43819, 43903, 43909, 43921, 43927, 43957, 43963, 43975, 43981, 44227, 44233, 44245, 44251, 44281, 44287, 44299, 44305, 44389, 44395, 44407, 44413, 44443, 44449, 44461, 44467, 45199, 45205, 45217, 45223, 45253, 45259, 45271, 45277, 45361, 45367, 45379, 45385, 45415, 45421, 45433, 45439, 45685, 45691, 45703, 45709, 45739, 45745, 45757, 45763, 45847, 45853, 45865, 45871, 45901, 45907, 45919, 45925, 52489, 52495, 52507, 52513, 52543, 52549, 52561, 52567, 52651, 52657, 52669, 52675, 52705, 52711, 52723, 52729, 52975, 52981, 52993, 52999, 53029, 53035, 53047, 53053, 53137, 53143, 53155, 53161, 53191, 53197, 53209, 53215, 53947, 53953, 53965, 53971, 54001, 54007, 54019, 54025, 54109, 54115, 54127, 54133, 54163, 54169, 54181, 54187, 54433, 54439, 54451, 54457, 54487, 54493, 54505, 54511, 54595, 54601, 54613, 54619, 54649, 54655, 54667, 54673, 56863, 56869, 56881, 56887, 56917, 56923, 56935, 56941, 57025, 57031, 57043, 57049, 57079, 57085, 57097, 57103, 57349, 57355, 57367, 57373, 57403, 57409, 57421, 57427, 57511, 57517, 57529, 57535, 57565, 57571, 57583, 57589, 58321, 58327, 58339, 58345, 58375, 58381, 58393, 58399, 58483, 58489, 58501, 58507, 58537, 58543, 58555, 58561, 58807, 58813, 58825, 58831, 58861, 58867, 58879, 58885, 58969, 58975, 58987, 58993, 59023, 59029, 59041, 59047}


3) For the slider 'n', under "Object Properties", "Scripting", "On Update", paste this:

    execute[{Sum[join[{"SetValue[f,"}, join[Sequence[Sequence["If[" + Element[list1, t]/3^w + "<x<" + (Element[list1, t]+1)/3^w + ", " + (2*t-1)/2^w +", ", t, 1, 2^(w-1)], w, 1, n]], {"0]"}, Sequence["]", t, 1, 2^n-1]]]}]


Edit: Now f is a function and list1 is half its original size.

photo
1

Hi, another way with the recursive spirit but only a polyline and not a function.

A way to have the list of the points recursively : (checked with n<=13 on my old computer)

    Execute[Sequence["SetValue[list1,RemoveUndefined[Join[Sequence[If[y(Element[list1, k]) ≠ y(Element[list1, k + 1]), {Element[list1, k], (x((2 (Element[list1, k]) + Element[list1, k + 1]) / 3), y((Element[list1, k + 1] + Element[list1, k]) / 2)), (x((Element[list1, k] + 2 (Element[list1, k + 1])) / 3), y((Element[list1, k + 1] + Element[list1, k]) / 2)),Element[list1, k + 1]}], k, 1, Length[list1]-1]]]]",k,1,n]]

https://ggbm.at/569009

photo
1

Tried as a real function (with n<=9 at home)

https://ggbm.at/569013

© 2019 International GeoGebra Institute