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

Related simulators

Continue with similar topics in this category — or all 85 in Math Visualization.

View category →
NewUniversity / research

Convolution (pulses)

Launch Simulator

Two rectangular pulses; overlap length at τ = 0.

NewUniversity / research

Flow Field Particles

Launch Simulator

Synthetic v(x,y,t); advection with wrap; optional arrow grid.

NewUniversity / research

Newton-Raphson Basins in 2D Systems

Launch Simulator

Map Newton basins for nonlinear F(x,y)=0 systems: initial-guess sensitivity, iteration counts, root attraction, and singular-Jacobian failures.

NewSchool

Logistic Growth

Launch Simulator

dN/dt = rN(1−N/K); exact S-curve vs carrying capacity K.

NewSchool

Fractal Generator

Launch Simulator

Mandelbrot, Julia, Koch snowflake. Zoom infinitely.

NewKids

Chaos Game (Sierpiński)

Launch Simulator

Random vertex + midpoint walk; the attractor is the Sierpiński gasket — try RGB by vertex.

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.