Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate the Lévy C curve
| ResourceFunction["LevyCCurve"][n] generates the line segments of the Lévy C curve with n iterations. | |
| ResourceFunction["LevyCCurve"][{p1,p2},n] uses the line connecting the points p1 and p2 as the initial line. | |
| ResourceFunction["LevyCCurve"][{p1,p2,… ,pn},n] uses the lines joining the points pi. | 


Generate the Lévy C curve for four iterations:
| In[1]:= | ![ResourceFunction["LevyCCurve"][4]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/1aaf4bb5c4510f48.png) | 
| Out[1]= |  | 
Generate the line for eight iterations and visualize the result:
| In[2]:= | ![Graphics[ResourceFunction["LevyCCurve"][8]]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/326aff41d8cd8262.png) | 
| Out[2]= |  | 
Start from a vertical line segment:
| In[3]:= | ![Graphics[ResourceFunction["LevyCCurve"][Line[{{0, 0}, {0, 1}}], 8]]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/52dadf5b5f5ef4ea.png) | 
| Out[3]= |  | 
The length of the Lévy C curve grows approximately exponentially:
| In[4]:= | ![ListLogPlot[
 Table[Length[First[ResourceFunction["LevyCCurve"][k]]], {k, 0, 9}], Joined -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/1c09427b51edb27e.png) | 
| Out[4]= |  | 
"Inward" and "outward" Lévy C curve starting from a square:
| In[5]:= | ![Graphics[{ResourceFunction["LevyCCurve"][
   Line[{{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}], 10], ResourceFunction["LevyCCurve"][
   Line[Reverse@{{3, 0}, {3, 1}, {4, 1}, {4, 0}, {3, 0}}], 10]}]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/46bbe0f99ce53de7.png) | 
| Out[5]= |  | 
Color the curve along its length:
| In[6]:= | ![pts = First@ResourceFunction["LevyCCurve"][10];
colors = Blend[{Red, Blue, Green, Orange}, #] & /@ Subdivide[Length[pts] - 1];
Graphics[Line[pts, VertexColors -> colors]]](https://www.wolframcloud.com/obj/resourcesystem/images/d9f/d9f93ab3-af9c-49dd-8767-0e5876b1f751/6e3fa99c31c8588c.png) | 
| Out[6]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License