# Cat catch mouse , application of differentials equations [closed]

Can anyone help me with this:

We have a room 4 metres deep and 4 metres wide. In the far right corner is a mousehole. The cat starts in the bottom left corner, and the mouse starts in the top left corner i.e. cat starts at (0,0) and mouse at (0,4), and the mouse hole is at (4,4).

The cat starts to chase the mouse and always runs directly at the mouse. The mouse runs straight for the hole i.e. along the top wall from (0,4) towards (4,4).

The cat has a constant speed, so too does the mouse. Cat speed is 2x faster than mouse .

Questions: Will cat catch the mouse, before mouse get away ?

I will ilustrate solving step by step manualy

1. $$y=y(x)$$ equations of curve (cat route way )

In moment $$x_0$$ cat made pass way : $$l(x_0)=\int_{0}^{x_0} \sqrt{1+(y'(s))^2} ds.$$

Mouse way is on tanget's of curve $$y=y(x)$$ , equation of that tanget is $$p(x)-y(x_0)=y'(x_0)(x-x_0).$$

So coordinates of mouse are $$\left(4,y(x_0)+y'(x_0)(4-x_0)\right),$$ from it we get $$\int_{0}^{x} \sqrt{1+(y'(s))^2} ds=2\left(y(x)+y'(x)(4-x)\right).$$ $$\sqrt{1+(y'(x))^2}=2(4-x)y''(x).$$

We need solve Cauchy problem

$$\left\{\begin{array}{rcl} 2\sqrt{1+(y'(x))^2}&=&2(4-x)y''(x), \\ y(0)&=&0,\\ y'(0)&=&0 \end{array}\right.$$

When we solve it we get

$$y(x)=\frac{1}{6} \left(-\sqrt{4-x} x-8 \sqrt{4-x}+16\right)$$,$$y(x)=\frac{1}{6} (-16 + 8\sqrt{4 - x} + \sqrt{4 - x} x).$$ My question here for Mathematica is next:

Have anyone idea how to make manipulate that i see on graph cat-mouse moving, so with that manipulate I can see the moment and when cat catch mouse etc.

I wrote for my Student research project this and now i need as much as can to involve here Mathematica (so give some idea if you have for plotting , manipulate plot etc) .

• This is similar to the mice problem, which was previously solved here. Nov 30, 2018 at 10:02
• People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful Dec 15, 2018 at 22:14

This case is valid for the cat running twice as fast as the mouse. The equation for y

y[x_] = 1/6 (-Sqrt[4 - x] x - 8 Sqrt[4 - x] + 16)


Call the mouse velocity 1

v = 1


Find x as a function of t from

txeq = v t == y[x] + y'[x] (4 - x) // Simplify;

xsol = Solve[%, x] // Flatten // Simplify;

{x /. xsol[], x /. xsol[], x /. xsol[]} /. t -> .1
(*{17.9 - 7.51202 I, 0.199978 - 7.77156*10^-16 I, 17.9 + 7.51202 I}*)


The second one is the Real one.

x[t_] = x /. xsol[] // FullSimplify


Now find the time the cat hits the wall at x = 4

Solve[txeq, t] // Flatten
(*{t -> (-x^2 + 20 x + 32 Sqrt[4 - x] - 64)/(12 Sqrt[4 - x])}*)

tf = Limit[t /. %, x -> 4]
(*8/3*)


Check

x[tf] // N[#, 20] &
(*4.0000000000000000000 + 0.*10^-20 I*)


ok

gifs = Table[
ParametricPlot[{{x[t], y[x[t]] // Chop}, {4, v t}}, {t, .001, ti},
PlotRange -> {{0, 4}, {0, 4}}, PlotStyle -> Thickness[.02]], {ti,
0, tf, tf/50}];
ListAnimate[%] Update While no longer applying to the original question, I will leave the results here as it is valid for the case where the cat runs with the same speed as the mouse.

The equation for y[x]

DSolve[{2 Sqrt[1 + y'[x]^2] == 2 (4 - x) y''[x], y == 0,
y' == 0}, y[x], x] // Flatten
(*{y[x] -> 1/16 (4 - x)^2 - 2 Log[4 - x] - 1 + 2 Log}*)

y[x_] = y[x] /. %;


Again, set the mouse velocity to be 1

v = 1;


The mouse y position is v t and the cat is running toward it, so get x as a function of t from:

txeq = v t == y[x] + y'[x] (4 - x) // Simplify
(*16 t + x^2 + 32 Log[4 - x] == 8 (x + Log)*)

xsol = Solve[txeq, x] // Flatten // Simplify;


Lots of conditional answers. After considerable experimentation to find the real solution, I get.

x[t_] = x /. xsol[] /. C -> 0 // FullSimplify[#, t >= 0] &
(*4 - 4 Sqrt[ProductLog[E^(1 - t)]]*)


The total time is the time the mouse gets to the hole since in this case the cat never catches up.

v tf == 4

tf = 4


The x distance the cat gets to when the mouse gets to the hole.

x[tf] // N
(*3.12842*)

gifs = Table[
ParametricPlot[{{x[t], y[x[t]]}, {4, v t}}, {t, .0001, ti},
PlotRange -> {{0, 4.1}, {0, 4.1}}, PlotStyle -> Thickness[.02],
Epilog -> {PointSize[.02], Point[{4, 4}]}], {ti, 0, tf, tf/50}];
ListAnimate[%] • Oh, this is great, just got one question , at my version 11.2 i get stuck at FindRoot[x[t] - 4, {t, 2.6666}, WorkingPrecision -> 50] [! [({t[Rule]2.6666666666666666666666658431852893864326289409482-1.\ 5160184654141179373340321724221791889689796860414*10^-25 I})]] Nov 30, 2018 at 8:24
• FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations. {t -> 2.3032255851278500802607111037823097583967618767776 + 1.0104347127048801144762023061399471150405610005790 I} I think its probably mistake at "Find x as a function of t from " v t == y[x] + y'[x] (4 - x) // Simplify ? Nov 30, 2018 at 8:27
• I had to play around with starting values to find the right one. M8 was different than 11.3, but I found the right one eventually with each of them. Evidently this FindRoot problem is very sensitive to starting values. Keep trying. Nov 30, 2018 at 8:32
• For x[tf] i get "4.852374710896211993637706194468270774527875582293 + 1.014650559459759538310943372442507445118422063960 I"" and then blank graphic animation Nov 30, 2018 at 8:35
• An earlier equation which I labeled txeq is a much easier way to solve for tf, so I have taken FindRoot out of the calculation. I should have seen it before. Nov 30, 2018 at 9:57