Solving ODE with Runge-Kutta method and automatic differentiation.
Assume N birds flying in swarms. Let x be positon of i-th birds, and v0 be preferred speed. Newton's equation of each bird is
where
V is Mexican-hat potential and f expresses preferred distance between birds, whereas g aligns their velocity with that of neighborhood.
Gros C.(2015). Complex and adaptive dynamical systems , Springer