PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Math Visualization

Other simulators in this category — or see all 85.

View category →
NewSchool

Bézier & de Casteljau

Launch Simulator

Drag control points; live recursive linear-interpolation scaffolding evaluates B(t).

NewSchool

Convex Hull (Graham & QuickHull)

Launch Simulator

Click to add points, drag to move; Graham scan with step playback or QuickHull divide-by-farthest; compare vertex sets.

NewSchool

Delaunay & Voronoi

Launch Simulator

Bowyer–Watson triangulation and dual Voronoi tessellation; click to add seeds, drag to move.

NewUniversity / research

Physarum Slime (Agents)

Launch Simulator

~4500 agents follow a deposited chemoattractant: deposit + diffusion + decay + 3-sensor steering grow path networks.

NewSchool

Savitzky–Golay Smoothing

Launch Simulator

Noisy cosine vs SG(7,2) convolution — preserves peaks better than a wide boxcar.

NewSchool

Markov Chain (Weather)

Launch Simulator

Sun/Rain two-state chain: P matrix, stationary π, empirical vs theory.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Math Visualization/L-Systems (Turtle)

L-Systems (Turtle)

Lindenmayer string rewriting + turtle: Koch, Sierpinski, Hilbert, Heighway dragon, plant.

L-system

Systems

4
1.2 px
axiom: F--F--F
F → F+F--F+F
δ = 60°

Measured values

segments drawn0
expanded length0
turning angle δ60°
depth4

About this model

Lindenmayer systems (L-systems) grow strings by parallel rewriting rules, then interpret the string with turtle graphics: move forward, turn, and push/pop state for branches. This simulator includes classic grammars — Koch curve, Sierpinski, Hilbert, Heighway dragon, and a plant-like branching axiom — so each iteration lengthens the string and refines the drawing. Angle, step length, and iteration depth control the rendered geometry. The model is deterministic context-free turtle interpretation without stochastic rules, timed growth biology, or 3D turtle headings beyond the planar presets. Raise the iteration count and switch presets to see how local string rules create global fractal and botanical shapes.

Who it's for: Discrete math, computer graphics, formal languages, and intermediate fractal / generative-art courses.

Key terms

  • L-system
  • Turtle graphics
  • String rewriting
  • Koch curve
  • Hilbert curve
  • Heighway dragon

How it works

An L-system is a parallel string-rewriting grammar invented by Aristid Lindenmayer (1968) to model plant growth. Start with an axiom and repeatedly substitute every symbol by its production. A turtle then walks the resulting string: F = step forward, +/− = turn by δ, [/] = push/pop position. With just a few rules you can reproduce Koch snowflake, the Hilbert space-filling curve, the Heighway dragon, Sierpinski triangles and remarkably plant-like trees.

Key equations

stringₙ₊₁ = apply(rules, stringₙ)
turtle: F→step, +→turn(+δ), −→turn(−δ), [/]→push/pop
|stringₙ| = O(bⁿ) where b = max |rule|

Frequently asked questions

Why does each iteration suddenly get much longer?
Rewriting replaces symbols with longer words in parallel, so string length (and drawing complexity) typically grows exponentially with iteration depth. That is why high iterations become dense quickly.
What do push and pop mean in the turtle?
Branching symbols save the turtle’s position and heading (push) and later restore them (pop), so a side branch can be drawn and the turtle can continue the main stem from the saved state.
Are these true mathematical fractals at finite iteration?
Finite iterations are polygonal approximations. The fractal limit appears only as the iteration depth tends to infinity (with step size shrinking), which the screen can only suggest.