Hydrodynamics can Determine the Optimal Route for Microswimmer Navigation

Contrasting the well explored problem on how to steer a macroscopic agent like an airplane or a moon lander to optimally reach a target,"optimal microswimming", i.e. the quest for the optimal navigation strategy for microswimmers, remains unsolved. Here, we systematically explore this problem and show that the characteristic flow field of microswimmers crucially influences the required navigation strategy to reach a target fastest. The resulting optimal trajectories can have remarkable and non-intuitive shapes, which qualitatively differ from those of dry active particles or motile macroagents. Our results provide generic insights into the role of hydrodynamics and fluctuations on optimal navigation at the microscale and suggest that microorganisms might have survival advantages when strategically controlling their distance to remote walls. In particular, when fluctuations are present, choosing the optimal strategy, which appropriately respects hydrdynamics, can halve the time to reach the target compared to cases microswimmers head straight towards it.


INTRODUCTION
The quest on how to navigate or steer to optimally reach a target is important e.g. for airplanes to save fuel while facing complex wind patterns on their way to a remote destination, or for the coordination of the motion of the parts of a space-agent to safely land on the moon. These classical problems are well-explored and are usually solved using optimal control theory [1]. Likewise, navigation and search strategies are frequently encountered in a plethora of biological systems, including the foraging of animals for food, [2] or of T cells searching for targets to mount an immune response [3]. Very recently there is a growing interest also in optimal navigation problems and search strategies [4][5][6][7][8][9] of microswimmers [10][11][12][13] and "dry" active Brownian particles [14][15][16][17][18]. These active agents can self-propel in a low-Reynoldsnumber solvent, and might play a key role in tomorrow's nanomedicine as recently popularized e.g. in [19]. In particular, they might become useful for the targeted delivery of genes [20] or drugs [21,22] and other cargo [23,24] to a certain target (e.g. a cancer cell) through our blood vessels, requiring them to find a good, or ideally optimal, path towards the target avoiding e.g. obstacles and unfortunate flow field regions. In the following, we refer to the general problem regarding the optimal trajectory of a microswimmer which can freely steer but cannot control its speed towards a predefined target (point-to-point navigation) as "the optimal microswimmer navigation problem".
The characteristic differences between the optimal microswimmer navigation problem and conventional optimal control problems for macroagents like airplanes, cruise-ships or moon-landers, root in the presence of a low-Reynolds-number solvent in the former problem only.
They comprise (i) overdamped dynamics (ii) thermal fluctuations and (iii) long-ranged fluid-mediated hydrodynamic interactions with interfaces, walls and obstacles, all of which are characteristic for microswimmers [15]. Notice in particular that the non-conservative hydrodynamic forces which microswimmers experience call for a distinct navigation strategy than the conservative gravitational forces acting e.g. on space vehicles. Recent work has explored optimal navigation problems of dry active particles (and particles in external flow fields) accounting for (i) and partly also for (ii): Specifically, the very recent works [4,5,8,9,[25][26][27][28][29][30][31][32][33] have pioneered the usage of reinforcement learning [34][35][36] e.g. to determine optimal steering strategies of active particles to optimally navigate towards a target position [4,5,8,9] or to exploit external flow fields to avoid getting trapped in certain flow structures by learning smart gravitaxis [25]. Meanwhile, refs. [5,6,37] have used (deep) reinforcement learning to explore microswimmer navigation problems in mazes and obstacle arrays assuming global [5] or only local [6] knowledge of the environment.Very recent analytical approaches [7,8] to optimal active particle navigation complement these works and allow testing machine-learned results [8,9]. (In addition, note that a significant knowledge exists on the complementary problem of optimizing body-shape deformation of deformable swimmers with optimal control theory; see e.g. [38][39][40].) Despite this remarkable progress in recent years, (iii), and its interplay with (ii), remains an important open problem to understand the optimal microswimmer navigation strategy.
To fill this gap, in the present work, we systematically explore the optimal microswimmer navigation problem in the presence of walls or obstacles, where hydrodynamic microswimmer-wall interactions are well known to occur [41][42][43][44][45][46][47][48][49], but whose impact on optimal microswimmer navigation is essentially unknown. Combining an analytical approach with numerical simulations, we find that in the presence of remote obstacles or walls, the shortest path is not fastest for microswimmers, even in the complete absence of external force or flow fields. Thus, unlike dry active particles (or light rays following Fermat's princple), in the presence of remote obstacles microswimmers generically have to take excursions to reach their target fastest. In the presence of fluctuations, the "optimal" navigation strategy effectively protects microswimmers from fluctutions and can drastically decrease the traveling time as compared to where the microswimmer head straight towards the target. This offers a novel perspective on the motion of microorganisms near surfaces or interfaces: it suggests that microorganisms might have a survival advantage when actively regulating their distance to remote walls in order to approach a food source via a strategic detour, rather than directly heading towards it. Besides their possible biological implications, our findings might provide a benchmark for future research on optimal navigation strategies of active particles.

RESULTS AND DISCUSSION
Before introducing our detailed model, let us illustrate the consequences of the finding that the shortest path is not fastest for microswimmers: Consider a microswimmer which can freely control its swimming direction (but not its speed) and aims to reach a predefined target in the presence of two obstacles ( Fig. 1): While in the absence of hydrodynamics (dry active particle), the shortest path is optimal (blue), an actual microswimmer takes a qualitatively different path to reach its target fastest (red and green curves) because it produces a flow field which is reflected by the obstacles and changes its speed. In particular, "source dipole" microswimmers (specified below) which produce a flow field which slows them down near walls (Fig. 1b), take an excursion (red curve in panel a) to avoid the obstacles. Other source-dipole microswimmers which produce an analogous but sign-reversed flow field (Fig. 1c), which speeds them up near walls, take a qualitatively different excursion to benefit from the proximity of both obstacles (green curve in panel a). More generally, we find that the role of hydrodynamics on optimal microswimmer routes can be subtle and lead to counterintuitive trajectory-shapes: while for source-dipole swimmers the sign of the coefficient plays a decisive role for the resulting trajectory-shapes, as have just seen (Fig. 1), for for force-dipole swimmers, we will see that the sign of the coefficient is unimportant for optimal navigation and only the strength of the hydrodynamic interactions matters.

Model
Let us consider a self-propelling active particle interacting with a 3D fluctuating environment. The particle's center of mass evolves asṙ(t) = (v x (r, ψ, t), v y (r, ψ, t), v z (r, ψ, t)) + √ 2D η(t), wherein v x , v y , and v z are the components of the deterministic swimming velocity in Cartesian coordinates, which depend on the hydrodynamic swimmer-wall interactions as well as on the propulsion direction of the swimmer (cos ψ cos φ, cos ψ sin φ, sin ψ). Here, D is the diffusion coefficient which determines the strength of thermal fluctuations; for now, we choose D = 0 and consider a twodimensional motion in the xz-plane and thus set φ = 0. We will discuss the effect of fluctuations later. Given a predefined initial r(t = 0) = r A and terminal point r(t = T ) = r B in the xz-plane, we ask for the optimal connecting trajectory minimizing the travel time T , when the swimmer is allowed to steer freely. (This may represent e.g. biological swimmers which steer through body shape deformations or synthetic swimmers controlled by external feedback). That is, ψ(t) can be freely chosen so as to minimize the ravel time of the swimmer. This is a well-defined optimal control problem determining the optimal trajectory, the navigation protocol {ψ(t)|t ∈ [0, T ]} and T . It resembles classical navigation problems e.g. of an airplane, which can steer freely and move at a speed which is determined by the wind (assuming some favorable constant engine power). Interestingly, however, while for such macroagents or dry active particles in constant external fields the shortest path is optimal [7,50], for microswimmers excursions can pay off, as we will see in the following. Note that the considered model can be tested with programmed active colloids [51][52][53] but should also be relevant for biological microswimmers which often swim at an almost constant speed and are able to control their self-propulsion direction on demand. These swimmers are often in contact with (remote) walls or interfaces which drastically influence their overall swimming speed and direction of motion.
As a model microswimmer, in the following, we employ the multipole description of swimming microorganisms. Accordingly, the self-generated flow field is decomposed in the far-field limit, to a good approximation, into a superposition of higher-order singularities of the Stokes equations. This model has favorably been verified experimentally for swimming E. coli bacteria [54] and Chlamydomonas algae [55]. Even though the theory is based on a far-field description of the hydrodynamic flow, it has been demonstrated using boundary integral simulations that, in some cases, the far-field approximation is surprisingly accurate, all the way down to a microswimmer-wall distance of one tenth of a swimmer length [56].
Source dipole swimmers: To develop an elementary understanding of optimal microswimmer navigation, let us first consider a source dipole microswimmer (e.g. Paramecium or active colloids with uniform surface mobility) aiming to reach a target in the presence of a distant hard wall infinitely extended in the xy-plane, for an initial and target position in the xzplane, yielding [56] and v z = v 0 − σ/z 3 sin ψ wherein the deviation from v 0 is due to hydrodynamic swimmer-wall interactions.
To reduce the parameter space to its essential dimensions we choose the length unit as = (|σ| /v 0 ) 1/3 , which represents the swimmer-wall distance at which the swimmer displacement per time due to hydrodynamic interactions and due to self-propulsion become comparable. For the time unit, we chose the associated time scale In reduced units, the noise-free equations of motion for a source dipole swimmer then read, where x * = x/ , z * = z/ , and s = sgn(σ). Accordingly, by expressing the equations of motion together with the underlying boundary conditions in reduced units, the optimal microswimmer trajectories only depend on the sign of the source dipole parameter, but not on its strength or on the swimmer speed. For microswimmers achieving self propulsion through surface activity (ciliated microorganisms like Paramecium, active colloidal particles with uniform surface mobility) one expects σ > 0, i.e. s = 1 whereas σ < 0 (s = −1) applies to some non-ciliated microswimmers with flagella [57].
To solve the optimal navigation problem, we first eliminate ψ from the equations of motion (Methods). We then obtain the travel time as sents the path which we optimize andż * = z * ẋ * with z * = ∂z * /∂x * . To find the optimal path which minimizes T * , we now determine the Lagrangian as (see Methods for details) and then numerically solve the Euler-Lagrange equation for L * SD as a boundary value problem, with the boundary conditions z * (x * A ) = z * A and z * (x * B ) = z * B , using shooting methods.
Force dipole and force quadrupole swimmers: Similarly, the translational swimming velocities due to force dipolar hydrodynamic interactions (E. coli, Chlamydomonas) with a planar hard wall reads [54,56] x = v 0 cos ψ + 3α sin(2ψ)/(8z 2 ) andż = v 0 sin ψ + 3α [1 − 3 cos(2ψ)] /(16z 2 ) where α is the force dipole coefficient. In units of = (|α|/v 0 ) 1/2 and τ = |α| 1/2 /v 3/2 0 the equations of motion reaḋ Here, s = sgn(α) is the sign of the singularity coefficient. After some algebra, as detailed in the Methods section, the resulting Lagrangian follows as where r ± are the roots of a lengthy quartic polynomial, the coefficients of which are explicitly known functions of z * and z * (see Methods). The optimal swimming trajectories then result again from solving the Euler-Lagrange equation as a boundary value problem using shooting methods. Interestingly, L FD is sign invariant in the force dipole coefficient α, which means that pushers and pullers show identical optimal trajectories, albeit they require different navigation strategies for this. We will discuss this further in the Results section. Finally, we also calculate the Lagrangian for force quadrupole microswimmers as detailed in the Methods section.

Optimal microswimmer trajectories
Flat walls: As shown in Fig. 2, in the presence of an infinitely extended and distant flat wall, we find that all considered swimmers (source and force dipole swimmers as well as force-quadrupole swimmers) follow significant excursions to reach the target fastest. That is, the shortest path is not fastest. For instance, panel (c) of Fig. 2 shows that source dipoles with s = 1 (which slow down when approaching the wall) follow a parabola bended away from the wall, whereas those with s = −1 prefer reducing their distance to the wall which speeds them up. The corresponding steering angles required for the optimal navigation strategy are shown in panel (d).
In contrast to source dipole swimmers, perhaps surprisingly, for force dipole swimmers the shape of the resulting parabola depends only on the force dipole strength but not on the sign of the flow field [panels (a) and (b)]. This pusher-puller-identity is generic not only for planar walls but also applies for spherical obstacles and obstacle landscapes, as can be directly seen from the independence of the Lagrangian of s [Eq. (4)]. Interestingly, however, the required steering protocol, i.e. the temporal evolution of the optimal value of the control variable ψ(t), which the swimmer has to choose to realize the optimal path is different for pushers and for pullers (Fig. 2b). Force quadrupolar microswimmers describing small microswimmers with elongated flagella [57,58]), can also be solved using the Lagrangian approach; their swimming trajectories and steering angles are presented in panels (e) and (f), respectively. The resulting parabolic curves are bent towards or away from the wall depending on the sign of the force quadrupole coefficient.
Spherical obstacles and complex landscapes: Based on these results we can now understand why hydrodynamic interactions with obstacles can have a drastic impact on the required navigation strategy to cross an obstacle field fastest. As shown in Fig. 1 without hydrodynamic interactions the agent takes the shortest path (blue curve), whereas a source dipole microswimmer takes qualitatively different path, which depends on the sign of the singularity coefficient. This is because source dipole swimmers with s = 1 (σ > 0) tend to avoid flat walls (red solid lines in Fig. 2c) as well as spherical obstacles (red solid lines in Fig. 3) and are faster when staying at a certain distance to the obstacles. This explains that the red path, which is longer than the blue one, is faster than the blue one for s = 1-source dipole swimmers in Fig. 1. Conversely, swimmers with s = −1 (σ < 0) speed up near flat or spherical walls (green dashed lines in Figs. 2c and 3), which explains why they manage to cross the obstacle field in Fig. 1 faster when following the green trajectory than the shorter blue trajectory. These observations demonstrate that the optimal microswimmer navigation strategy qualitatively differs from the optimal strategy of dry active particles or macroagents.
Fluctuating environments: In the world of microswimmers, fluctuations often play an important role. Besides Brownian noise which significantly displaces small biological microorganisms or active colloids on their way to a target, steering errors (or delay effects [59]) can effectively lead to fluctuations even in larger microswimmers. We now exemplarically consider source dipole microswimmers and set D * := D/ 2 /τ = D/ v 2/3 0 |σ| 1/3 = 0 assuming that D * does not depend on space for simplicity. (Note that accounting for rotational diffusion e.g. to represent imperfect steering, does not qualitatively change the following results.) Let us now compare the following two different navigation strategies: The first one, which we call the "straight swimming strategy" is to steer straight towards the target at each instant of time. An alternative strategy is to re-calculate the optimal path of the underlying noisefree problem at each point in time, using the present position as a starting point, and to steer in the correspondingly determined direction. We refer to this as the "optimal swimming strategy". While the latter strategy is of course expected to be better at weak noise, for strong noise, one might expect the opposite.
However, in our simulations we find that the optimal swimming strategy notably outperforms the straight swimming strategy over the entire considered noise regime (Fig. 4a), i.e. from D * = 0 up to D * ≈ 0.15. Interestingly, the difference between the two strategies increases with the noise strength, such that the choice of the swimming strategy gets more and more important for a microswimmer as fluctuations become important. This finding might be relevant e.g. for microswimmers when trying to reach a food source: they do much better when seeking the proximity of nearby walls first (or getting into some reasonable distance), rather than greedily heading straight towards the target. To understand these observations, let us first consider the case s = −1 where optimal swimming tends to reduce the microswimmer-wall distance and guides the swimmer to locations where hydrodynamic interactions are comparatively important and speed up the swimmer (Fig. 4d,e). Thus, for s = −1 the swimmer can steadily approach the target for comparatively large D * -values. In contrast, when following the straight swimming strategy, nothing stops fluctuations from transferring the swimmer to regions where it is very slow (Fig. 4e). The swimmer is then dominated by noise at comparatively low D * -values and might reach the target only after following a long and winding path.
Let us now discuss the case s = 1, where optimal swimming reduces traveling times over the whole range of explored D * -values, although the above mechanism does not apply, because swimmers slow down when they are close to the wall. To see the strategic advantage of optimal swimming also here, note that when following the straight swimming strategy, fluctuations may accidentally displace the swimmer to locations close to the wall, where it is slow. In contrast, the optimal swimming strategy makes the swimmer stay away from the wall (Fig. 4b,c) and prevents it from getting trapped in regions where it is slow and dominated by noise.
The resulting travel time, monitored as a function of frequency (Fig. 5c), features a sequence of extrema occurring at frequencies where the swimmer reaches the target before completing a full driving cycle. For example, the global minimum corresponds to ω * ≈ π where the swimmer reaches the target at maximum speed without experiencing a phase where the swimmer is slower than its average speed. The travel time also depends nonmonotonously on λ; it features a local minimum around λ = 0.5, where the time-average g 2 (t) is smallest, and a local maximum at λ = 1. To understand the decrease of the travel time for λ > 1, note that for λ > 1 the velocity temporarily changes sign. Since the swimmer can freely steer, it immediately turns and swims forward again with an effective speed of v 0 |1 + λ sin(ωt)|. This leads to an average swimmer speed which increases with λ, yielding the observed decrease of T . These exact results exemplify the complexity of finding the optimal strategy in time-dependent cases and might serve as useful reference calculations to challenge corresponding machine-learning based approaches.
Parameter regimes: Let us now briefly discuss the generic relevance of our results for typical microswimmers. The force dipole coefficient of pushers and pullers is expected to scale as α ∼ a 2 v 0 [64,65] where a is the body size of the microswimmer. Thus, for v 0 ∼ 10 µm/s we have ≈ a. Following Figs. 2b, 3 this means that even at a wall distance of 2 -3 body length, which commonly occurs in the life of many microswimmers, the deviation of the optimal path from the shortest one is significant. These estimates can be specified for E. coli bacteria where the force dipole coefficient has been measured in various experiments and amounts to α = 8 − 75 µm 3 /s [64] yielding = |α|/v 0 ∼ 0.5 − 2 µm for v 0 ∼ 20 µm/s, which again is comparable to the length scale of the swimmer and means that the influence of hydrodynamic wall interactions on the required navigation strategy to reach a target fastest is highly significant. A similar discussion also applies to source dipole microswimmers, where the source dipole coefficient is expected to scale as σ ∼ a 3 v 0 . Regarding the generic relevance of our findings in the presence of noise, let us now estimate the typical value of D * = D/ |σ| 1/3 v 2/3 0 for source dipole swimmers to compare with Fig. 4a. Using σ ∼ a 3 v 0 as well as the Stokes-Einstein relation D = k B T /(6πηa), where η ≈ 10 −3 Pa s is the viscosity of water and k B T is the thermal energy, at room temperature, we obtain D * ∼ 10 −2 − 10 −1 , depending on the size of the considered microswimmer. This roughly coincides with the parameter regime shown in Fig. 4a, which means that typical microswimmers can save a significant fraction of their traveling time to reach a food source or another target lying one or a few body lengths away from a wall, when strategically regulating their distance to the wall rather than greedily heading straight towards the target.

CONCLUSIONS
The message of this work is that, to reach their target fastest, microswimmers require navigation strategies which qualitatively differ from those used to optimize the motion of dry active particles or motile macroagents like airplanes. This finding hinges on hydrodynamic interactions between microswimmers and remote boundaries, which oblige the swimmers to take significant detours to reach their target fastest, even in the absence of external fields. Such strategic detours are particularly useful in the presence of (strong) fluctuations: they effectively protect microswimmers against fluctuations and allow them to reach a food source or another target up to twice faster than when greedily heading straight towards it. This suggests that strategically controlling their distance to remote walls might benefit the survival of motile microorganisms -which serves as an alternative to the common viewpoint, that the microswimmer-wall distance is a direct (i.e. non-actively-regulated) consequence of hydrodynamic interactions. Our results might be relevant for future studies on microswimmers in various complex environments involving hard walls or obstacle landscapes [66][67][68], penetrable boundaries [69,70] or external (viscosity) gradients [71][72][73]. For such scenarios our results (or generalizations based on the same framework) can be used as reference calculations e.g. to test machine learning based approaches to optimal microswimmer navigation [5,6] and perhaps also to help programming navigation systems for future microswimmer generations. They should also serve as a useful ingredient for future works on microswimmer navigation problems in environments which are not globally known but subsequently discovered by the microswimmers. Finally, for future work, it would also be interesting to explicitly solve the Hamilton-Jacobi-Bellman equation for the present problem with noise to compare the discussed navigation strategies which are optimal in the absence of noise and highly useful in the presence of noise, with the optimal navigation strategy following from this equation.

METHODS
Here we discuss details regarding the two approaches used to solve the optimal microswimmer navigation problem based on a Lagrangian approach and on Pontryagin's maximum principle respectively. Both approaches lead to identical results but have been found to be advantageous in different situations: the Lagrangian approach leads to a boundary value problem which is more immediate to implement, numerically simpler and more robust than the corresponding higher-dimensional problem resulting from Pontryagin's principle. The latter in turn allows for solving more general problems applying e.g. also to explicitly time-dependent microswimmers.
Lagrangian approach for source dipole microswimmers: To find the optimal path we write the path connecting the starting point (x * A , z * A ) and the terminal point (x * B , z * B ) as a function z * (x * ) and write the traveling time as Following the Lagrangian optimization approach, a necessary condition for minimizing T * follows from the Euler-Lagrange equation where the Lagrangian, L * , depends on the microswimmer under consideration. First, considering source-dipolar hydrodynamic interactions with a planar interface, an explicit expression for the Lagrangian can readily be obtained. It follows from Eqs. (1) that cos ψ = x * / 1 − s/ 4z * 3 and sin ψ = z * / 1 − s/z * 3 . By enforcing the relation cos 2 ψ + sin 2 ψ = 1 and using the fact thatż * = z * ẋ * with z * = ∂z * /∂x * , the Lagrangian can explicitly be obtained as Inserting this Langrangian into the Euler-Lagrange equation (5) shows that the optimal swimming trajectory is governed by the following second-order differential equation where we have defined the coefficients Equations (7) and (8) subject to Dirichlet boundary condition of imposed vertical distance at the start and end points can readily be solved numerically using a computer algebra software by means of a standard shooting method.
The nature of the roots of the quartic polynomial is primarily determined by the sign of the discriminant [75]. Assuming that z * is a weakly-varying function about the value h > 0, such that z * (x * ) = h + f (x * ), where | | h, the discriminants ∆± of the polynomial function given by Eq. (14) can be expanded to leading order about = 0 as where K is a positive real number. In the far-field limit, we expect that h 2 3/4, and thus ∆± < 0. Accordingly, the polynomial functions has two distinct real roots and two complex conjugate non-real roots [76].
If we denote by r1 and r2 the real roots of P+ then it can readily be noticed that −r1 and −r2 are the real roots of P− since P−(−Z) = P+(Z). Consequently, the system admits two possible Lagrangians, as can be inferred from Eq. (13).
The roots r1 and r2 can be obtained via computer algebra systems. They are not listed here due to their complexity and lengthiness.
Physically, the Lagrangian yielding the shortest traveling time is the one that needs to be considered [7].
Lagrangian approach for force-quadrupolar microswimmers: Finally, we investigate the optimal swimming due to forcequadrupolar hydrodynamic interactions with the interface. In this case, the translational swimming velocities read [56,58] where ν is the force quadrupolar coefficient. In units of = (|ν| /v0) 1/3 and τ = |ν| 1/3 /v 4/3 0 , Eqs. (15) can be expressed in a dimensionless form aṡ where we have used the abbreviation s = sgn(ν). Solving Eq. (16a) for ψ yields three possible distinct values where we have defined for convenience the abbreviations Z = z * 3 /s and E = 27ẋ * Z + f . Moreover, and Substituting the expression of ψ1 given by Eq. (17a) into Eq. (16b), using the fact thatż * = z * ẋ * , and solving the resulting equation forẋ * yields the expression of the Lagrangian where ρ denotes the roots of explicitly-known polynomial of degree 12. In the physical range of parameters, this polynomial admits either one real radical having the order of multiplicity four or three distinct radicals also having the order of multiplicity four. It turned out that the same set of radicals are obtained when making substitution with ψ2 of ψ3. Again, only real values of the steering angle should physically be considered.
In order to proceed further, we evaluate numerically the Lagrangians and accurately fit the results using a standard nonlinear bivariate hypothesis of the form where aij are fitting parameters. Here, we have taken N = 5 but checked that taking larger values does not alter our results.

Hydrodynamic interactions near spherical boundaries:
The translational swimming velocities resulting from source dipolar hydrodynamic interactions with a solid sphere of radius R positioned at the origin of coordinates (see Fig. 6) can be decomposed into two terms withê = cos θn + sin θt denoting the instantaneous orientation angle of the swimmer, and v HI = P sin θt + Q cos θn , quantifies the effect of hydrodynamic interactions with the spherical boundary. This contribution can readily be determined from the Green's function near a rigid sphere [77].
Here, we have defined for convenience where, again, we have scaled lengths by a characteristic length scale of the swimmer L, and velocities by the bulk swimming speed v0. Without loss of generality, we consider motion in the plane y = 0.
To obtain the translational swimming velocities near two obstacles, as illustrated in Fig. 1 a of the main text, we use the commonly-employed superposition approximation [78,79]. The latter conjectures that the solution for the Green's function near two widely-separated obstacles can conveniently be approximated by superimposing the contributions due to each obstacle independently. Accordingly, where v HI i = Pi sin θiti + Qi cos θini , i ∈ {1, 2} .
In addition, cos θ1n1 + sin θ1t1 =:ê1 ≡ê2 := cos θ2n2 + sin θ2t2 . (27) We then project Eq. (25) along the unit vectorst1 andn1 to obtain two scalar equations. Next, we project Eq. (27) along the unit vectorst2 andn2 to obtain two additional equations. Subsequently, the unknown quantities cos θ1, sin θ1, cos θ2, and sin θ2 can be expressed in terms of x, z, and z by solving the resulting linear system of four equations, upon using the fact thatż = z ẋ. By solving the identity cos 2 θ1 + sin 2 θ1 = 1 forẋ, the Lagrangian can then be obtained explicitly as LSD = |ẋ| −1 . The expression of the resulting Lagrangian is rather lengthy and complicated and thus omitted here. Finally, the Euler-Lagrange equation can be solved numerically in Matlab using the ode45 routine.
Optimal control theory for microswimmer navigation: We now use Pontryagin's principle from optimal control theory [1,[61][62][63] as an alterntive approach to solve the optimal navigation problem for microswimmers. While the Lagrangian approach is numerically rather convenient for the present set of problems, Pontryagin's approach provides a more general framework to determine optimal microswimmer trajectories. In particular, it allows us to discuss optimal trajectories in higher spatial dimensions or to calculate the optimal path for microswimmers with a time-dependent propulsion speed as we discuss now.
Let us consider the cost J[r(t), p(t), ψ(t), t] = T which we want to minimize subject to the equations of motion for microswimmers interacting with remote walls (Eqs. (1)) and the boundary conditions r(t = 0) = rA and r(t = T ) = rB where r := (x, z). Here ψ is the control variable, p is the costate and T is the (unknown) traveling time corresponding to the fastest route. As the cost can be determined from the endpoint (or the "endtime") alone it can be considered as a pure endpoint cost, whereas the running cost is zero. Allowing for explicitly time-dependent microswimmers with a time-dependent source dipole strength σt and/or a time-dependent self-propulsion speed vt, this is a nonautonomous, fixed endpoint, free endtime optimal control problem. To solve it we first construct the optimal control Hamiltonian as H(r, p, ψ, t) = F · p where F is given byṙ = [vt − σt/ 4z 3 ] cos ψ, [vt − σt/z 3 ] sin ψ =: F . We now minimize H with respect to the (unconstrained) control variable ψ by solving ∂ ψ H = 0 yielding tan ψ * = uz/ux where ψ * is the optimal control and where we have defined ux := px(vt − σt/(4z 3 )) and uz = pz(vt − σt/z 3 ). Using H(r, p, t) ≡ H(r, p, ψ * , t), after a few lines of straightforward algebra, we obtain the minimized (lower) Hamiltonian as H(r, p, t) = ± √ u 2 x + u 2 z . In the following we use only the plus-branch, as the minus-branch does not seem to result in sensible trajectories. The optimal trajectory now follows from the Hamilton equations of motionṙ = ∂pH andṗ = −∂rH which have to be solved as a boundary value problem, such that r(t = 0) = rA and r(t = T ) = rB where T is the unknown traveling time. Thus, up to now, we have determined four first order differential equations which are complemented by four boundary conditions. Since this problem depends on the unknown T , we need one additional boundary condition. This is given by the Hamiltonian endpoint condition (or transversality condition) which determines the value of H(r(T ), p(T ), T ). This condition can be determined from the endpoint LagrangianL = T + ν · e where T is again the endpoint cost; ν is the (constant) endpoint costate and e = (r(T ) − rB) (such that e = 0 represents the boundary conditions in standardized form). The Hamiltonian endpoint condition simply yields H(r(T ), p(T ), T ) = −∂TL = −1 for the considerd minimal time problem. (The remaining two transversality conditions for the costate, p(T ) = −∂ r(T )L , just relate the two unknowns p(T ) to two other unknowns ν and hence do not provide any additional information.) To numerically solve the Hamilton equations together with r(0) = rA, r(T ) = rB and H(r(T ), p(T ), T ) = −1, it is convenient to rescale time via t = T t such that, in primed units, the terminal time is T = 1 and the endpoint boundary conditions are explicitly known as r(t = 1) = rB; i.e. they no longer depend on the unknown variable T , which instead shows up in the equations of motion. In addition, to ease the usage of standard shooting methods to solve this boundary value problem, it is convenient to treat T as a dynamical variable, i.e. we introduce T =: a(t), leading to the additional equation of motionȧ = 0, which we solve together with the Hamilton equations and the five mentioned boundary conditions. We have compared the results from this approach for time-independent microswimmers in the presence of flat walls with those from the Lagrangian approach and find the same trajectories. For time-dependent microswimmers corresponding new results are presented in the main text. Let us finally mention that an alternative approach to treat the present non-autonomous optimal control problem would be to first transform it to an autonomous problem, by introducing an extra variableτ = 1 with τ (t = 0) = 0 such that τ (t) = t. The corresponding approach leads to the same numerical results to those presented in Fig. 5.

DATA AVAILABILITY
The data that support the findings of this study are available from the authors upon reasonable request.

CODE AVAILABILITY
The code that supports the findings of this study are available from the authors upon reasonable request.  1. (a) Optimal microswimmer navigation versus conventional optimal navigation in the presence of two spherical obstacles (shown in gray): Curves represent optimal trajectories for microswimmers (red and green) and for a dry active particle (blue), i.e., in the absence of hydrodynamic interactions (HIs) with obstacles. The swimmers are micron sized and the swimming trajectories are assumed to take place in the plane passing through the centers of the spherical obstacles. Here, σ is the source dipole coefficient and x, z are spatial coordinates. Panels (b),(c) show the flow field streamlines induced by a source dipole at position r = (−3, 3) µm in the presence of a spherical obstacle with radius R = 3 µm. Black arrows indicate the orientation of the swimmers. The fluid-mediated hydrodynamic interactions with the spherical boundary induce a deceleration of the swimming agent for σ > 0 leading to larger speeds as the swimmer gets away from the obstacle. In contrast to that, hydrodynamic interactions cause an acceleration for σ < 0 yielding an increased speed near the obstacle.