Four bugs on corners of a rectangle are standing at positions
The following diagram shows the initial positions of all four bugs and what happens after
The four bugs are initially located at corners of rectangle. The width is
We see that at each instance of time, each bug remains at the corner of a scaled down parallelogram version of the original rectangle, which is rotating and the bug’s velocity is straight toward the bug position it is chasing. What this means is that bug 1 motion is always at
To obtain the equation of motion for each bug, we will look at each bug’s position relative to the bug it is chasing. Starting with bug 1 relative to bug 2 with the help of the following diagram
The position vector of bug 1 is
But since
Where
The same analysis is now done to obtain
The position vector of bug 2 is
Since
Where
By doing the above again for bug 3 and bug 4, it is clear the result will be similar. The final equations of motions in vector form are
With initial conditions
We can not write this as
This problem was also solved for a square instead of a rectangle. The only change needed was to make the initial conditions as follows
The time needed to reach the center in this case is one second.
These animations will play in HTML only
![]() |
![]() |
![]() |
Code for animation is
ClearAll[t, x1, x2, x3, x4, y1, y2, y3, y4]; ode1 = x1'[t] == (x2[t] - x1[t])/ Sqrt[(x2[t] - x1[t])^2 + (y2[t] - y1[t])^2]; ode2 = y1'[t] == (y2[t] - y1[t])/ Sqrt[(x2[t] - x1[t])^2 + (y2[t] - y1[t])^2]; ode3 = x2'[t] == (x3[t] - x2[t])/ Sqrt[(x3[t] - x2[t])^2 + (y3[t] - y2[t])^2]; ode4 = y2'[t] == (y3[t] - y2[t])/ Sqrt[(x3[t] - x2[t])^2 + (y3[t] - y2[t])^2]; ode5 = x3'[t] == (x4[t] - x3[t])/ Sqrt[(x4[t] - x3[t])^2 + (y4[t] - y3[t])^2]; ode6 = y3'[t] == (y4[t] - y3[t])/ Sqrt[(x4[t] - x3[t])^2 + (y4[t] - y3[t])^2]; ode7 = x4'[t] == (x1[t] - x4[t])/ Sqrt[(x1[t] - x4[t])^2 + (y1[t] - y4[t])^2]; ode8 = y4'[t] == (y1[t] - y4[t])/ Sqrt[(x1[t] - x4[t])^2 + (y1[t] - y4[t])^2]; sol = NDSolve[{ode1, ode2, ode3, ode4, ode5, ode6, ode7, ode8, x1[0] == 0, y1[0] == 0, x2[0] == 0, y2[0] == 1, x3[0] == 1, y3[0] == 1, x4[0] == 1, y4[0] == 0}, {x1[t], y1[t], x2[t], y2[t], x3[t], y3[t], x4[t], y4[t]}, {t, 0, 1}]; Manipulate[ p1 = ParametricPlot[{x1[t], y1[t]} /. sol, {t, 0, tMax}, AxesOrigin -> {0, 0}, GridLines -> Automatic, GridLinesStyle -> LightGray, Frame -> True, FrameLabel -> {{"y", None}, {"x", None}}, ImageSize -> 350, PlotStyle -> Red] /. Line[x_] :> {Arrowheads[.04], Arrow[x]}; p2 = ParametricPlot[{x2[t], y2[t]} /. sol, {t, 0, tMax}, AxesOrigin -> {0, 0}, GridLines -> Automatic, GridLinesStyle -> LightGray, Frame -> True, FrameLabel -> {{"y", None}, {"x", None}}, ImageSize -> 350, PlotStyle -> Blue] /. Line[x_] :> {Arrowheads[.04], Arrow[x]}; p3 = ParametricPlot[{x3[t], y3[t]} /. sol, {t, 0, tMax}, AxesOrigin -> {0, 0}, GridLines -> Automatic, GridLinesStyle -> LightGray, Frame -> True, FrameLabel -> {{"y", None}, {"x", None}}, ImageSize -> 350, PlotStyle -> Black] /. Line[x_] :> {Arrowheads[.04], Arrow[x]}; p4 = ParametricPlot[{x4[t], y4[t]} /. sol, {t, 0, tMax}, AxesOrigin -> {0, 0}, GridLines -> Automatic, GridLinesStyle -> LightGray, Frame -> True, FrameLabel -> {{"y", None}, {"x", None}}, ImageSize -> 350, PlotStyle -> Green] /. Line[x_] :> {Arrowheads[.04], Arrow[x]}; Show[p1, p2, p3, p4, PlotRange -> {{0, 1}, {0, 1}}, PlotLabel -> Column[{"Solution to the 4 bugs on corner problem", "On (0,0),(1,1) square"}], BaseStyle -> 12, ImageSize -> 300], {{tMax, .01, "time"}, .01, 1, .01, Appearance -> "Labeled"} ]