2

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).$$enter image description here

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) .

1 Answers1

6

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[[1]], x /. xsol[[2]], x /. xsol[[3]]} /. 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[[2]] // 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[%]

enter image description here

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] == 0, 
   y'[0] == 0}, y[x], x] // Flatten
(*{y[x] -> 1/16 (4 - x)^2 - 2 Log[4 - x] - 1 + 2 Log[4]}*)

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[256])*)

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

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

x[t_] = x /. xsol[[7]] /. C[1] -> 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[%]

enter image description here

Bill Watts
  • 8,217
  • 1
  • 11
  • 28
  • 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.
    516018465414117937334032172422179188968979686041410^-25 I})][1]][1]

    – Милош Вучковић Nov 30 '18 at 08: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 '18 at 08: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. – Bill Watts Nov 30 '18 at 08:32
  • For x[tf] i get "4.852374710896211993637706194468270774527875582293 + 1.014650559459759538310943372442507445118422063960 I"" and then blank graphic animation – Милош Вучковић Nov 30 '18 at 08:35
  • A smaller working precision might help, but I had trouble finding a good starting value with the default. The one I did find was obviously the right one, because everything works from there. Also, a different version might have xsol values in a different order than mine, so you may need to check that. – Bill Watts Nov 30 '18 at 08:38
  • Ye, i found FindRoot[x[t] - 4, {t, 2.6666666665}, WorkingPrecision -> 50] [! [(*{t[Rule]2.6666666666666666666666658431852893864326289409482-1.
    516018465414117937334032172422179188968979686041410^-25 I})][1]][1] , its work now , TNX ! :)
    – Милош Вучковић Nov 30 '18 at 08:48
  • I have now included in my post how I chose whichxsol to use. Your version may list a different order so you may need to use a different one. – Bill Watts Nov 30 '18 at 08:49
  • 1
    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. – Bill Watts Nov 30 '18 at 09:57
  • Hello mate. I need finish my finall master rexam on my university. Till friday i need give on teacher's my project after 5 weeks i am formal defending it. I rly would like to put your annimation in my project (i noticed there that is your CODE for animation) but problem is SOLUTION which i wrote here is WRONG . After when i checked in mathematica DSolve[{2*Sqrt[1 + (y'[x])^2] == 2 (4 - x) y''[x], y[0] == 0, y'[0] == 0}, y[x], x]

    I get another solution , {{y[x] -> -1 + 1/16 (4 - x)^2 + 2 Log[4] - 2 Log[4 - x]}} .

    – Милош Вучковић Dec 12 '18 at 14:24
  • How i see from that solution y[4]-> \infity , so cat never catch mouse :/ . Can you please make me that new animation, I am student of math, i rly would like to have this animation for my defending on project but i havent enough of knowledge in mathematica to make that animation.

    I will mention you in my project work.

    – Милош Вучковић Dec 12 '18 at 14:24
  • OK, I have updated the answer. See if that works for you. – Bill Watts Dec 12 '18 at 20:31
  • Are you sure this second case is correct? When I integrate over the cat's curve, I get the distance the cat travels is 4 rather than 8 as would be the case if the cat's speed were twice the mouse's. – Bill Watts Dec 12 '18 at 21:14
  • Check your equations again. When I work the problem from scratch, I match your first answer when the cat goes twice the mouse speed. The second case is for the cat going the same speed as the mouse. – Bill Watts Dec 12 '18 at 23:35
  • I am totally confused now, do i make something wrong before i get till my last differential equation with that conditional initial ? Logicaly like you tell , in sqare A x A , mice will make past way A and cat like 2x times faster will make 2A, but question is will cat cath mouse ? At differential equation, we ssee it wont but problem is probably that cat will be too hot to catch mouse what is not case in second one :D ? I am gues that on animation probably need be like mouse almost on point (4,4) catch cat but it didnt make :/ – Милош Вучковић Dec 13 '18 at 02:57
  • http://mymathforum.com/calculus/1765-cat-chases-mouse.html look this , it tees that this is standard aplication of differential equations – Милош Вучковић Dec 13 '18 at 03:04
  • In your differential equation, there should not be a 2 in front of the square root. Fix that and you will reproduce the first case. – Bill Watts Dec 13 '18 at 03:30
  • I checked it, totally clear now, answer one is right , i will also edite my question, you can delete second case, tnx again much, i will mention you in my finally exam project work ! :) – Милош Вучковић Dec 13 '18 at 03:51
  • You also need to edit the line after Cauchy Problem. – Bill Watts Dec 13 '18 at 20:12