## Figures

## Abstract

The *Drosophila* larva executes a stereotypical exploratory routine that appears to consist of stochastic alternation between straight peristaltic crawling and reorientation events through lateral bending. We present a model of larval mechanics for axial and transverse motion over a planar substrate, and use it to develop a simple, reflexive neuromuscular model from physical principles. The mechanical model represents the midline of the larva as a set of point masses which interact with each other via damped translational and torsional springs, and with the environment via sliding friction forces. The neuromuscular model consists of: 1. segmentally localised reflexes that amplify axial compression in order to counteract frictive energy losses, and 2. long-range mutual inhibition between reflexes in distant segments, enabling overall motion of the model larva relative to its substrate. In the absence of damping and driving, the mechanical model produces axial travelling waves, lateral oscillations, and unpredictable, chaotic deformations. The neuromuscular model counteracts friction to recover these motion patterns, giving rise to forward and backward peristalsis in addition to turning. Our model produces spontaneous exploration, even though the nervous system has no intrinsic pattern generating or decision making ability, and neither senses nor drives bending motions. Ultimately, our model suggests a novel view of larval exploration as a deterministic superdiffusion process which is mechanistically grounded in the chaotic mechanics of the body. We discuss how this may provide new interpretations for existing observations at the level of tissue-scale activity patterns and neural circuitry, and provide some experimental predictions that would test the extent to which the mechanisms we present translate to the real larva.

## Author summary

We investigate the relationship between brain, body and environment in the exploratory behaviour of fruitfly larva. A larva crawls forward by propagating a wave of compression through its segmented body, and changes its crawling direction by bending to one side or the other. We show first that a purely mechanical model of the larva’s body can produce travelling compression waves, sideways bending, and unpredictable, chaotic motions. For this body to locomote through its environment, it is necessary to add a neuromuscular system to counteract the loss of energy due to friction, and to limit the simultaneous compression of segments. These simple additions allow our model larva to generate life-like forward and backward crawling as well as spontaneous turns, which occur without any direct sensing or control of reorientation. The unpredictability inherent in the larva’s physics causes the model to explore its environment, despite the lack of any neural mechanism for rhythm generation or for deciding when to switch from crawling to turning. Our model thus demonstrates how understanding body mechanics can generate and simplify neurobiological hypotheses as to how behaviour arises.

**Citation: **Loveless J, Lagogiannis K, Webb B (2019) Modelling the mechanics of exploration in larval *Drosophila*. PLoS Comput Biol 15(7):
e1006635.
https://doi.org/10.1371/journal.pcbi.1006635

**Editor: **Joseph Ayers,
Northeastern University, UNITED STATES

**Received: **September 19, 2017; **Accepted: **November 8, 2018; **Published: ** July 5, 2019

**Copyright: ** © 2019 Loveless et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.

**Data Availability: **All data and software files are available from a github repository, https://github.com/janeloveless/mechanics-of-exploration (DOI: 10.5281/zenodo.1432637).

**Funding: **This work was supported by the EU Seventh Framework Programme (FP7, https://ec.europa.eu/research/fp7/) grant MINIMAL (reference number FP7-618045). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

Exploratory search is a fundamental biological behaviour, observed in most phyla. It has consequently become a focus of investigation in a number of model species, such as larval *Drosophila*, in which neurogenetic methods can provide novel insights into the underlying mechanisms. However, appropriate consideration of biomechanics is needed to understand the control problem that the animal’s nervous system needs to solve.

When placed on a planar substrate (typically, an agar-coated petri dish), the *Drosophila* larva executes a stereotypical exploratory routine [1] which appears to consist of a series of straight runs punctuated by reorientation events [2]. Straight runs are produced by laterally symmetric peristaltic compression waves, which propagate along the larval body in the same direction as overall motion (i.e. posterior-anterior waves carry the larva forwards relative to the substrate, anterior-posterior waves carry the larva backwards) [3]. Reorientation is brought about by laterally asymmetric compression and expansion of the most anterior body segments of the larva, which causes the body axis of the larva to bend [2].

Peristaltic crawling and reorientation are commonly thought to constitute discrete behavioural states, driven by distinct motor programs [2]. In exploration, it is assumed, alternation between these states occurs stochastically, allowing the larva to search its environment through an unbiased random walk [1, 4–6]. The state transitions or direction and magnitude of turns can be biased by sensory input to produce taxis behaviours [4, 5, 7–13]. The neural circuits involved in producing the larval exploratory routine potentially lie within the ventral nerve cord (VNC), since silencing the synaptic communication within the brain and subesophageal ganglia (SOG) does not prevent substrate exploration [1]. Electrophysiological and optogenetic observations of fictive locomotion patterns within the isolated VNC [14, 15] support the prevailing hypothesis that the exploratory routine is primarily a result of a centrally generated motor pattern. As such, much recent work has focused on identifying and characterising the cells and circuits within the larval VNC [16–32]. However, behaviour rarely arises entirely from central mechanisms; sensory feedback and biomechanics often play a key role [33–35] including the potential introduction of stochasticity. Indeed, thermogenetic silencing of somatosensory feedback in the larva leads to severely retarded peristalsis [36] or complete paralysis [37, 38].

In line with the ethological distinctions drawn between runs and turns, computational modelling of the mechanisms underlying larval behaviour has so far focused on either peristaltic crawling or turning. An initial model based on neural populations described a possible circuit architecture and dynamics underlying the fictive peristaltic waves observed in the isolated ventral nerve cord [39]. A subsequent model described the production of peristaltic waves through interaction of sensory feedback with biomechanics, in the absence of any centrally generated motor output [40], in a manner similar to earlier models of wave propagation via purely sensory mechanisms in *C. elegans* [41, 42]. This model produced only forward locomotion as it incorporated strongly asymmetric substrate interaction. Recently, a model combining biomechanics, sensory feedback, and central pattern generation reproduced many features of real larval peristalsis [43]. However, this model only aimed to explain forward locomotion, and accordingly contained explicit symmetry-breaking elements in the form of posterior-anterior excitatory couplings between adjacent segments of the VNC, and posterior-anterior projections from proprioceptive sensory neurons in one segment into the next segment of the VNC. No biomechanical models of turning in the larva have yet been published, but the sensory control of reorientation behaviour has been explored in more abstract models [4, 5, 8, 11–13, 44]. No current model accounts for both peristalsis and reorientation behaviours, and no current model of peristalsis can account for both forward and backward locomotion without appealing to additional neural mechanisms.

Here we present a model of unbiased substrate exploration in the *Drosophila* larva that captures forward and backward peristalsis as well as reorientation behaviours. We provide a deterministic mathematical description of body mechanics coupled to a simple, reflexive nervous system. In contrast to previous models, our nervous system has no intrinsic pattern-generating ability [39, 43, 44], and does not explicitly encode discrete behavioural states or include any stochasticity [4, 5, 8, 11–13]. Nevertheless, the model is capable of producing apparently random “sequences” of crawling and reorientation behaviours, and is able to effectively explore in a two-dimensional space. We argue that the core of this behaviour lies in the chaotic mechanical dynamics of the body, which result from an energetic coupling of axial (“peristaltic”) and transverse (“turning”) motions.

Our choice not to explicitly model navigational decision-making and central pattern generation circuits is motivated by our desire to illustrate the powerful insights offered by focusing upon the mechanics of the body with which the nervous system interacts. The model neuromuscular system we have constructed is based upon simple physical arguments, yet ultimately bears a striking resemblance to known features of the larval nervous system. By starting from the mechanics of the body, and not assuming the existence of particular neural circuits, we are able to provide a new explanatory framework within which to re-interpret existing neurophysiological observations, including observations of central pattern generation within the larval VNC, and also provide unique predictions for future neurophysiological experiments.

In what follows, we first outline the key components and assumptions of our model of body mechanics. We then follow simple arguments to guide the construction of a neuromuscular model capable of producing power flow into the body, and motion of the body’s centre of mass relative to the substrate. Crucially, the neuromuscular model neither senses nor drives transverse motions. In analysing the behaviour of our model, we begin by focusing on the small-amplitude, energy-conservative behaviour of the body in the absence of frictive and driving forces. In this case, the motion of the body is quasiperiodic and decomposes into a set of energetically isolated axial travelling waves and transverse standing waves. Reintroducing friction and driving forces, we demonstrate the emergence of a pair of limit cycles corresponding to forward and backward peristaltic locomotion, with no differentiation of the neural activity for the two states. We then shift focus to the behaviour of the model at large amplitudes. In this case the axial and transverse motions of the body are energetically coupled, and the conservative motion becomes chaotic. The energetic coupling allows our neuromuscular model to indirectly drive transverse motion, producing chaotic body deformations capable of driving substrate exploration. Analysis of our model supports a view of larval exploration as an (anomalous) diffusion process grounded in the deterministic chaotic mechanics of the body.

## Models

### Mechanics

To explore larval crawling and turning behaviours, we choose to describe the motion of the larval body axis (midline) in a plane parallel to the substrate (Fig 1, S1 Fig). The larval body is capable of more diverse motions including lifting/rearing [21], rolling [45], digging [46], self-righting / balancing, and denticle folding which we have recently observed to occur during peristalsis (S1 Video). However, while exploring flat surfaces, the larva displays fairly little out-of-plane motion (neither translation perpendicular to the substrate nor torsion around the body axis) and only small radial deformations [47]. Furthermore, the majority of ethological characterisations of larval exploration treat the animal as if it were executing purely planar motion [4, 6, 8–13, 48]. A planar model is thus a reasonable abstraction for the issues addressed in this paper, i.e., the generation of peristalsis, bending, and substrate exploration.

The midline of the larva is modelled as a set of discrete point masses interacting with each other via linear, damped translational and torsional springs, and with the environment via Coulomb sliding friction. We model the larva’s incompressible coelomic fluid by constraining the total length of the midline to remain constant (see main text). Quantities used to describe deformations of the body, and interaction with the substrate, are shown in S1 Fig.

The segmented anatomy of the *Drosophila* larva allows us to focus our description of the midline to a set of *N* = 12 points in the cuticle, located at the boundaries between body segments and at the head and tail extremities. We assign each point an identical mass, and measure its position and velocity relative to a two dimensional cartesian coordinate frame fixed in the substrate (the laboratory or lab frame). We therefore have *N*_{DOF} = 2*N* = 24 mechanical degrees of freedom. We note that our assumption of a uniform mass distribution along the midline is somewhat inaccurate, since thoracic segments are smaller than abdominal segments. However, simulations with non-uniform mass distribution give results which are qualitatively close to those presented here.

We assume that the larval body stores elastic energy in both axial compression/expansion and transverse bending, due to the presence of elastic proteins in the soft cuticle. We assume that energy is lost during motion due to viscous friction within the larva’s tissues and sliding friction between the body and the substrate. Sliding friction also allows shape changes (deformations) of the body to cause motion of the larva as a whole relative to the substrate (centre of mass motion).

Since the mechanical response of the larva’s tissues is yet to be experimentally determined, we assume a linear viscoelastic model. This is equivalent to placing linear (Hookean) translational and torsional springs in parallel with linear (Newtonian) dampers between the masses in the model, as shown in Fig 1, or to taking quadratic approximations to the elastic potential energy and viscous power loss (as in S1 Appendix). We note that the accuracy of the approximation may decrease for large deformations, in which nonlinear viscoelastic effects may become important.

As with larval tissue mechanics, there has been little experimental investigation of the forces acting between the larva and its environment. We therefore assume a simple anisotropic Coulomb sliding friction model, in which the magnitude of friction is independent of the speed of motion, but may in principle depend upon the direction of travel. This anisotropy could be thought of as representing the biased alignment of the larva’s denticle bands, or directional differences in vertical lifting or denticle folding motions which are not captured by our planar model. A mathematical formulation of our sliding friction model is given in S1 Appendix.

In addition to power losses due to friction, we also allow power flow due to muscle activation. For the sake of simplicity, we choose to allow only laterally symmetric muscle tensions. In this case, the musculature cannot directly cause bending of the midline, and can only explicitly drive axial motions. We will see later that even indirect driving of bending motion can lead to surprisingly complex behaviour, due to energetic coupling of axial and transverse degrees of freedom.

The choice to neglect asymmetric muscle tensions is made in order to simplify our model and provide a clearer illustration of the potential role of body mechanics in generating complex larval behaviour. We note that there is only one way for muscle activations to be symmetric—if we were to allow asymmetry we would have to specify exactly what form that asymmetry should take, and we have little empirical or theoretical grounds on which to do so. Nevertheless, there are some interesting cases which may be considered in passing—the presence of a constant torque about the model’s segment boundaries should cause a shift in the equilibrium posture towards a resting curved shape. The presence of torques which are a linear function of the local body bending angle or local angular velocity should shift the effective transverse stiffness or viscosity of the body S5 Appendix. In this sense the model presented here could be considered to already include the effect of asymmetric muscle tensions, they have simply been incorporated into the passive stiffness and viscosity of the body. We have recently developed an extension of the model presented here which uses a similar local reflex to modulate the body’s effective transverse viscosity in proportion to a stimulus input, allowing the model to exhibit taxis behaviour [49].

Finally, we model the internal coelomic fluid of the larva. Given the extremely small speed of the fluid motion compared to any reasonable approximation to the speed of sound in larval coelomic fluid, we can safely approximate the fluid flow as incompressible [50]. This would ordinarily require that the volume contained within the larval cuticle remain constant. However, since we are modelling only the motion of the midline and neglecting radial deformations, we constrain the total length of the larva to remain constant. We note that this constraint is not entirely accurate to the larva, as the total length of the animal has been observed to vary during locomotion [47]. Nevertheless, for the sake of simplicity we will continue with this constraint in place, noting that this approximation has been used with success in previous work focused on peristalsis [40, 43], and that there is experimental support for kinematic coupling via the internal fluid of the larva [3]. We note that we satisfy the incompressibility condition only approximately in some sections (*Model behaviour—Conservative chaos, Dissipative chaotic deformations*, and *Deterministic exploration*), by introducing an additional potential energy associated with the constraint, which produces an energetic barrier preventing large changes in the total length of the body (see S1 Appendix for details of this approximation along with specifics of the mathematical formulation of our mechanical model).

Note that in the absence of transverse bending, the total length constraint causes the head and tail extremities of the larva to become mechanically coupled and move in unison [40, 43]. The axial mechanics thus has periodic boundary conditions, and the most anterior (T1) and posterior (A8) segments of the larva may be considered adjacent. This means, for instance, that a compression wave travelling from tail to head will cause motion of the tail on termination at the head, thus initiating a new compression wave. This view also allows us to reason about what should happen if we relax the total length constraint. In particular, if we were to replace the direct coupling of head and tail by a viscoelastic coupling, representing the capacity for storage and dissipation of energy within the internal fluid or in radial expansion of the cuticle, the axial mechanics would still have periodic boundary conditions but would now have a step change in mechanical impedance. Waves hitting such “sudden” impedance boundaries in their transmission media will generally be partially transmitted (i.e. passing directly from head to tail in the larva) and partially reflected (i.e. changing direction and moving backwards from the head extremity), providing one possible cause of transitions between forward and backward locomotion in the animal. As will be seen, however, these transitions may occur even in the absence of an impedance discontinuity, and we will continue with the total length constraint in place in order to simplify our model.

### Neuromuscular system

Let us now consider how we should use muscle activity to produce locomotion. There are two basic requirements. First, we must have power flow into the body from the musculature, so that the effects of friction may be overcome and the larva will not tend towards its equilibrium configuration. Second, we must be able to produce a net force on the centre of mass of the larva, so that it can accelerate as a whole relative to the lab frame. Note that in this section, we motivate the neural circuits in the model from this purely functional point of view, but will present relevant biological evidence in the discussion.

To satisfy the first criterion, let us examine the flow of power into the body due to the action of the musculature (1)

Here, *q*_{i} describes the change in length of the *i*’th body segment away from its equilibrium length, is the rate of expansion of the *i*’th body segment, *b*_{i} is a (positive) gain parameter, MF_{i} is a (positive) dimensionless control variable representing muscle activation, and the product *b*_{i}MF_{i} is the total axial tension across the *i*’th body segment. From this expression, it is clear that if we produce muscle tensions (MF_{i} > 0) only while segments are shortening (), we will always have positive power flow into the body (*P* > 0). This is a mathematical statement of the requirement for the larva’s muscles to function as *motors* during locomotion, rather than as springs, brakes, or struts [33].

A simple way to fulfil this condition is to introduce a segmentally localised reflex circuit (Fig 2, [40]). We place a single sensory neuron in each segment which activates when that segment is compressing (). Each sensory neuron then projects an excitatory connection onto a local motor neuron, which in turn projects to a muscle fibre within the same segment. Assuming for now that there are no other influences on the motor neurons, so that sensory activation implies local motor neuron activation, segmental shortening will produce an immediate muscle tension serving to amplify compression of the segment and thus counteract frictive energy losses.

A local reflex amplifies motion via positive feedback: sensory neurons SN activate during segmental shortening, exciting motor neurons MN, and causing muscle fibre activation MF which accelerates shortening. Reflexes in distant segments *i* and *i* + *j* (|*j*| > 1) mutually inhibit one another via interneurons IN. This limits the number of moving segments to allow centre of mass motion (see text).

Let us now consider the second criterion for peristaltic locomotion. Assuming all segment boundaries are of equal mass, the force on the centre of mass of the larva is proportional to the sum of the forces acting on each segment boundary, i.e. (2)

Newton’s third law tells us that any forces of interaction between segment boundaries (i.e. viscoelastic and muscle forces) must be of equal magnitude and opposite direction, so that they cancel in this summation and we are left only with contributions arising from substrate interaction. If the motion of the body is such that some number *n*_{f} of segments move forward at a given time, against a frictional force −*μ*_{f}, while *n*_{b} segments remain anchored or move backward, experiencing a frictional force *μ*_{b}, then the summation becomes
(3)

In the limiting case of isotropic (direction-independent) substrate interaction we have *μ*_{b} = *μ*_{f}, and this expression tells us that the centre of mass will accelerate in the forward direction only when there are less segments moving forward than are moving backward or anchored to the substrate. Similarly, moving a small number of segments backward while the others remain anchored will result in backward acceleration of the centre of mass. Therefore, if the animal is to move relative to its substrate, it must ensure that only a limited number of its segments move in the overall direction of travel at a given time (indeed, this matches observations of the real larva [3, 22]). A more lengthy exposition of this requirement on limbless crawling behaviours can be found in [51].

We fulfil the requirement for a small number of moving segments by introducing mutually inhibitory interactions between the segmentally localised reflex circuits (Fig 2). We add a single inhibitory interneuron within each segment. When the sensory neuron within the local reflex activates, it excites this interneuron, which then strongly inhibits the motor neurons and inhibitory interneurons in non-adjacent segments, effectively turning off the local reflexes in distant neighbours. Adjacent segments do not inhibit each other in our model, allowing reflex activity to track mechanical disturbances as they propagate from one segment to the next. We comment on the plausibility of this feature of our model, given the experimental observation of nearest-neighbour inhibitory connections in the larval ventral nerve cord [28], in the discussion. Similarly, the head and tail segments do not inhibit each other, which permits peristaltic waves to be (mechanically) reinitiated at one extremity as they terminate at the other (see Discussion at the end of the previous subsection). This effectively introduces a ring-like topology into the neural model, matching our model of axial mechanics which couples head and tail motion through the total length constraint [40].

We now have a neuromuscular model consisting of four cell types repeated in each segment—sensory neurons, inhibitory interneurons, motor neurons, and muscle fibres. For the sake of simplicity we model all neurons as having a binary activation state governed by the algebraic relation
(4)
where *V*_{i} is the activation of the *i*’th cell, *θ*_{i} is its activation threshold, *V*_{j} is the activation of the *j*’th presynaptic cell, and *w*_{j} is the associated synaptic weight. Numerical values for the weights and thresholds used in our model are given in S1 Table, supplemental. Note that the muscle tension over a segment either vanishes (when the muscle fibre is in the inactive state) or has fixed magnitude *b*_{i} (when the muscle fibre is activated by local sensory feedback). For this reason we refer to *b*_{i} as the *reflex gain*.

Our choice to neglect neural dynamics is based on the large difference in timescales between the neural and mechanical dynamics. Typical motor neuron spiking occurs with a timescale on the order of 10^{−3} seconds. Spiking is observed to be significantly “averaged out” by the graded (non-spiking) muscle fibre responses, and respond on the order of ∼10^{−1} seconds to prolonged motor neuron spiking [52, 53]. During locomotion, segmental compressions are driven by several longitudinal muscle fibres activating simultaneously [3, 14, 29] in response to largely independent motor neuron populations [54, 55] which are unlikely to spike with identical timing. This spatial integration should further “mask” the effects of neural dynamics. Note that the lack of neural dynamics in our model immediately rules out central pattern generation. However, this does not prevent our model from producing complex, larva-like behaviour, and we consider how our model could account for observations of central pattern generation in the discussion.

To summarise, the neural model we have constructed can be seen as consisting of two parts, a segmentally repeating local reflex and a mutual inhibition circuit acting between non-adjacent reflexes. The local reflex is constructed so that muscles will act as motors, amplifying segmental compressions and counteracting friction. The mutual inhibition circuit couples distant reflexes to allow only localised amplification. By limiting the number of moving segments, this should ensure that the model larva can produce a net force on its centre of mass.

## Results

### Larva-like axial compression waves and lateral oscillations result from conservative mechanics

One of the advantages of grounding our model of larval exploration in the body’s physics is that we are now able to apply powerful analytical results from classical mechanics in order to understand the model’s behaviour. In this section we attempt to elucidate the naturally preferred motions of the larva by focusing our attention on the conservative mechanics of the body while neglecting friction forces, which would cause all motion to stop, and driving forces, which might impose a particular pattern of motion.

In this case, the general character of motion is specified by the Liouville-Arnold integrability theorem. This theorem asks us to look for a set of conserved quantities associated with a mechanical system, which remain unchanged as the system moves (energy, momentum, and angular momentum are examples of some commonly conserved quantities). If we can find a number of these quantities equal to the number of mechanical degrees of freedom in our model, then the theorem tells us that the motion of the body is *integrable*—it can be expressed analytically, and must be either periodic or quasiperiodic. If there are not enough conserved quantities, then the system is said to be *nonintegrable*. In this case the motion is much more complicated and will be chaotic for some initial conditions. These chaotic motions do not permit analytical expression and must be approximated through simulation.

In this section, we explicitly seek a case for which there is a “full set” of conserved quantities (we provide only major results here, for detailed derivations see S2 Appendix). We begin by restricting ourselves to considering only small deformations of the larval midline, in the case where all segments are of identical axial stiffness *k*_{a}, transverse stiffness *k*_{t}, mass *m*, and length *l*. Under these assumptions, the total mechanical energy of the body may be written
(5)
where **x** and **y** are vectors giving the displacement of each segment boundary along the body axis and perpendicular to the body axis, respectively, **p**_{x} and **p**_{y} give the translational momentum associated with each direction, **D**_{2} and **D**_{4} are difference matrices arising from a Taylor series expansion of our model’s potential energy (see S2 Appendix), and and are characteristic axial and transverse frequency scales. By making a linear change of coordinates {**x**, **y**, **p**_{x}, **p**_{y}} → {**X**, **Y**, **p**_{X}, **p**_{Y}} to the eigenbasis of **D**_{2} and **D**_{4} (see S2 Appendix) this simplifies to
(6)
where λ_{a,i} and λ_{t,i} are eigenvalues associated with the coordinate transformation. This expression is a sum of component energies, each of which is independently conserved. The Liouville-Arnold theorem immediately tells us that the motion of the body must be (quasi)periodic in the case of conservative small deformations. Indeed, the energy associated with each of the new coordinates *X*_{i}, *Y*_{i} is in the form of a harmonic oscillator, and each coordinate executes pure sinusoidal oscillations. By transforming back to the original coordinates **x**, **y** we obtain a set of collective motions (modes) of the body which are energetically isolated and have a sinusoidal time dependence, corresponding to axial and transverse standing waves. We will refer to the *X*_{i}, *Y*_{i} as modal coordinates since they describe the time dependence of each of the collective motions.

Each transverse standing wave corresponds to a periodic lateral oscillation of the body, with a unique frequency given by . We determined these frequencies numerically, along with the spatial components of the lowest frequency standing waves (Fig 3A). These can be seen to match the eigenmaggot shapes extracted from observations of unbiased larval behaviour [56].

A: spatial component of first four transverse standing waves (top, black) compared to first four experimentally determined eigenmaggots [56] (top, blue), with natural frequencies of oscillation (bottom). B: spatial component of first four axial standing waves (top), with natural frequencies of oscillation (bottom). Note that axial standing waves come in pairs with identical frequency. C: Pairs of axial standing waves can be combined to produce forward-propagating (top, solid black line) and backward-propagating (bottom, solid black line) travelling waves. Head and tail extremities move in phase (dashed black line) due to our total length constraint (see text), reminiscent of the “visceral pistoning” observed in the real animal [3].

The axial standing waves correspond to oscillating patterns of segmental compression and expansion. While each transverse standing wave had its own unique frequency of oscillation, the axial standing waves come in pairs with identical frequency but different spatial components—each member of the pair corresponds to a different spatial pattern of segmental compression/expansion spread across the body, but these patterns oscillate in time with the same frequency. We were able to analytically determine the frequency of oscillation of the *i*’th pair of axial standing waves to be
(7)

The spatial components of the axial standing waves could also be determined analytically (8)

Where *x*_{k,i} is the displacement of the *k*’th segment boundary for the *i*’th pair of standing waves. We plot the axial frequencies *ω*_{a,i} and spatial components *x*_{k,i} in Fig 3B.

The fact that the axial oscillation frequencies come in identical pairs allows us to combine the axial standing waves with a ±90° relative phase shift to form pairs of forward and backward travelling wave solutions (see S2 Appendix for the full derivation)
(9)
where *x*_{k,i}(*t*) gives the displacement of the *k*’th segment boundary as a function of time for the *i*’th pair of travelling waves. The choice of a plus or minus sign corresponds to the choice between forward or backward wave propagation. These solutions correspond to propagating waves of segmental compression and expansion similar to those seen during larval peristalsis. We plot the lowest frequency pair of axial travelling wave solutions in Fig 3C, and directly visualise the synthesis of travelling wave solutions from standing wave solutions in S2 Video.

To summarise, in this section we have shown that for the case of conservative, small oscillations, the motion of the body may be decomposed into a combination of transverse standing waves and axial travelling waves. This is of clear relevance to understanding the behaviour of the larva, which moves across its substrate by means of axial peristaltic waves while reorienting using lateral oscillations. Indeed, the transverse modes of oscillation that we have derived here match principal components of bending computed from actual larval behaviour [56]. Our results can be interpreted as providing a physical basis for these observations—the principal components extracted from real larval data correspond to a “natural” coordinate basis that is grounded in the animal’s mechanics. Furthermore, the proportion of postural variance explained by each principal component of the experimental data decreases with increasing modal frequency in our model (and thus increasing energy). We can therefore help to explain the observed ordering of principal components, as this corresponds to the larva “preferring” to occupy low-frequency, low-energy modes during most of its behaviour. We comment further on this observation in S3 Appendix in the context of axial modes. We will now focus on the small-amplitude motion of the body in the presence of energy dissipation due to friction and driving forces.

### Forward and backward peristaltic locomotion can be obtained from simple reflexes

Reintroducing friction will clearly lead the motions described above to eventually terminate due to energy dissipation, unless opposed by transfer of power. In a previous section (*Models—Neuromuscular system*, see also S1 Appendix), we introduced a neuromuscular system to produce power flow into the body, but as described, it can only directly transfer power into the axial degrees of freedom. In the small deformation model we have just analysed, the axial and transverse degrees of freedom are energetically decoupled. It follows that transverse friction is unopposed and any transverse motion must eventually terminate in the case of small deformations. In this section we will therefore focus only on the axial degrees of freedom, which correspond to the peristaltic locomotion of the larva.

In Fig 4, we show the effect of coupling our neuromuscular model to the axial mechanics. For small reflex gains, the power flow into the body from the musculature is too low to effectively counteract frictive losses and the larva tends towards its passive equilibrium state, in which there is complete absence of motion. However, increasing reflex gain past a certain critical value leads to the emergence of long-term behaviours in which the larva remains in motion, away from its passive equilibrium. These motions correspond to forward and backward locomotion, driven by forward and backward propagating compression waves (see below), as predicted from our earlier description of the conservative motions of the body, and as observed in the real larva [3]. The qualitative changes in behaviour that occur as reflex gain is varied are depicted in Fig 4A, where we have measured the long-term centre of mass momentum of the larva, along with the long-term relative phase of the lowest frequency modal coordinates.

A: as reflex gain is increased past a critical point, the model larva attains a positive or negative long-term average centre of mass momentum (top, red and blue lines), signifying continuous forward or backward motion relative to the substrate, and a ±*π*/2 relative phase difference between the two lowest frequency axial standing wave modes (bottom, red and blue lines), signifying the presence of forward- or backward-propagating axial travelling waves. B: trajectories of individual point masses in the model for forward (top) or backward (bottom) locomotion (see S2 Fig for corresponding neural state). C: projection of model trajectories onto the lowest frequency axial modes and the centre of mass momentum reveals a pair of (putative) stable limit cycles for forward (blue) and backward (red) locomotion. Parameters used to generate this figure are given in S2 Table.

The exact value of reflex gain required for onset of locomotion depends on the particular mechanical parameters used in our model (see S2 Table for parameters used in Fig 4). In principle, this bifurcation point of the dynamics should be amenable to analytical investigation by studying the stability of the linearised model dynamics around the passive equilibrium state [57, 58]. In practise, however, the presence of hard nonlinearities in the sliding friction model makes such an approximation inaccurate.

For low reflex gains the centre of mass momentum tends to 0 as the body comes to a stop and enters a passive equilibrium state. The relative phase of the low frequency modal coordinates tends to either 0 or 180 degrees, which also corresponds to a loss of momentum. For larger values of reflex gain, the total momentum is either positive, zero, or negative. Positive and negative total momentum represent forward and backward locomotion, respectively, while zero momentum corresponds to two unstable cases which we discuss below. The relative phase of the lowest frequency modal coordinates tends to ±90° at high reflex gains, corresponding to the presence of forward- or backward-propagating compression waves (see previous section). As in the larva [1, 3], forward-propagating waves drive forward locomotion while backward-propagating waves drive backward locomotion (Fig 4B).

We believe that these behaviours arise from the production of a pair of limit cycle attractors in the system’s phase space, which we visualise in Fig 4C by projecting the system state onto the lowest frequency pair of axial modes, and plotting the associated modal coordinates along with the centre of mass momentum. Since wave motion implies that pairs of modal coordinates should perform pure sinusoidal oscillations with equal amplitude and frequency, and a ±90° relative phase shift (see previous section and S2 Appendix), the travelling wave trajectories of the system become circles in this coordinate system (see discussion of Lissajous figures, [59]). Forward and backward locomotion can then be distinguished by the momentum of the centre of mass.

In this model, the speed of forward and backward locomotion are equal for a fixed value of reflex gain, while in the real larva the speeds are known to differ [15]. We comment on some possible explanations for this difference in the discussion.

In S2 Fig we show the neural state of the model larva during forwards and backwards locomotion. As expected given our previous exposition, we observe waves of activity in the nervous system which track the mechanical waves propagating through the body. Our sensory neurons also show a second, brief period of activation following propagation of the mechanical wave caused by a slight compression that occurs as segments return to equilibrium. This activity is “cancelled out” by the mutual inhibition circuit, so that motor neurons do not exhibit a secondary burst of activity.

The larva has zero long-term total momentum in the presence of large reflex gain in only two cases, both of which are highly unstable. First, if we start the larva so that it is already in its passive equilibrium state, so that no relative motion of segment boundaries occurs, it is obvious that there will be no activation of local reflexes and the larva will not spontaneously move out of equilibrium. The second case corresponds to a pure axial standing wave. In this case the larva is divided into two regions by nodal points where the axial displacement is zero. During the first half-cycle of the standing wave, one region will experience compression while the other experiences expansion, and in the second half-cycle these roles will reverse. The neural circuit we have constructed can amplify compression during both half-cycles since they are separated by a configuration in which no compression or expansion occurs, and this allows the entire nervous system to become inactive and “reset”. Since these behaviours are extremely unstable and require very specific initial conditions to be observed, we have not visualised them here.

While the mutually inhibitory connections in our model are not required for the propagation of locomotor waves, which can be maintained entirely by local reflexes [40], these connections do greatly enhance stability. In the absence of the mutual inhibition circuit, small mechanical disturbances in any stationary body segments can be amplified, giving rise to multiple compression waves which travel through the body simultaneously. If this instability produces an equal number of forward and backward moving segments then overall motion of the larva relative to the substrate will stop, in line with the argument presented earlier. We have also observed that roughly symmetrical substrate interaction is required to produce both forward and backward locomotion in our model. If friction is too strongly anisotropic, then locomotion can only occur in one direction regardless of the direction of wave propagation.

It is worth noting that the axial model presented in this section does display discrete behavioural states. However, there are no explicit decisions regarding which behavioural states to enter, since the particular neural states occupied during forwards and backwards locomotion are indistinguishable. Rather, both the apparent decision and the eventual direction of travel can only be understood by examining the dynamics and mechanical state of the body.

### Conservative chaos from mechanical coupling

Having successfully produced peristaltic locomotion using our model, we will now turn our attention to the larva’s turning behaviours. As before, we will start from physical principles. In a previous section (*Results—Conservative axial compression waves and transverse oscillations*) we showed that, for the case of conservative small oscillations, transverse motions of the body were energetically decoupled from axial motions, and could be decomposed into a set of periodic standing waves. We will first extend our previous analysis to the case of energy-conservative, large amplitude motions in the absence of damping and driving; and then in the following section consider the impact of energy dissipation and the neuromuscular system on transverse motion.

To keep our presentation simple and allow visualisation of model trajectories, we will focus on a reduced number of the mechanical degrees of freedom. Namely, we will examine the bending angle *ϕ* and axial stretch *q* of the head segment (Fig 5A). We introduce an amplitude parameter *ϵ* by making the substitutions *q* → *ϵq* and *ϕ* → *ϵϕ*, so that the total mechanical energy of the head may be written in nondimensional form as (see S4 Appendix)
(10)
where *p*_{q}, *p*_{ϕ} are the radial and angular momentum of the head mass, and we have scaled the time axis of the model so that the natural frequency of axial oscillation is unity. The parameter λ = *ω*_{t}/*ω*_{a} = *k*_{t}/*k*_{a}*l*^{2} is the ratio of transverse and axial frequencies.

A: we focus on the conservative dynamics of the head’s strain *q* and bend *ϕ* coordinates as amplitude *ϵ* is varied. B: head trajectories are visualised by Poincare section, in which the head’s configuration *q*, *ϕ* is plotted at successive turning points of the transverse bending motion (at which angular velocity vanishes, d*ϕ*/dt = 0).

In the case of small oscillations, i.e. *ϵ* → 0, the mechanical energy reduces to the simpler expression
(11)
which is clearly a sum of independent axial and transverse energies. These energies are individually conserved, so that the Liouville-Arnold theorem applies, and the motion of the head is integrable and (quasi)periodic. This is in clear agreement with our earlier results. For the more general case of large amplitude motion (*ϵ* > 0), we may have in principle only a single conserved quantity—the total energy of the system. Indeed, it should be clear from the presence of a “mixed” term in the mechanical energy (Eq 10) that the axial and transverse motions are energetically coupled at large amplitudes, so that the individual energies associated with each motion are no longer independently conserved. Given that we have only one conserved quantity for a two degree of freedom system, we can no longer rely on the Liouville-Arnold theorem to prove (quasi)periodicity of the motion, and must accept that the system’s behaviour may be chaotic.

To investigate this possibility further, we first note that conservation of energy implies that flow within the four dimensional phase space must be constrained to lie on the energy surface given implicitly by the relation *H*(*q*, *ϕ*, *p*_{q}, *p*_{ϕ}) = *E*. Therefore, given a particular value *E* for the total energy, the system dynamics becomes three dimensional. This allows us to visualise the behaviour of the system by plotting the points at which trajectories intersect a two-dimensional Poincare section [57, 58]. We define our Poincare section by the condition that the angular momentum vanishes *p*_{ϕ} = 0 (equivalently, angular velocity vanishes d*ϕ*/dt = 0), and plot successive crossings of the section as points in the *q*, *ϕ* plane. This allows us to intuitively interpret points in the Poincare section as configurations of the head at successive turning points (extrema) in the transverse motion (Fig 5B).

In what follows, we set the total energy to be so that when *ϵ* = 1 we can in principle obtain complete compression of the head (*q* = −1). We choose to set , giving an irrational frequency ratio. This loosely matches observations of the real larva in which the frequency of transverse oscillations is approximately half that of axial oscillations but does not satisfy an exact (rational) resonance relationship [44]. The results we obtain with these parameters do not differ much from results for other energies or other frequency ratios, including resonant relationships.

Poincare plots for the cases *ϵ* → 0 and are shown in Fig 6. When *ϵ* → 0 (Fig 6A), conservation of transverse energy implies that the turning points of the transverse motion must remain constant. The fact that the frequency ratio λ is irrational implies that the overall motion is quasiperiodic, and the values of *q* obtained at successive transverse turning points should not repeat. In accordance with these observations, the Poincare section for *ϵ* → 0 consists of a series of verticle lines (Fig 6Ai). For the Poincare plot becomes distorted, but the majority of trajectories still trace out one-dimensional curves in the section (Fig 6Bi), which is indicative of persistent quasiperiodic behaviour. At the Poincare plot appears qualitatively different. There is now a large region of what appears to be “noise”, indicating that the configuration of the head at successive transverse turning points has become unpredictable. This is a clear signature of deterministic chaos. There are, however, several regions of the section indicative of (quasi)periodic behaviour. These appear as one-dimensional curves or discrete points in the Poincare section (Fig 7Ai). At *ϵ* = 1, the region of the Poincare plot occupied by chaos has expanded, although there still appear to be some regions corresponding to (quasi)periodic behaviour (Fig 7Bi). These results qualitatively agree with the Kolmogorov-Arnold-Moser theorem [59], which tells us that quasiperiodic behaviour should persist under small nonintegrable (chaotic) perturbations of an integrable Hamiltonian, and that the region of phase space corresponding to chaotic behaviour should grow with the perturbation size (in our case, the perturbation size corresponds to the amplitude of motion *ϵ*). However, our model as presented here does not formally meet the requirements of this theorem (see S4 Appendix).

A, B: for small amplitudes (*ϵ* → 0, *ϵ* = 1/3), Poincare section shows quasiperiodic head oscillations (i), while the maximum Lyapunov characteristic exponent (MLCE), which quantifies the dominant rate of separation of nearby phase trajectories, converges to ∼ 0bits s^{−1} (ii), the power spectra of head stretch *q* and bend *ϕ* coordinates show clear peaks with little “noise” component (iii), and autocorrelations of these variables decay linearly (iv). These results betray non-chaotic, quasiperiodic oscillations for small amplitudes. MLCE, power spectra, and autocorrelations were computed for initial conditions shown by black dot in panel i. Parameters used to generate this figure are detailed in the main text, and reported in S3 Table.

A, B: for large amplitudes (*ϵ* = 2/3, *ϵ* = 1), the Poincare section contains a large chaotic sea (i), while the MLCE converges to a positive value (ii), power spectra become “noisy” (iii), and autocorrelations decay rapidly (iv). These results strongly suggest the existence of deterministic chaotic head dynamics for large amplitudes. MLCE, power spectra, and autocorrelations were computed for initial conditions shown by black dot in panel i. Parameters used to generate this figure are detailed in the main text, and reported in S3 Table.

Analysis by Poincare section provides an invaluable method to determine the character of overall system behaviour by direct visualisation of trajectories, but cannot be applied to higher dimensional systems. This is problematic, since we would like to assess the existence of chaos beyond our reduced model of the larva’s head. We therefore deployed a series of other methods which are possibly less reliable than the method of Poincare section but can be applied equally well to higher dimensional systems. These included estimation of the maximal Lyapunov characteristic exponent (MLCE) for the dynamics along with calculation of the power spectrum and autocorrelation of internal variables [57, 58, 60]. The MLCE can be thought of as quantifying the rate of separation of nearby trajectories, or, equivalently, the rate at which information is generated by the system being analysed [61]. A positive MLCE is generally considered a good indicator of chaotic behaviour. The power spectrum of a periodic or quasiperiodic process should consist of a “clean” set of discriminable peaks, whereas that of a chaotic process should appear “noisy” and contain power across a wide range of frequencies. Meanwhile, the autocorrelation of a periodic or quasiperiodic process should show a strong oscillatory component with an envelope that decays linearly with time, while that of a chaotic process should show a much quicker decay, similar to a coloured noise process. In Fig 6 we plot these measures at each value of *ϵ*, for a trajectory starting with initial conditions indicated on the corresponding Poincare plot by a filled black circle. These measures confirm increasingly chaotic behaviour as the amplitude *ϵ* increases, in agreement with our Poincare analysis. In Fig 8 we show a solution including all degrees of freedom in our conservative mechanical model (i.e. not just those of the head). The trajectory of individual segments relative to the substrate appears qualitatively irregular, while the indirect measures we introduced above (MLCE, power spectrum, autocorrelation) are all indicative of deterministic chaotic behaviour.

A: trajectories of individual segment boundaries appear qualitatively irregular, B: our estimate of the maximum Lyapunov characteristic exponent converges to a positive value, C: power spectra of head stretch *q* and bend *ϕ* show a strong “noise” component, and D: their autocorrelations decay rapidly. All are indicators of deterministic chaos. Parameters used to generate this figure are given in S4 Table.

### Spontaneous turning and reversals require no additional control

We will now reintroduce dissipative effects into our model of larval motion in the plane. We previously saw that conservative mechanics predicted axial travelling waves and transverse oscillations. These were lost in the presence of friction, but the axial travelling waves could be recovered with the addition of a neuromuscular system designed to selectively counteract frictive effects. We have now seen that conservative mechanics predicts chaotic planar motion. Although our neuromuscular model transfers power only into the axial degrees of freedom, we recall from the previous section that axial and transverse motions are energetically coupled at large amplitudes. We therefore tentatively expect that we may be able to recover the complete chaotic planar motion without requiring any additional mechanism for direct neuromuscular power transfer into tranverse motion.

To investigate whether our dissipative planar model shows chaotic behaviour, we ran *n* = 1000 simulations starting from almost identical initial conditions (euclidean distance between initial mechanical state vectors < 10^{−7}, with no initial neural activity) and identical parameters (see S5 Table). We can indeed observe that the simulated larva perform peristalsis with interspersed bending of the body (turns), and that the fully deterministic system produces apparently random turning such that the simulations rapidly diverge (S3 Video). Since most working definitions of chaos require strictly bounded dynamics, we here restrict our analysis to the coordinates describing deformation of the body (segmental stretches and bending angles), ignoring motions of, or overall rotations about, the centre of mass (i.e., the trajectory through space of the body, which we will analyse in the following section).

Qualitatively, the deformations of the large amplitude dissipative model appear irregular (Fig 9A). However, there are persistent features reminiscent of the ordered small-amplitude behaviour described in previous sections. In particular, there are clear axial travelling waves and lateral oscillations. However, whereas forward- and backward-propagating axial waves previously corresponded to stable limit behaviours, the large amplitude system appears to go through occasional “transitions” between these behaviours. In addition, apparently spontaneous large bends appear occasionally, suggesting that the neuromuscular system is effectively driving transverse motion.

A: representative segmental stretch (left) and bend (right) time series (see S3 Fig for corresponding neural state). Note the occurence of a large bend starting at ∼ 1–2 seconds at the larva’s head, which appears to propagate backwards along the body while triggering a “transition” from forward to backward wave propagation at ∼ 3.5 seconds. Forward wave propagation resumes at ∼ 6 seconds. B: power spectra of the head stretch *q* (top) and bend *ϕ* (bottom) showing significant “noise” component. C: Autocorrelations of *q* and *ϕ* rapidly decay. D: probability density of correlation dimension estimates for 1000 mechanical trajectories. The dimension of the system’s limit set is estimated as ∼ 3.5 (median, vertical blue line). E: maximum Lyapunov characteristic exponent estimates converge to a positive value. All measures suggest the presence of deterministic chaotic dynamics. Parameters used to generate this figure are given in S5 Table.

The irregularity of the axial motion is reflected in the pattern of sensory neuron activation (S3 Fig). However, the mutual inhibitory interactions in our model act to filter this input, allowing only a small window of excitability within the central nervous system. As a result, interneuron and motor neuron activity appears fairly ordered, tracking and reinforcing axial compression waves.

We used four measures to assess whether our qualitative observation of irregular motion betrays the existence of deterministic chaos. First, we analysed the power spectrum of individual cooordinates (Fig 9B). The power spectra of all degrees of freedom showed consistent harmonic peaks along with a strong “noisy” non-harmonic component, a pattern consistent with chaos and incommensurate with (quasi)periodicity (Fig 9B shows data for head bending angle and stretch Next, we computed the autocorrelation of the same degrees of freedom. The autocorrelations of all degrees of freedom showed a periodic pattern with a peak at 0 seconds time lag followed by a rapid decay (Fig 9C). This is characteristic of oscillatory chaotic behaviour, and the exponential loss of information regarding initial conditions that chaotic systems display. We then estimated the correlation dimension (*D*_{c}) of the limit set of our model’s dynamics. Note that we did not apply this measure to the conservative models in the previous section since the Liouville theorem rules out attracting limit sets for these systems. The distribution of correlation dimension estimates for our dissipative system across all 1000 trials is shown in Fig 9D. Estimates were clustered around ∼ 3.5 (median dimension 3.46), with 93% of estimates lying in the range [3–4]. These results are suggestive of a limit set with fractal dimension, which is a signature of “strange” chaotic attractors. Finally, we computed an estimate of the maximal Lyapunov characteristic exponent (MLCE). As in the previous section, we estimated the MLCE for our system to be positive (∼ 13*textrmbitss*^{−1}, Fig 9D), a very strong indicator of chaotic behaviour. All of these results point to the presence of a chaotic dynamical regime in our dissipative large amplitude model.

### Exploration emerges without decisions or stochasticity

As the coupled biomechanical and neuromuscular system produces both forward and backward peristalsis and lateral oscillations, each simulated larva will trace out a 2D trajectory over time. As shown in Fig 10A, the chaotic deformations characterised in the previous section caused the larvae to disperse across their two-dimensional substrate, following paths reminiscent of the real animal’s exploratory behaviour.

A: dispersion of the centres of mass of 1000 simulated larvae, starting from almost identical mechanical initial conditions (overlayed in inset). B: tortuosity and fractal (box-counting) dimension for all 1000 paths indicate plane-filling behaviour (blue line = mean tortuosity, red line = mean dimension, see text; see S4 Fig for power law analysis of trajectory curvature and angular speed). C: mean-squared displacement (black line) shows transient quadratic growth (blue line) followed by asymptotic linear growth (red line, asymptotic diffusion constant ≈ 144segs^{2}s^{−1}; see also log-log plot, S5 Fig). D: distribution of body bends (black) with maximum likelihood von Mises (red) and wrapped Cauchy (blue) fits. E: distribution of run lengths with maximum likelihood exponential fit (red). Run lengths were calculated as duration between successive crossings of a threshold body bend (20°), indicated by blue lines in panel D. See S6 Fig for analysis of tail speed and head angular velocity. Parameters used to generate this figure are given in S5 Table.

To characterise the trajectories of our model, we first investigated them at a global level, based on the centre of mass (COM) trajectory of each simulated larva, computing the tortuosity and fractal dimension of the paths (Fig 10B) [62]. We defined our tortuosity measure as
(12)
where *D* is the net displacement of the COM between initial and final times, and *L* is the total distance travelled by the COM along its path. Note that if the COM travels in a straight line between initial and final times we will have *D* = *L* so that *T* = 0. In the limit *L* → ∞, corresponding to the COM taking an extremely long path between its initial and final states, we have so that *T* → 1. We calculated the mean tortuosity of our COM trajectories to be 〈*T*〉 = 0.43, with a variance of 〈(*T* − 〈*T*〉〉)^{2} = 0.05. The lowest (highest) tortuosity observed was *T* = 0.05 (*T* = 0.95).

We estimated the fractal dimension *D*_{b} of the COM trajectories using a box-counting algorithm. The minimum expected dimension *D*_{b} = 1 would correspond to curvilinear paths (e.g. straight line or circular paths), while the maximum expected dimension of *D*_{b} = 2 corresponds to plane-filling paths (e.g. brownian motion). We calculated the mean dimension of the COM trajectories to be 〈*D*_{b}〉 = 1.37, with variance 〈(*D*_{b} − 〈*D*_{b}〉)^{2}〉 = 0.01. The lowest (highest) path dimension observed was *D*_{b} = 1.17 (*D*_{b} = 1.95). We have plotted the tortuosity and fractal dimension of every path in Fig 10B. These results show that the trajectories of the model differed markedly from straight lines (tortuosity *T* > 0 and box-counting dimension *D*_{b} > 1), and displayed a good ability to cover the planar substrate (box-counting dimension 1 < *D*_{b} < 2). We also note that our COM trajectories display the power-law relationship between angular speed and curvature reported by [63], with a scaling exponent (*β* ≈ 0.8) falling within the range reported for freely exploring larvae (S4 Fig).

We next investigated the rate at which the simulated larvae explored their environment. To do this, we calculated the mean-squared displacement (MSD) of the COM over time (Fig 10C). This is a standard measure used to characterise diffusion processes, and is defined as
(13)
where *R*_{i}(*t*) is the position of the *i*’th larva’s COM at time *t* and *n* = 1000 is the number of trials being averaged over. We observed an initial transient, lasting on the order of 10 seconds, during which the MSD grew as ∼ *t*^{2} (blue line, S5 Fig), after which growth slowed and tended to ∼ *t* (linear fit for *t* > 80 seconds shown by red line, Fig 10C and S5 Fig, *r*^{2} = 0.99, diffusion constant *D* = 144segs^{2}s^{−1}). The initial transient was not due to our particular initial conditions, since it remained even after discarding > 60s of initial data. These results therefore tell us that, although on long timescales our model appears to execute standard Fick diffusion or a Brownian random walk (linear growth of MSD), on short timescales the model’s behaviour is superdiffusive (approximately quadratic growth of MSD) [64, 65]. This is in good agreement with observations of the real larva [6, 48]. The superdiffusive behaviour of the larva was previously explained in terms of a persistent random walk [6], in which the larva’s current and previous headings are highly correlated during straight runs so that the animal follows an approximately ballistic trajectory on short timescales. We believe that persistence effects arise in our model due to the finite time required for the deterministic chaotic dynamics to destroy information regarding initial conditions.

We next calculated some other standard measures found in the larva literature. To do so, we built a two-segment representation of each simulated larva by drawing vectors from the tail extremity to the A2-A3 segment boundary (the tail vector, **T**), and from the A2-A3 boundary to the head extremity (the head vector, **H**). We then defined the body bend, *θ*, to be the angle between tail and head vectors, *θ* = atan(*H*_{y}/*H*_{x}) − atan(*T*_{y}/*T*_{x}). The head angular velocity *ν* was computed as the cross-product of the head vector and the head extremity’s translational velocity measured relative to the lab frame, , while the tail speed *v* was taken to be the magnitude of the tail extremity’s translational velocity measured relative to the lab frame, . The tail speed and head angular velocity both show a strong oscillatory component, which can be seen in the time and frequency domains (S6 Fig). The power spectra of these variables contains considerable “noise” over a wide spread of frequencies, in accordance with the results of the previous section. The distribution of tail speeds for our model is bimodal, similar to that of the real larva [44]. The body bend angle was observed to be symmetrically distributed (Fig 10D), with roughly zero mean (〈*θ*〉 = 0.005), small variance (〈(*θ* − 〈*θ*〉)^{2}〉 = 0.13), slight positive skew (*SK*(*θ*) = 0.23), and high excess kurtosis *KU*(*θ*) = 7.9. The kurtosis of our data precludes a good fit by the von Mises distribution (maximum likelihood estimate shown by red line in Fig 10D). Our data appears to be better fitted by a wrapped Cauchy distribution, though this overestimates the central tendency of our data (maximum likelihood estimate shown by blue line in Fig 10D). The high excess kurtosis of the body bend distribution gives a quantitative measure of the rare large bending events mentioned at the beginning of the previous section, and qualitatively matches experimentally observed distributions of real larval bends [44, 66]. Our model also reproduces the observed overall speed of larval locomotion (median model speed = 0.26 body lengths s^{−1}, real larval range ∼ 0.1 − −0.35 body lengths s^{−1}), the turn rate (median model turn rate = 2.08 turns min^{−1}, real larval range ∼ 0 − −4.5 turn min^{−1}, threshold body bend for turn classification = 30^{deg} to match relevant literature), and the relative distance gained during free locomotion (median model distance gained = 0.14 body lengths *s*^{−1}, real larval range ∼ 0 − −0.2), with our results being more consistent with observations of third instar than first instar larvae [66].

Finally, we computed a run-length distribution by setting a threshold body bend angle *θ*_{turn} = 20° (as in [13]) and calculating the length of time between successive crossings of this threshold. The distribution we obtained appears approximately linear on a log-linear plot (Fig 10E, linear fit *r*^{2} = 0.99 with slope λ = −0.075), and is better fit by an exponential than a power law distribution (maximum likelihood estimates, log likelihood ratio = 5281, *p* < 0.01). Together with our observation of asymptotic linear growth of MSD, the exponential distribution of run lengths suggests that the model can be considered to be effectively memoryless on long timescales [65]. This again agrees with the observed rapid loss of information from the system due to its chaotic dynamics, as quantified by the Lyapunov exponent and autocorrelation analysis of the previous section.

Ultimately, the analysis of our model supports a view of the larval exploratory routine as an (anomalous) diffusion process arising from the deterministic chaotic dynamics of the body. The model nervous system functions purely to recover these dynamics from the effects of frictive energy dissipation, and to ensure centre of mass motion, rather than explicitly directing exploration.

## Discussion

The intrinsic capabilities of an organism’s body determine the field of possibilities that neural circuits for behaviour can exploit. Here, by focusing first on the biomechanics of *Drosophila* larva, we find that its body already contains an inherent exploratory routine. This is demonstrated through a combined biomechanical and neuromuscular model that is the first to be able to generate both forward and backward peristalsis and turning, allowing 2D motion in the plane to be simulated. We show that, in the absence of friction, the body’s conservative mechanics alone supports both axial travelling waves and transverse standing waves. These are energetically coupled at larger amplitudes, such that no driving, sensing, or control of body bend is required for the system to start producing spontaneous coordinated bending motions. Frictional losses can be recovered, to maintain axial waves, by a neuromuscular system consisting of only simple local sensorimotor reflexes and long-range inhibitory interactions. This is sufficient to produce emergent crawling, reversal and turning that resembles larval exploratory behaviour, and which is chaotic in nature. At a population level, we observe a deterministic anomalous diffusion process in which an initial superdiffusive transient evolves towards asymptotic Fickian/Brownian diffusion, matching observations of real larvae [6, 48]. We therefore propose that the role of biomechanical feedback in *Drosophila* larvae goes beyond the periphery of basic neuromuscular rhythms [40, 43], to provide the essential “higher order” dynamics on which exploratory behaviour is grounded.

Most existing models of larval exploration abstract away from the mechanics underlying the production of runs and reorientations [4–6, 8, 11–13]. The larva is often described as executing a stochastic decision-making process which determines which state (running or turning) should be occupied, and when to initiate a change of behavioural state. In contrast, our model produces the entire exploratory routine without making any decisions (the transverse motion is neither sensed nor driven by the nervous system) nor introducing any stochastic process (neural or otherwise). Similarly, transient “switching” is seen to occur between forward and backward peristalsis even though there is no neural encoding or control of the direction of wave propagation. In other words, the body dynamics generate the basis of a chaotic exploratory routine which only needs to be amplified by the neural circuitry, making the search for underlying stochastic or state switching circuitry superfluous for this behaviour.

The work presented here also stands in contrast to previous models of larval peristalsis [39, 43] and the prevailing hypotheses regarding this phenomenon [15, 67] by eschewing any role for intrinsic neural dynamics. Such stereotyped and rhythmic locomotion is widely assumed to be the signature of a central pattern generator (CPG), that is, a neural circuit that intrinsically generates a rhythmic output, and thus determines a particular mechanical trajectory to be followed by the body [68–70]. However it is recognised that systems vary in the degree to which coordinated behaviour is independent of biomechanical and sensory feedback [70]. Indeed, evidence from studies employing genetic manipulations to disrupt sensory neuron input suggest that proprioceptive feedback is necessary for correct larval locomotive patterns [16, 36–38, 71]; although in some cases coordinated waves of forward and backward peristalsis can be produced, in both intact [16, 36, 71] and isolated VNC preparations [14, 15], these are reported as abnormal with the most evident defects being time-dilation [15, 36, 71] and abnormal frequency in polarity changes [71].

In fact, our intent is not to adjudicate between the roles of intrinsically generated activation sequences vs. biomechanical feedback in this system, but rather to note that we should expect neural circuits of locomotion to adhere to the dynamical modes of the associated body, instead of working against them. Thus it should be unsurprising if these dynamics also exist (potentially in a latent form) in the neural circuitry. For example, a simple modification of the neural circuit presented here could produce instrinsic ‘peristaltic’ waves. Recall that the long-range global inhibition pattern in our model treats head and tail segments as ‘neighbouring’ nodes (see *Models—Neuromuscular system*). If local constant input or recurrent feedback were added to each segment, the circuit would then resemble a ring attractor [72–74] and a stable activity bump would be formed. Breaking the forward/backward symmetry of the circuit, e.g., by introducing asymmetric nearest-neighbour excitatory connections [75], would cause the activity bump to move along the network, giving rise to intrinsic travelling waves. This would complement any mechanical compression waves travelling through the body, i.e., remain consistent with the principles set out in this paper. Would such a network be a CPG? The answer is unclear. On the one hand, it would show spontaneous rhythmic activity in the absence of sensory input. On the other, sensory feedback would do much more than simply correct deviations from the CPG output or provide a “mission accomplished” signal [36]. Rather, feedback would play a crucial role in orchestrating motor output to ensure power flow into the body, consistently with its dynamical modes.

It is important to note that the emergence of rhythmic peristalsis and spontaneous turns in our model is not strongly dependent on the specific assumptions made in our mechanical abstraction. For example, the observation for small amplitude motions of sinusoidal axial travelling waves, along with transverse standing waves whose shapes match the experimentally observed “eigenmaggots” [56], is a direct result of the second-order Taylor series approximation of the model Hamiltonian (S2 Appendix). The small-amplitude model is thus non-unique, since many different mechanical models could have identical second-order approximations. Similarly, we expect that the deterministic chaotic behaviour derived from our conservative model for large amplitude motions will hold for other models of the larval body, given that it is conjectured that the majority of Hamiltonian systems are nonintegrable. This may also mean that our results can be applied to other animals with body morphologies and mechanics similar to the *Drosophila* larva.

In our model we constrain the total length of the larva to be constant. This constraint is intended to represent the fact that there is minimal observable radial deformation of the larva’s body during behaviour, yet its body is filled with fluid which should conserve volume. We were further motivated by the experimental observation of “visceral pistoning” [3] in which the head and tail extremities of the larva appear to be mechanically coupled via the coelomic fluid during peristalsis. However, the total length of the real larva is known to change during behaviour [47], and it is therefore important to consider the effect of weakening the length constraint in our model. When restricted to small-amplitude motion, the total length constraint appears as periodic boundary conditions in the axial mechanics, allowing waves of compression to propagate from head to tail and vice versa. In the complete absence of the length constraint, these waves will instead be reflected back from the head and tail extremities, leading to alternating forward and backward waves. Alternatively, replacing the constraint with a simple linear viscoelastic model to represent energy storage and dissipation within the internal fluid and in radial cuticle deformation leads to the presence of a new mechanical impedance between the head and tail. It is well known that sudden impedance changes in wave transmission media lead to simultaneous reflection and transmission of waves—in our model, this means that some amount of the axial compression wave will be transmitted between head and tail while some will be reflected. Since our neural model cannot sustain two peristaltic waves concurrently due to the presence of mutual inhibition between distant segments, this causes occasional “switching” between forward and backward peristalsis. If the extent of radial deformations is under neural control in the larva, this could provide a potential route for control or biasing of transitions between forward and backward peristalsis.

As a consequence of exploiting body mechanics, our model explains a wider range of behaviour than previous models, using a simpler nervous system. The properties included in the neuromuscular circuitry were derived from basic physical considerations, i.e., what was necessary and sufficient to produce exploration, rather than from known neuroanatomy or neurophysiology. However, it is useful to now examine what insights and predictions regarding this circuitry can be derived from our model.

Firstly, we consider the connections between segments. Unlike the model from [43], we did not require assymmetric connections to obtain forward (or backward) waves as these (and spontaneous switching between them) arise inherently in the mechanics. Rather, obtaining centre of mass motion of the entire body required the “ring attractor” layout of mutual inhibition between distant segments described above. The model thus predicts that motor output should be strongly inhibited (by signalling from other segments) the majority of the time, so that motor neurons only activate as the (mechanical) peristaltic wave passes through the corresponding body segment. This is in contrast to previous models which appealed only to local, nearest-neighbour inhibitory connections [39, 43].

What might be the neural substrate for the proposed inhibition? There are two currently known intersegmental inhibitory pathways in the larva. GVLI premotor inhibitory neurons synapse onto motor neurons within the same segment but extend their dendritic fields several segments further anterior along the VNC. Accordingly, the GVLIs inhibit motor neurons at a late phase during the local motor cycle [22]. Our model predicts that there should be a larger set of GVLI-like neurons within each segment, with dendritic fields tiling distant segments. Although in our model the mutual inhibition is (for simplicity) arranged to act on all non-adjacent segments, we would in practice expect that active compression is actually spread across more segments [3, 22] to transfer power to the body more efficiently (S3 Appendix), and this should be reflected in the inhibitory connection pattern. The second inhibitory pathway involves GDL inhibitory interneurons, which receive input from the excitatory premotor neuron A27h in the nearest posterior segment, and synapse onto A27h within the same segment while simultaneously disinhibiting premotor inhibitory neurons in distant segments [28]. Thus, GDL effectively produces both local and long-range inhibition of motor output. However, GDL receives axo-axonic connections from vdaA and vdaC mechanosensory cells within the same segment, so local inhibition is likely gated by sensory input. This would match our model, in which sensory activation within a segment should be sufficient to produce motor output when one of the neighbouring segments is active. We thus predict that simultaneous experimental suppression of GDL, GVLI, and all other long-range inhibition in the VNC should allow the propagation of several, concurrent locomotor waves in response to mechanical input.

Secondly, within a segment, our model highlights the importance of the timing of neuromuscular forces relative to body motion. Specifically, during locomotion, the larva’s muscles should act primarily as motors rather than as springs, brakes, or struts (see [33] for a discussion of these differences), and thus should activate in phase with the segmental stretch rate. This hypothesis could be tested by performing work-loop experiments, for which we predict the existence of a counterclockwise cycle in a plot of muscle force (potentially measurable by calcium imaging) over segment length during locomotion.

Can our model’s requirement that neurons sensing stretch-rate provide a direct excitatory connection to motor neurons, within the same segment, be mapped to identified pathways in the larva? One possible monosynaptic implementation of such a link are the dda mechanosensory cells which have been observed to make synapses onto aCC and RP2 motor neurons [23]. However, synapse counts show high variability both within and across individuals, so it seems unlikely to be a core component of the locomotor circuitry. A more promising candidate is the excitatory premotor interneuron A27h, which receives input from vpda and vdaC and sends bilaterally symmetric outputs to aCC and RP5 [28]. It is known that A27h activation is sufficient to activate downstream motor neurons, but it remains unknown whether proprioceptive sensory input is sufficient to activate A27h. Additionally, we hypothesise that A02 (PMSI) interneurons [20], which have been recently shown to form an inhibitory sensory-motor feedback pathway between dbd mechanosensory cells and motor neurons [27], could play a role in filtering this signal to obtain the necessary stretch-rate activation independently of stretch. General models of mechanotransduction suggest that larval mechanosensory cells may be sensitive to both rate of stretch as well as absolute stretch, depending upon the mechanical properties of the sensory dendrites and the biophysics of the relevant mechanosensitive ion channels [76]. If PMSIs have a slow-activating, integrator dynamics that encodes stretch, while A27h activate quickly in response to proprioceptive sensory input to encode stretch and stretch-rate, the combined input to motor neurons would be only stretch-rate dependent excitation, as our model requires. This could explain the observation that optogenetic disturbance of PMSIs [20] slows the timescale of peristaltic waves, as the inclusion of absolute stretch in this feedback loop would produce muscle forces that not only counteract friction but also decrease the effective stiffness of the cuticle, slowing peristalsis (see S5 Appendix).

It is clear the real larval nervous system exhibits many complexities not reflected in our model, and likewise that the real larva performs many more behaviours than exploration. These include appropriate (directed) reactions to sensory stimuli such as stopping, withdrawal and reverse in response to touch stimuli [38]; differences in the speed of forward and backward locomotion [15]; and modulation of the frequency and direction of (large) turns in response to sensory gradients such as odour, heat or light [4, 8–10, 12, 13, 77–82] to produce positive or negative taxis. In a previous model of taxis [44] we have shown that by a continuous coupling of the amplitude of a regular lateral oscillation to the experienced change in stimulus strength in a gradient, a larva-like response to gradients can emerge, again without requiring active switching between states. In the current model, this could be effected by incorporating direct neuromuscular driving of bending degrees of freedom, since the real larva can likely use asymmetric activation of its lateralised muscles to produce active bending torques to influence the transverse motion. Alternatively, the degree of bend could be influenced indirectly by altering the stiffness and viscosity of segments (as explored in our upcoming paper [49]), or their frictional interaction with the substrate. We note that the effective viscoelasticity of body segments can be neurally controlled by local reflex arcs (see S4 Appendix and [40]). Indeed, this could partially explain the experimental observation of increased bending on perturbation of a contralateral segmental reflex mediated by Eve^{+} interneurons [24]. The muscle activation caused by this reflex should produce bending torques which are proportional to current bend or bending rate, thus effectively modulating transverse stiffness or viscosity, respectively. Notably, in the taxis model of [44], it is not required that the descending signal that alters turn amplitude is lateralised, but rather that it has the right temporal coordination, which itself is naturally created by the interaction of body and environment.

Backward locomotion is observed to be slower than forward locomotion in the real larva [15], yet in our model both behaviours are of equal speed for a fixed value of reflex gain. We believe that this is due to the preservation of mechanical symmetry between forward and backward motion in our model. The real larva likely experiences asymmetric substrate interaction forces. For instance, this could be due to the exact coordination of denticle folding/lifting during forward and backward locomotion (S1 Video) or due to the geometry of the larva’s denticle bands, which display a degree of anisotropy [83]. Alternatively, there may be asymmetries within the larva’s neural circuitry responsible for this difference. Indeed, there do appear to be neurons in the larval VNC which are only active specifically during forwards or backwards locomotion, and these may be functionally asymmetric [28].

The model presented in this paper does occasionally produce stops (cessation of peristalsis) during exploration, but this only occurs in concert with a large body bend (this stored transverse energy can subsequently and spontaneously restart the peristalsis); whereas in larva slowing, stopping and resumption of peristalsis (or transition from a stop to a large bend) can occur while the body is relatively straight [2, 10]. As for ‘directed’ turning, this suggests that additional neural control might be needed to terminate or initiate movement in response to sensory stimuli. It is worth noting that our model predicts that peristalsis can be restarted by almost any small disturbance of the physical equilibrium provided the local feedback gain is high enough; similarly, lowering the gain means that energy losses due to friction are not compensated and the animal will stop. In general, we have found that altering assumptions about the sliding friction forces by which the model interacts with the substrate can often have unexpected and subtle effects on the motion produced, thus it would be interesting to further explore the functions provided by segmental lifting [3, 84], folding of the denticle bands (S1 Video), and extrusion of the mouth-hooks [3, 85] during locomotion. Indeed, detailed experimental characterisation of the substrate interaction forces experienced by the larva would be a major advance in understanding how the animal behaves. Inspiration for approaches to this problem could perhaps be taken from the literature on *C. elegans* substrate interaction (see for instance [42, 86–90], though this list is not exhaustive). In the more extreme case, larva are capable of burrowing through a soft substrate, and it is clear that a complex interaction of forces, mechanics, sensing and neural control must be involved that go well beyond the scope considered here.

## Supporting information

### S1 Fig. Coordinate system and substrate interaction schematics.

Internal coordinate system used to describe deformations of the larval body (left), and quantities used to describe substrate interaction (right). The friction force *F*_{friction} acting on the *i*’th segment boundary is directed opposite to that boundary’s velocity vector **v**_{i}, and has a magnitude which depends only upon the direction *θ*_{i} of the velocity vector relative to a unit vector aligned with the local body axis (see text). Note that denotes a unit vector aligned with the boundary’s velocity vector.

https://doi.org/10.1371/journal.pcbi.1006635.s001

(TIF)

### S2 Fig. Neural activation during peristalsis.

(from top to bottom) stretch rate, sensory neuron, interneuron, and motor neuron activation during forwards (left) and backwards (right) peristalsis.

https://doi.org/10.1371/journal.pcbi.1006635.s002

(TIF)

### S3 Fig. Neural activation during planar locomotion.

(from top to bottom) stretch, stretch rate, sensory neuron, interneuron, and motor neuron activation during planar motion.

https://doi.org/10.1371/journal.pcbi.1006635.s003

(TIF)

### S4 Fig. Relationship between path curvature and angular velocity.

A: representative time-series of angular velocity and curvature. B: model data from all trials (grey points) compared to fit by a power law with scaling exponent *β* ≈ 0.8 (blue line, *r*^{2} ≈ 0.94).

https://doi.org/10.1371/journal.pcbi.1006635.s004

(TIF)

### S5 Fig. Log-log plot of mean-squared displacement.

Initial quadratic growth (blue line, slope = 2) leads to asymptotic linear growth (red line, slope = 1).

https://doi.org/10.1371/journal.pcbi.1006635.s005

(TIF)

### S6 Fig. Tail speed *v* and head angular velocity *ν* during planar motion.

A: representative time series for *v* and *ν*. B: probability density of *v* and *ν* across all 1000 trials. C: individual (faint) and mean (bold) power spectra of *v* and *ν*.

https://doi.org/10.1371/journal.pcbi.1006635.s006

(TIF)

### S1 Video. Denticle bands fold into the larval cuticle during peristalsis.

The larva was placed on its side, on a Sylgard 184 PDMS plate, beneath a dissection microscope. The video was taken at 45x magnification with an Allied Vision Technologies Marlin F131B digital camera. Denticle bands are visible as repeated “rough” patches on the ventral surface of the larval cuticle, towards the top-left of the video frame. As the peristaltic wave passes a denticle band, the denticles visibly “fold” or are “squeezed” into the cuticle.

https://doi.org/10.1371/journal.pcbi.1006635.s007

(MP4)

### S2 Video. Synthesis of travelling wave solutions from standing wave solutions.

https://doi.org/10.1371/journal.pcbi.1006635.s008

(MP4)

### S3 Video. Simulated larval exploratory behaviour.

https://doi.org/10.1371/journal.pcbi.1006635.s009

(MP4)

### S2 Appendix. Detailed small-amplitude analysis.

https://doi.org/10.1371/journal.pcbi.1006635.s011

(PDF)

### S3 Appendix. A trade-off between power flow into the body and force on the centre of mass.

https://doi.org/10.1371/journal.pcbi.1006635.s012

(PDF)

### S4 Appendix. Modelling and analysis of head motion.

https://doi.org/10.1371/journal.pcbi.1006635.s013

(PDF)

### S5 Appendix. Effective body physics arising due to relationship of neuromuscular action to body motion.

https://doi.org/10.1371/journal.pcbi.1006635.s014

(PDF)

### S6 Appendix. Computer algebra and numerical methods.

https://doi.org/10.1371/journal.pcbi.1006635.s015

(PDF)

### S1 Table. Neural parameter values.

All segments are identical. Values given in larval units (seg = resting segment length, segmass = mass of a single segment boundary, nondim = dimensionless/nondimensional).

https://doi.org/10.1371/journal.pcbi.1006635.s016

(PDF)

### S2 Table. Mechanical parameters for Fig 4—*Emergence of limit cycles for forward and backward locomotion in the dissipative, small-amplitude model*.

All segments are identical. Values given in larval units (seg = resting segment length, segmass = mass of a single segment boundary, nondim = dimensionless/nondimensional).

https://doi.org/10.1371/journal.pcbi.1006635.s017

(PDF)

### S3 Table. Mechanical parameters for Figs 6 and 7—*Emergence of deterministic chaos in the conservative head dynamics as amplitude of motion is increased*.

Values given in larval units (seg = resting segment length, segmass = mass of a single segment boundary, nondim = dimensionless/nondimensional).

https://doi.org/10.1371/journal.pcbi.1006635.s018

(PDF)

### S4 Table. Mechanical parameters for Fig 8—*Conservative planar motion of the body is chaotic at large amplitudes*.

All segments are identical. Values given in larval units (seg = resting segment length, segmass = mass of a single segment boundary, nondim = dimensionless/nondimensional).

https://doi.org/10.1371/journal.pcbi.1006635.s019

(PDF)

### S5 Table. Mechanical parameters for Fig 9—*Dissipative planar motion is chaotic* and Fig 10—*Deterministic exploration*.

Values given in larval units (seg = resting segment length, segmass = mass of a single segment boundary, nondim = dimensionless/nondimensional).

https://doi.org/10.1371/journal.pcbi.1006635.s020

(PDF)

## Acknowledgments

We are grateful to Balazs Szigeti for providing us with experimental eigenmaggot data, and wish to thank Matthieu Louis and Richard Ribchester for their feedback on our manuscript.

## References

- 1.
Berni J, Pulver SR, Griffith LC, Bate M. Autonomous circuitry for substrate exploration in freely moving
*Drosophila*larvae. Current Biology. 2012;22(20):1861–70. pmid:22940472 - 2.
Lahiri S, Shen K, Klein M, Tang A, Kane E, Gershow M, et al. Two alternating motor programs drive navigation in
*Drosophila*larva. PLOS ONE. 2011;6(8):e23180. pmid:21858019 - 3. Heckscher ES, Lockery SR, Doe CQ. Characterization of Drosophila larval crawling at the level of organism, segment, and somatic body wall musculature. The Journal of Neuroscience. 2012;32(36):12460–71. pmid:22956837
- 4.
Luo L, Gershow M, Rosenzweig M, Kang K, Fang-Yen C, Garrity PA. Navigational Decision Making in
*Drosophila*Thermotaxis. The Journal of Neuroscience. 2010;30(12):4261–4272. pmid:20335462 - 5.
Davies A, Louis M, Webb B. A Model of
*Drosophila*Larva Chemotaxis. PLOS Computational Biology. 2015;11(11):1–24. - 6.
Gunther MN, Guilherme N, Shubeita GT. Quantifying and predicting
*Drosophila*larvae crawling phenotypes. Scientific Reports. 2016;6:1–10. - 7.
Green CH, Burnet B, Connolly KJ. Organization and patterns of inter- and intraspecific variation in the behaviour of
*Drosophila*larvae. Animal Behaviour. 1983;31:282–291. - 8.
Gomez-Marin A, Stephens GJ, Louis M. Active sampling and decision making in
*Drosophila*chemotaxis. Nature Communications. 2011;2(441):1–10. - 9.
Kane EA, Gershow M, Afonso B, Larderet I, Klein M, Carter AR, et al. Sensorimotor structure of
*Drosophila*larva phototaxis. Proceedings of the National Academy of Sciences. 2013;110(40):E3868–E3877. - 10.
Gomez-Marin A, Louis M. Multilevel control of run orientation in
*Drosophila*larval chemotaxis. Frontiers in Behavioral Neuroscience. 2014;8(38):1–14. - 11.
Hernandez-Nunez L, Belina J, Klein M, Si G, Claus L, Carlson JR, et al. Reverse-correlation analysis of navigation dynamics in
*Drosophila*larva using optogenetics. eLife. 2015;4:e06225. - 12.
Gepner R, Mihovilovic Skanata M, Bernat NM, Kaplow M, Gershow M. Computations underlying
*Drosophila*photo-taxis, odor-taxis, and multi-sensory integration. eLife. 2015;4:e06229. - 13. Schulze A, Gomez-Marin A, Rajendran VG, Lott G, Musy M, Ahammad P, et al. Dynamical feature extraction at the sensory periphery guides chemotaxis. eLife. 2015;4:e06694.
- 14.
Fox LE, Soll DR, Wu CF. Coordination and modulation of locomotion pattern generators in
*Drosophila*larvae: effects of altered biogenic amine levels by the tyramine beta hydroxlyase mutation. The Journal of Neuroscience. 2006;26(5):1486–98. pmid:16452672 - 15.
Pulver SR, Bayley TG, Taylor AL, Berni J, Bate M, Hedwig B. Imaging fictive locomotor patterns in larval
*Drosophila*. Journal of Neurophysiology. 2015;114(5):2564–2577. pmid:26311188 - 16.
Inada K, Kohsaka H, Takasu E, Matsunaga T, Nose A. Optical Dissection of Neural Circuits Responsible for
*Drosophila*Larval Locomotion with Halorhodopsin. PLOS ONE. 2011;6(12):1–10. - 17. Crisp SJ, Evers JF, Bate M. Endogenous Patterns of Activity Are Required for the Maturation of a Motor Network. The Journal of Neuroscience. 2011;31(29):10445–10450. pmid:21775590
- 18.
Iyengar BG, Chou CJ, Vandamme KM, Klose MK, Zhao X, Akhtar-Danesh N, et al. Silencing synaptic communication between random interneurons during
*Drosophila*larval locomotion. Genes, Brain and Behaviour. 2011;10:883–900. - 19.
Rickert C, Kunz T, Harris KL, Whitington PM, Technau GM. Morphological Characterization of the Entire Interneuron Population Reveals Principles of Neuromere Organization in the Ventral Nerve Cord of
*Drosophila*. The Journal of Neuroscience. 2011;31(44):15870–15883. pmid:22049430 - 20.
Kohsaka H, Takasu E, Morimoto T, Nose A. A Group of Segmental Premotor Interneurons Regulates the Speed of Axial Locomotion in
*Drosophila*Larvae. Current Biology. 2014;24:2632–2642. pmid:25438948 - 21.
Okusawa S, Kohsaka H, Nose A. Serotonin and Downstream Leucokinin Neurons Modulate Larval Turning Behavior in
*Drosophila*. The Journal of Neuroscience. 2014;34(7):2544–2558. pmid:24523545 - 22.
Itakura Y, Kohsaka H, Ohyama T, Zlatic M, Pulver SR, Nose A. Identification of Inhibitory Premotor Interneurons Activated at a Late Phase in a Motor Cycle during
*Drosophila*Larval Locomotion. PLOS ONE. 2015;10(9). - 23.
Couton L, Mauss AS, Yunusov Y, Diegelmann S, F EJ, Landgraf M. Development of Connectivity in a Motorneuronal Network in
*Drosophila*Larvae. Current Biology. 2015;25(5):568–576. pmid:25702582 - 24.
Heckscher ES, Zarin AA, Faumont S, Clark MQ, Manning L, Fushiki A, et al. Even-Skipped
^{+}Interneurons Are Core Components of a Sensorimotor Circuit that Maintains Left-Right Symmetric Muscle Contraction Amplitude. Neuron. 2015;88:314–329. pmid:26439528 - 25.
Berni J. Genetic Dissection of a Regionally Differentiated Network for Exploratory Behaviour in
*Drosophila*Larvae. Current Biology. 2015;25:1319–1326. pmid:25959962 - 26.
Ohyama T, Schneider-Mizell CM, Fetter RD, Aleman JV, Franconville R, Rivera-Alba M, et al. A multilevel multimodal circuit enhances action selection in
*Drosophila*. Nature. 2015;520:644–639. - 27.
Schneider-Mizell CM, Gerhard S, Longair M, Kaimiers T, Li F, Zwart MF, et al. Quantitative neuroanatomy for connectomics in
*Drosophila*. eLife. 2016;5. - 28.
Fushiki A, Zwart MF, Kohsaka H, Fetter RD, Cardona A, Nose A. A circuit mechanism for the propagation of waves of muscle contraction in
*Drosophila*. eLife. 2016;5:e13253. pmid:26880545 - 29. Zwart MF, Pulver SR, Truman JW, Fushiki A, Fetter RD, Cardona A, et al. Selective Inhibition Mediates the Sequential Recruitment of Motor Pools. Neuron. 2016;91:615–628. pmid:27427461
- 30.
Hasegawa E, Truman JW, Nose A. Identification of excitatory premotor interneurons which regulate local muscle contraction during
*Drosophila*larval locomotion. Scientific Reports. 2016;6:1–13. - 31.
Yoshikawa S, Long H, Thomas JB. A subset of interneurons required for
*Drosophila*larval locomotion. Molecular and Cellular Neuroscience. 2016;70:22–29. pmid:26621406 - 32.
Matsunaga T, Kohsaka H, Nose A. Gap Junction-Mediated Signaling from Motor Neurons Regulates Motor Generation in the Central Circuits of Larval
*Drosophila*. The Journal of Neuroscience. 2017;37(8):2045–2060. pmid:28115483 - 33. Dickinson MH, Farley CT, Full RJ, Koehl MAR, Kram R, Lehman S. How Animals Move: An Integrative View. Science. 2000;288(5463):100–106. pmid:10753108
- 34. Tytell ED, Holmes P, Cohen A H. Spikes alone do not behaviour make: Why neuroscience needs biomechanics. Current Opinion in Neurobiology. 2011;21(5):816–822. pmid:21683575
- 35. Chiel HJ, Beer RD. The brain has a body: adaptive behavior emerges from interactions of nervous system, body and environment. Trends in Neurosciences. 1997;20(12):553–557. pmid:9416664
- 36.
Hughes CL, Thomas JB. A sensory feedback circuit coordinates muscle activity in
*Drosophila*. Molecular and Cellular Neuroscience. 2007;35(2):383–396. pmid:17498969 - 37.
Song W, Onishi M, Jan LY, Jan YN. Peripheral multidendritic sensory neurons are necessary for rhythmic locomotion behavior in
*Drosophila*larvae. Proceedings of the National Academy of Sciences. 2007;104(12):5199–5204. - 38. Zhou Y, Cameron S, Chang WT, Rao Y. Control of directional change after mechanical stimulation in Drosophila. Molecular Brain. 2012;5(39):1–13.
- 39.
Gjorgjieva J, Berni J, Evers JF, Eglen SJ. Neural circuits for peristaltic wave propagation in crawling
*Drosophila*larvae: analysis and modeling. Frontiers in computational neuroscience. 2013;7:1–24. - 40.
Ross D, Lagogiannis K, Webb B. In: A Model of Larval Biomechanics Reveals Exploitable Passive Properties for Efficient Locomotion. Springer International Publishing; 2015. p. 1–12.
- 41. Boyle J, Berri S, Cohen N. Gait Modulation in C. elegans: An Integrated Neuromechanical Model. Frontiers in Computational Neuroscience. 2012;6:10. pmid:22408616
- 42. Cohen N, Sanders T. Nematode locomotion: dissecting the neuronal–environmental loop. Current Opinion in Neurobiology. 2014;25:99—106. https://doi.org/10.1016/j.conb.2013.12.003 pmid:24709607
- 43.
Pehlevan C, Paoletti P, Mahadevan L. Integrative neuromechanics of crawling in
*D. melanogaster*larvae. eLife. 2016;5:e11031. - 44.
Wystrach A, Lagogiannis K, Webb B. Continuous lateral oscillations as a core mechanism for taxis in
*Drosophila*larvae. eLife. 2016;5:e15504. pmid:27751233 - 45.
Ohyama T, Jovanic T, Denisov G, Dang TC, Hoffmann D, Kerr RA, et al. High-Throughput Analysis of Stimulus-Evoked Behaviors in
*Drosophila*Larva Reveals Multiple Modality-Specific Escape Strategies. PLOS ONE. 2013;8(8):1–21. - 46.
Godoy-Herrera R. The development and genetics of digging behaviour in
*Drosophila*larvae. Heredity. 1986;56:33–41. - 47. Berrigan D, Pepin DJ. How maggots move: Allometry and kinematics of crawling in larval Diptera. Journal of Insect Physiology. 1995;41(4):329–337.
- 48. Jakubowski BR, Longoria RA, Shubeita GT. A high throughput and sensitive method correlates neuronal disorder genotypes to Drosophila larvae crawling phenotypes. Fly. 2012;6(4):303–308. pmid:22992470
- 49.
Loveless J, Webb B. A Neuromechanical Model of Larval Chemotaxis. Integrative and Comparative Biology. in review;.
- 50.
Landau LD, Lifshitz EM. Fluid Mechanics. vol. 6 of Course of Theoretical Physics. 2nd ed. Butterworth-Heinemann; 1987.
- 51.
Alexander RM. Principles of Animal Locomotion. 1st ed. Princeton University Press; 2003.
- 52. Paterson BA, Anikin IM, Krans JL. Hysteresis in the production of force by larval Dipteran muscle. Journal of Experimental Biology. 2010;213(14):2483–2493. pmid:20581278
- 53. Ormerod KG, Hadden JK, Deady LD, Mercier AJ, Krans JL. Action of octopamine and tyramine on muscles of Drosophila melanogaster larvae. Journal of Neurophysiology. 2013;110(8):1984–1996. pmid:23904495
- 54. Landgraf M, Bossing T, Technau GM, Bate M. The Origin, Location, and Projections of the Embryonic Abdominal Motorneurons of Drosophila. Journal of Neuroscience. 1997;17(24):9642–9655. pmid:9391019
- 55. Hoang B, Chiba A. Single-Cell Analysis of Drosophila Larval Neuromuscular Synapses. Developmental Biology. 2001;229(1):55–70. https://doi.org/10.1006/dbio.2000.9983 pmid:11133154
- 56.
Szigeti B, Deogade A, Webb B. Searching for motifs in the behaviour of larval
*Drosophila melanogaster*and*Caenorhabditis elegans*reveals continuity between behavioural states. Journal of The Royal Society Interface. 2015;12(113). - 57.
Strogatz HS. Nonlinear Dynamics and Chaos: With Applications to Physics, Biology, Chemistry, and Engineering. 1st ed. Perseus Books; 1994.
- 58.
Guckenheimer J, Holmes P. Nonlinear Oscillations, Dynamical Systems, and Bifurcations of Vector Fields. vol. 42 of Applied Mathematical Sciences. 1st ed. Springer; 1983.
- 59.
Arnol’d VI. Mathematical Methods of Classical Mechanics. vol. 60 of Graduate Texts in Mathematics. 2nd ed. Springer; 1989.
- 60. Cuerno R, Rañada AF, Ruiz-Lorenzo JJ. Deterministic chaos in the elastic pendulum: A simple laboratory for nonlinear dynamics. American Journal of Physics. 1992;60(1):73–79.
- 61. Shaw R. Strange Attractors, Chaotic Behaviour, and Information Flow. Zeitschrift Naturforschung Teil A. 1981;36:80–112.
- 62. Benhamou S. How to reliably estimate the tortuosity of an animal’s path: straightness, sinuousity, or fractal dimension? Journal of Theoretical Biology. 2004;229:209–220. pmid:15207476
- 63.
Zago M, Lacquaniti F, Gomez-Marin A. The speed-curvature power law in
*Drosophila*larval locomotion. Biology Letters. 2016;12. pmid:28120807 - 64.
Vlahos L, Isliker H, Kominis Y, Hizanidis K. Normal and Anomalous Diffusion: A Tutorial. pre-print: arXiv:08050419 [nlinCD]. 2008;.
- 65.
Méndez V, Campos D, Bartumeus F. Stochastic Foundations in Movement Ecology: Anomalous Diffusion, Front Propagation, and Random Searches. 1st ed. Springer Series in Synergetics. Springer-Verlag Berlin Heidelberg; 2014.
- 66. Almeida-Carvalho MJ, Berh D, Braun A, Chen Yc, Eichler K, Eschbach C, et al. The Ol1mpiad: concordance of behavioural faculties of stage 1 and stage 3 Drosophila larvae. Journal of Experimental Biology. 2017;220(13):2452–2475. pmid:28679796
- 67.
Kohsaka H, Okusawa S, Itakura Y, Fushiki A, Nose A. Development of larval motor circuits in
*Drosophila*. Development, Growth, and Differentiation. 2012;54(3):408–419. - 68. Grillner S. Locomotion in Vertebrates: Central Mechanisms and Reflex Interaction. Physiological Reviews. 1975;55(2):247–304. pmid:1144530
- 69. Marder E, Bucher D. Central pattern generators and the control of rhythmic movements. Current Biology. 2001;11(23):986–996.
- 70. Marder E, Bucher D, Schulz DJ, Taylor AL. Invertebrate Central Pattern Generation Moves Along. Current Biology. 2005;15(17):685–699.
- 71. Suster ML, Bate M. Embryonic assembly of a central pattern generator without sensory input. Nature. 2002;416(6877):174–178. pmid:11894094
- 72. Skaggs WE, Knierim JJ, Kudrimoti HS, McNaughton BL. A Model of the Neural Basis of the Rat’s Sense of Direction. Advances in Neural Information Processing Systems. 1995;7:173–180. pmid:11539168
- 73. Zhang K. Representation of Spatial Orientation by the Intrinsic Dynamics of the Head-Direction Cell Ensemble: A Theory. The Journal of Neuroscience. 1996;16(6):2112–2126. pmid:8604055
- 74. Song P, Wang X. Angular Path Integration by Moving “Hill of Activity”: A Spiking Neuron Model without Recurrent Excitation of the Head-Direction System. The Journal of Neuroscience. 2005;25(4):1002–1014. pmid:15673682
- 75.
Merritt D, Whitington P. Central projections of sensory neurons in the
*Drosophila*embryo correlate with sensory modality, soma position, and proneural gene function. The Journal of Neuroscience. 1995;15(3):1755–1767. pmid:7891133 - 76. Suslak TJ, Armstrong JD, Jarman AP. A general mathematical model of transduction events in mechano-sensory stretch receptors. Network: Computation in Neural Systems. 2011;22(1-4):133–142.
- 77.
Sawin EP, Harris LR, Campos AR, Sokolowski MB. Sensorimotor transformation from light reception to phototactic behavior in
*Drosophila*larvae (Diptera: Drosophilidae). Journal of Insect Behavior. 1994;7(4):553. - 78.
Busto M, Iyengar B, Campos AR. Genetic Dissection of Behavior: Modulation of Locomotion by Light in the
*Drosophila melanogaster*Larva Requires Genetically Distinct Visual System Functions. The Journal of Neuroscience. 1999;19(9):3337–3344. pmid:10212293 - 79.
Scantlebury N, Sajic R, Campos AR. Kinematic Analysis of
*Drosophila*Larval Locomotion in Response to Intermittent Light Pulses. Behavior Genetics. 2007;37(3):513–524. pmid:17318369 - 80. Louis M, Huber T, Benton R, Sakmar TP, Vosshall LB. Bilateral olfactory sensory input enhances chemotaxis behaviour. Nature Neuroscience. 2008;11(2):187–199. pmid:18157126
- 81. Gershow M, Berck M, Mathew D, Luo L, Kane EA, Carlson JR, et al. Controlling airborne cues to study small animal navigation. Nature Methods. 2012;9(3):290–296. pmid:22245808
- 82.
Klein M, Afonso B, Vonner AJ, Hernandez-Nunez L, Berck M, Tabone CJ, et al. Sensory determinants of behavioral dynamics in
*Drosophila*thermotaxis. Proceedings of the National Academy of Sciences. 2015;112(2):E220–E229. - 83. Alexandre C, Lecourtois M, Vincent J. Wingless and Hedgehog pattern Drosophila denticle belts by regulating the production of short-range signals. Development. 1999;126(24):5689–5698. pmid:10572045
- 84.
Dixit R, VijayRaghavan K, Bate M. Hox genes and the regulation of movement in
*Drosophila*. Developmental Neurobiology. 2008;68(3):309–316. pmid:18044732 - 85.
Bhatt PK, Neckameyer WS. Functional Analysis of the Larval Feeding Circuit in
*Drosophila*. Journal of Visualised Experiments. 2013;81. - 86. Berri S, Boyle JH, Tassieri M, Hope IA, Cohen N. Forward locomotion of the nematode C. elegans is achieved through modulation of a single gait. HFSP journal. 2009;3 3:186–93. pmid:19639043
- 87. Gjorgjieva J, Biron D, Haspel G. Neurobiology of Caenorhabditis elegans Locomotion: Where Do We Stand? BioScience. 2014;64(6):476–486. pmid:26955070
- 88. Rabets Y, Backholm M, Dalnoki-Veress K, Ryu WS. Direct Measurements of Drag Forces in C. elegans Crawling Locomotion. Biophysical Journal. 2014;107(8):1980—1987. https://doi.org/10.1016/j.bpj.2014.09.006 pmid:25418179
- 89. Backholm M, Kasper AKS, Schulman RD, Ryu WS, Dalnoki-Veress K. The effects of viscosity on the undulatory swimming dynamics of C. elegans. Physics of Fluids. 2015;27(9):091901.
- 90. Keaveny EE, Brown AEX. Predicting path from undulations for C. elegans using linear and nonlinear resistive force theory. Physical Biology. 2017;14(2):025001. pmid:28140351