gives the line segments representing the n
-step Sierpiński curve.
SierpinskiCurve
gives the line segments representing the n
-step Sierpiński curve.
Details and Options
- SierpinskiCurve is also known as Sierpiński space-filling curve.
- SierpinskiCurve returns a Line primitive corresponding to a closed path around {0,0}.
- SierpinskiCurve takes a DataRange option that can be used to specify the range the coordinates should be assumed to occupy.
Examples
open all close allBasic Examples (2)
Graphics[SierpinskiCurve[2]]Lengths of the approximations to the Sierpiński curve:
Table[RegionMeasure[SierpinskiCurve[n]], {n, 5}]FindSequenceFunction[%, n]Visualize the Sierpiński curve in 2D with splines:
Graphics[{Thickness[Large], SierpinskiCurve[3] /. Line -> BSplineCurve}]Scope (6)
Curve Specification (2)
Curve Styling (4)
Sierpiński curves with different thicknesses:
Table[Graphics[{Thickness[i], SierpinskiCurve[3]}], {i, {Medium, Large}}]Table[Graphics[{Thickness[i], SierpinskiCurve[2]}], {i, {.005, .05, .1}}]Thickness in printer's points:
Table[Graphics[{AbsoluteThickness[i], SierpinskiCurve[2]}], {i, {1, 5, 10}}]Table[Graphics[{Dashing[i], SierpinskiCurve[3]}], {i, {Tiny, Small, Medium, Large}}]Table[Graphics[{d, SierpinskiCurve[3]}], {d, {Dotted, Dashed, DotDashed}}]Table[Graphics[{c, SierpinskiCurve[3]}], {c, {Red, Green, Blue, Yellow}}]Options (1)
DataRange (1)
DataRange allows you to specify the range of mesh coordinates to generate:
SierpinskiCurve[1]SierpinskiCurve[1, DataRange -> {{0, 1}, {0, 1}}]Applications (4)
SierpinskiCurve is constructed recursively by transforming segments into curves linked together by lines:
cups[curve_, i_] := With[{part = Most@Partition[First[curve], UpTo[i + 1], i]},
Graphics[Apply[{{Thick, Line[#1]}, {Dotted, Line[#2]}}&, Map[Partition[#, UpTo[i], i - 1]&, part], {1}]]]Row[{cups[SierpinskiCurve[1], 4], cups[SierpinskiCurve[2], 16]}, Spacer[40]]color[curve_, i_, n_ : 1] := With[{color = ColorData[97, "ColorList"], data = First[cups[curve, i]]},
Graphics[MapIndexed[{color[[First[#2]]], #1}&, Partition[data, n]]]]Row[{color[SierpinskiCurve[2], 16], color[SierpinskiCurve[3], 64, 1]}, Spacer[40]]Visualize the Sierpiński curve in 2D:
Graphics[SierpinskiCurve[2]]% /. Line -> BSplineCurveGraphics[Polygon @@ SierpinskiCurve[4]]Apply a Sierpiński curve texture to a surface:
ParametricPlot3D[{1.16 ^ v Cos[v](1 + Cos[u]), -1.16 ^ v Sin[v](1 + Cos[u]), -2 1.16 ^ v(1 + Sin[u])}, {u, 0, 2Pi}, {v, -15, 6}, PlotStyle -> Directive[Specularity[White, 30], Texture[Graphics[SierpinskiCurve[4]]]], TextureCoordinateFunction -> ({#4, 2#5}&), Lighting -> "Neutral", Mesh -> None, PlotRange -> All, Boxed -> False, Axes -> False]Properties & Relations (3)
SierpinskiCurve consists of lines:
SierpinskiCurve[1]Find the perimeter of the 2D Sierpiński curve:
Table[Graphics[SierpinskiCurve[n]], {n, 3}]Table[RegionMeasure[SierpinskiCurve[n]], {n, 5}]FindSequenceFunction[%, n]DataRangerange is equivalent to using RescalingTransform[{…},range]:
Region[SierpinskiCurve[2, DataRange -> {{1, 2}, {1, 3}}], Frame -> True]Use RescalingTransform:
coor = First[SierpinskiCurve[2]];
{x, y} = {coor[[All, 1]], coor[[All, 2]]};box = TransformedRegion[SierpinskiCurve[2], RescalingTransform[{{Min[x], Max[x]}, {Min[y], Max[y]}}, {{1, 2}, {1, 3}}]];Region[box, Frame -> True]Possible Issues (2)
By default, the coordinates of the Sierpiński curve are not in the unit square:
SierpinskiCurve[1]Using DataRange to generate the Sierpiński curve in the unit square:
SierpinskiCurve[1, DataRange -> {{0, 1}, {0, 1}}]SierpinskiCurve can be too large to generate:
SierpinskiCurve[30]Related Guides
History
Text
Wolfram Research (2017), SierpinskiCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/SierpinskiCurve.html.
CMS
Wolfram Language. 2017. "SierpinskiCurve." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SierpinskiCurve.html.
APA
Wolfram Language. (2017). SierpinskiCurve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SierpinskiCurve.html
BibTeX
@misc{reference.wolfram_2026_sierpinskicurve, author="Wolfram Research", title="{SierpinskiCurve}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SierpinskiCurve.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sierpinskicurve, organization={Wolfram Research}, title={SierpinskiCurve}, year={2017}, url={https://reference.wolfram.com/language/ref/SierpinskiCurve.html}, note=[Accessed: 13-June-2026]}