# Snail Problem, Part 5

I hope no one is tired of snails yet. In the last several posts, I tackled the following problem: a snail crawls along a twig of length L0 at 1 cm/d, and the twig grows (along its entire length) at 2 cm/d. Will the snail reach the end, and when? In parts 1, 2, and 3, I solved this problem, and then in part 4 I turned to the general case, leaving the snail’s velocity and twig growth velocity unspecified.

We found that the snail’s position, x, can be given by the following equation, where g is the growth rate of the twig, s is the (inherent) velocity of the snail, and t is the time:

$\displaystyle x = \frac{s}{g}(gt+L_0)\ln\frac{gt+L_0}{L_0}.$

We want to find the time t where the snail reaches the end of the twig. Since the length of the twig is gt+L0, we set x equal to this.

$\displaystyle x = gt+L_0$

Substituting our equation for x gives

$\displaystyle \frac{s}{g}(gt+L_0)\ln\frac{gt+L_0}{L_0}=gt+L_0$.

To solve this for t, we start by dividing both sides by gt+L0 (note that this is the twig length, and is only applicable for nonzero twig lengths).

$\displaystyle \frac{s}{g}\ln\frac{gt+L_0}{L_0}=1$

We can multiply both sides by g/s (note that the snail velocity cannot be zero).

$\displaystyle \ln\frac{gt+L_0}{L_0}=\frac{g}{s}$

Exponentiating both sides gives

$\displaystyle e^{\ln\frac{gt+L_0}{L_0}}=e^{\frac{g}{s}}$

$\displaystyle \frac{gt+L_0}{L_0}=e^{\frac{g}{s}}$

$\displaystyle gt+L_0 = L_0 e^{\frac{g}{s}}$

$\displaystyle gt = L_0 e^{\frac{g}{s}}-L_0$

$\displaystyle gt = L_0(e^{\frac{g}{s}}-1)$

And finally, the time is

$\displaystyle t_f = \frac{L_0}{g}\left(e^{g/s}-1\right) \blacksquare$

So the time it takes is the initial length of the twig divided by its growth rate (which incidentally is the amount of time it would have taken to grow to its start position) times the quantity e to the power of the ratio of the twig and snail rates minus 1.

Interestingly, this will be finite no matter how small s is. If the snail is extremely slow, then the exponent g/s will be very large, but as long as s is positive, the snail will eventually reach the end of the twig — no matter how fast the twig grows!

Let’s also see how long the twig will be when the snail reaches the end. Recall that the length of the twig is

$\displaystyle L(t) = gt+L_0$

We can substitute our time above in for t:

$\displaystyle L(t_f) = g\left[\frac{L_0}{g}\left(e^{g/s}-1\right)\right] +L_0$

$\displaystyle L(t_f) = L_0\left(e^{g/s}-1\right)+L_0$

$\displaystyle L(t_f) = L_0\left[(e^{g/s}-1)+1\right]$

And finally, the length is

$\displaystyle L(t_f) = L_0 e^{g/s}\, \blacksquare$

# Snail Problem, Part 4

In the last three posts (see Snail Problem parts 1, 2, and 3), I tackled the following problem: a snail crawls along a twig of length L0 at 1 cm/d, and the twig grows 2 cm/d. Will the snail reach the end, and when?

The answer is yes, and it will reach the end in

$\displaystyle t = (e^2-1)\cdot\frac{L_0}{2}.$

I’m interested in solving this now for the general case, leaving the twig growth and snail velocities unspecified. Fellow blogger Ken Roberts has already solved this, but I still want to try my hand at it. I’ll follow his example and use g for the growth rate of the twig (I’m already using t for time), s for the inherent velocity of the snail, and I’ll continue using L0 for the initial length of the twig (and L for its length at any time).

The length of the twig L is

$\displaystyle L(t)= gt+L_0$,

since it grows at g cm/d and its grown for t days. The velocity at any point x is length is the fraction of the length of the twig,

$\displaystyle \frac{x}{L(t)} = \frac{x}{gt + L_0}$

times the twig’s overall growth rate, g:

$\displaystyle \frac{gx}{gt + L_0}$.

The net velocity v of the snail is the sum of the growth of the twig at that point (which we just calculated) and its own inherent velocity, s:

$\displaystyle v = \frac{gx}{gt + L_0} + s$

Of course, v is the derivative of the snail’s position x with respect to time. Remember that L0, g, and s are constants.

$\displaystyle \frac{dx}{dt} = \frac{gx}{gt + L_0} + s$

This is a linear first-order differential equation.

$\displaystyle \frac{dx}{dt} - \frac{g}{gt + L_0}x = s$

The way to solve this is to multiply by the following integrating factor (see part 2 for an explanation):

$\displaystyle \mu(t) = e^{\int \left(-\frac{g}{gt + L_0}\right) \,dt}$

$\displaystyle \mu(t) = e^{-\int g\cdot\frac{1}{gt + L_0}\,dt}$

$\displaystyle \mu(t) = e^{-\ln|gt+L_0| + c_1}$

I actually might prefer doing this the other way (the longer method from the previous post), since integrating inside an exponent is inconvenient. Using sum and product rules for exponents:

$\displaystyle \mu(t) = e^{c_1}{\left(e^{ln |gt+L_0|}\right)}^{-1}$

$\displaystyle \mu(t) = c_2(gt+L_0)^{-1}$

I got rid of the absolute value because the quantity gt + L0 will always be positive, since it’s the length of the twig. And more generally, we can select a quantity for the constant that would have the appropriate sign. We just need one possible solution for this integrating factor, so I’ll select the one where the constant is equal to one.

$\displaystyle \mu(t) = (gt+L_0)^{-1}$

Now we take this and multiply it by our prior differential equation.

$\displaystyle (gt+L_0)^{-1}\left(\frac{dx}{dt} - \frac{g}{gt + L_0}x\right) = (gt+L_0)^{-1}s$

$\displaystyle (gt+L_0)^{-1}\frac{dx}{dt}-g(gt+L_0)^{-2}x = \frac{s}{gt+L_0}$

The whole point of this diversion was to get the left side of the equation into a form that is the inverse of the product rule.

$\displaystyle \frac{d}{dt}\left[(gt+L_0)^{-1}x\right] = \frac{s}{gt+L_0}$

Integrating both sides with respect to t gives

$\displaystyle (gt+L_0)^{-1}x = \int\frac{s}{gt+L_0}\,dt$

$\displaystyle (gt+L_0)^{-1}x = s\int\frac{1}{gt+L_0}\,dt$

We need to set up the inverse of the chain rule.

$\displaystyle (gt+L_0)^{-1}x = \frac{s}{g}\int\frac{g}{gt+L_0}\,dt$

$\displaystyle (gt+L_0)^{-1}x = \frac{s}{g}\left(\ln|gt+L_0| + c_3\right)$

We can multiply through by s/g, and define a new constant. Also, I’ll remove the absolute value, since I’m only interested in positive t.

$\displaystyle (gt+L_0)^{-1}x=\frac{s}{g}\ln(gt+L_0) + c_4$

$\displaystyle x = \left[\frac{s}{g}\ln(gt+L_0) + c_4\right](gt+L_0)$

We can find the constant by noting that when t=0, x=0:

$\displaystyle 0 = \left(\frac{s}{g}\ln L_0 + c_4\right)(L_0)$

Dividing both sides by L0 gives

$\displaystyle 0 = \frac{s}{g}\ln L_0 + c_4$

$\displaystyle c_4 = -\frac{s\ln L_0}{g}$

Substituting this back into our equation for x:

$\displaystyle x = \left[\frac{s}{g}\ln(gt+L_0) -\frac{s\ln L_0}{g}\right](gt+L_0)$

$\displaystyle x = \frac{s}{g}\left[\ln(gt+L_0)-\ln L_0\right](gt+L_0)$

Let’s combine the natural logarithms and rearrange the terms for clarity:

$\displaystyle x= \frac {s}{g}(gt+L_0)\ln\frac{gt+L_0}{L_0}$

That’s it! Noting that the quantity gt+L0 represents the current twig length, L, we can say that

$\displaystyle x = \frac{s}{g}L\ln\frac{L}{L_0}$.

In other words, at any given time, the position of the snail is equal to the ratio of the snail’s inherent velocity to the twig growth velocity times the current twig length times the natural logarithm of the ratio of the twig’s current length to its original length. Keeping it in this form, using the general case rather than s=1 and g=2, certainly makes the formula more intuitive. I’ll solve for the time it takes to reach the end of the twig in the next post.

# Snail Problem, Part 3

This is a continuation of my attempt to solve the following problem: A snail crawls along a twig of length L0 at 1 cm/d, and the twig grows (along its entire length) at 2 cm/d. Will the snail reach the end, and when? You can see part 1 where I successfully set up the differential equation and unsuccessfully tried to solve it, and part 2 where I did manage to solve it.

At the end of the last post, I had solved for the equation that describes the position of the snail over time,

$\displaystyle x = \left(t+\frac{L_0}{2}\right)\ln\left(\frac{2t}{L_0}+1\right)$.

Also, recall that the length of the twig is

$\displaystyle L = 2t + L_0$

since it grows at 2 cm/d. We want to find the time t when these two are equal.

$\displaystyle 2t + L_0 = \left(t+\frac{L_0}{2}\right)\ln\left(\frac{2t}{L_0}+1\right)$

[Edit: I missed a very obvious step at this point, so the next few steps will be unhelpful. Free free to skip ahead to the next edit.] We need to isolate the natural logarithm.

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = \frac{2t+L_0}{t+\frac{L_0}{2}}$

Exponentiating both sides gives

$\displaystyle e^{\ln\left(\frac{2t}{L_0}+1\right)} = e^{\frac{2t+L_0}{t+\frac{L_0}{2}}}$

$\displaystyle \frac{2t}{L_0}+1 = e^{(2t+L_0)(t+\frac{L_0}{2})^{-1}}$

Well, the left side is great, but the right side is a mess.

$\displaystyle \frac{2t}{L_0}+1 = \left[e^{(t+\frac{L_0}{2})^{-1}}\right]^{(2t+L_0)}$

If I bring the 2tL0 term out, I could split it up.

$\displaystyle \frac{2t}{L_0}+1 = \left[e^{(t+\frac{L_0}{2})^{-1}}\right]^{(2t+L_0)}$

$\displaystyle \frac{2t}{L_0}+1 = \left[e^{(t+\frac{L_0}{2})^{-1}}\right]^{2t}\left[e^{(t+\frac{L_0}{2})^{-1}}\right]^{L_0}$

This was unhelpful and I have no idea how to simplify this.

[Edit: At this point I get back on track.] Let’s go back to the last simple equation.

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = \frac{2t+L_0}{t+\frac{L_0}{2}}$

I should get rid of this complex fraction, even if it means making the numerator more complex.

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = \frac{2t+L_0}{t+\frac{L_0}{2}}\cdot\frac{2}{2}$

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = \frac{4t+2L_0}{2t+L_0}$

Oh, it’s so obvious now. I don’t know how I missed realizing that this fraction would simplify.

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = \frac{2(2t+L_0)}{2t+L_0}$

$\displaystyle \ln\left(\frac{2t}{L_0}+1\right) = 2$

I feel a bit foolish. Now, let’s exponentiate both sides.

$\displaystyle e^{\ln\left(\frac{2t}{L_0}+1\right)} = e^2$

That’s much simpler.

$\displaystyle \frac{2t}{L_0}+1 = e^2$

$\displaystyle \frac{2t}{L_0} = e^2 - 1$

$\displaystyle t = (e^2-1)\cdot\frac{L_0}{2}$.

Here are my initial observations: It seems “elegant” enough to be a solution to this problem. I like that it depends on e. I also notice that the time it takes is directly proportional to the initial length of the twig. I’m a bit surprised, as the snail’s net speed is not constant but rather increases as it progresses. Also, it’s apparent in retrospect that the first factor, $\left(t+\frac{L_0}{2}\right)$ in the equation for the snail’s position over time,

$\displaystyle x = \left(t+\frac{L_0}{2}\right)\ln\left(\frac{2t}{L_0}+1\right)$,

is half the length of the twig at that time, L(t):

$\displaystyle x(t) = \frac{1}{2}L(t)\ln\left(\frac{2t}{L_0}+1\right)$.

I don’t have an intuitive understanding of what the other quantity could represent, nor do I know if the 2 and 1 have any connection to the twig growth and snail inherent velocity. It would be interesting to repeat this but leave all the quantities unspecified.

# Snail Problem, Part 2

I read through some more of my college differential equations textbook and I think I am ready to further tackle the snail problem (see yesterday’s post). In short, a snail crawls along a twig of length L0 at 1 cm/d, and the twig grows 2 cm/d. Will the snail reach the end, and when?

I got as far as this differential equation, which I believe is correct:

$\displaystyle \frac{dx}{dt} = \frac{2x}{2t + L_0} + 1$

I read about a technique to solve linear first-order differential equations last night, so I’m going to try it here. First we put this into standard form:

$\displaystyle \frac{dx}{dt} -\frac{2}{2t + L_0}\cdot x = 1.$

Since we already have an x’ and an x, if only they were multiplied by another function μ and μ’ respectively, we would have an inverse of the product rule (μx)’ = (μx’ + μ’x). Of course we can’t multiply different parts of the equation by different functions; we’ll have to multiply the entire equation by the same function μ(t). This will put a μ term in front of the x’, so we have to select a μ that, when multiplied by the function in the second term, will result in μ’. Let’s take a detour to find this function.

$\displaystyle \mu' = \mu\left( -\frac{2}{2t + L_0} \right)$

This is a separable differential equation; we can get the μ terms on one side and the t terms on the other. (Incidentally, I don’t think we could have done that with the original equation, or I would have.)

$\displaystyle \frac{d\mu}{dt} = \mu\left( -\frac{2}{2t + L_0} \right)$

$\displaystyle \frac{1}{\mu}\,d\mu = -\frac{2}{2t+L_0}\,dt$

I just realized we divided both sides by μ. I hope that was “allowed.” Of course we would have lost any solutions where μ = 0, though I’m not sure of the significance of that. In any case, I can’t stop now. Let’s integrate:

$\displaystyle \int \frac{1}{\mu}\,d\mu = \int \left( -\frac{2}{2t+L_0} \right) \,dt$

The left side is easy; it’s a standard rule.

$\displaystyle \ln |\mu|= \int \left( -\frac{2}{2t+L_0} \right) \,dt$

The right side is essentially the same; we need to use the inverse of the chain rule.

$\displaystyle \ln |\mu| = - \int \left( \frac{1}{2t+L_0} \right) (2) \,dt$

$\displaystyle \ln |\mu| = - \ln | 2t+L_0 | + c_1$

Exponentiating both sides yields

$\displaystyle e^{ \ln |\mu| } = e^{- \ln | 2t+L_0 | + c_1}$

$\displaystyle |\mu| = {e^{c_1}} {\left( e^{ln |2t+L_0|} \right)}^{-1}$

Setting $c_2 := e^{c_1}$

$\displaystyle |\mu| = c_2 {|2t+L_0|}^{-1}$

$\displaystyle \mu = \pm \frac{c_2}{2t+L_0}$

I think we can absorb the ± into the constant (though I’m not positive).

$\displaystyle \mu = \frac{c_3}{2t+L_0}$

Actually, we need a solution, not all solutions, so I’ll set the constant equal to 1. So dropping the ± was fine.

$\displaystyle \mu = {(2t+L_0)}^{-1}$

Armed with μ, we should now be ready to return to our earlier work. We’ll take our previous equation, in standard form,

$\displaystyle \frac{dx}{dt} -\frac{2}{2t + L_0}\cdot x = 1$

and multiply both sides by the function μ:

$\displaystyle {(2t+L_0)}^{-1} \cdot \frac{dx}{dt} - 2{(2t + L_0)}^{-2} \cdot x = {(2t+L_0)}^{-1}$

We should now be able to a use the inverse of the product rule.

$\displaystyle \frac{d}{dt} \left[{(2t+L_0)}^{-1} x \right] = {(2t+L_0)}^{-1}$

Integrating both sides gives

$\displaystyle {(2t+L_0)}^{-1} x = \int {(2t+L_0)}^{-1}\,dt$

We’ll need to use the inverse of the chain rule again, so let’s set it up.

$\displaystyle \frac{x}{2t+L_0} = \frac{1}{2}\int 2{(2t+L_0)}^{-1}\,dt$

$\displaystyle \frac{x}{2t+L_0} = \frac{1}{2} \left(\ln |2t+L_0| + c_4\right)$

$\displaystyle \frac{x}{2t+L_0} = \frac{ \ln |2t+L_0|}{2} + c_5$

Multiplying both sides by 2tL0 gives

$\displaystyle x = \left( \frac{\ln |2t+L_0|}{2} + c_5 \right) (2t+L_0)$

Wow, we already solved for x. I wasn’t expecting it so soon. The solution is a little more complex than I’d expected, and I suspect I made a mistake somewhere. However, we should keep going. Let’s find the constant. The snail starts at position x = 0 at time t = 0, so

$\displaystyle 0 = \left( \frac{\ln |0+L_0|}{2} + c_5 \right) (0 + L_0)$

L0 is positive, so we don’t need the absolute value.

$\displaystyle 0 = \left( \frac{\ln L_0}{2} + c_5 \right)L_0$

$\displaystyle 0 = \frac{L_0 \ln L_0}{2} + c_5 L_0$

$\displaystyle c_5 L_0 = - \frac{L_0 \ln L_0}{2}$

$\displaystyle c_5 = - \frac{\ln L_0}{2}$

This is actually promising. Substituting c5 back into the equation we solved for x,

$\displaystyle x = \left( \frac{\ln |2t+L_0|}{2} + c_5 \right) (2t+L_0)$

$\displaystyle x = \left( \frac{\ln |2t+L_0|}{2} - \frac{\ln L_0}{2} \right) (2t+L_0)$

$\displaystyle x = \left( \frac{\ln |2t+L_0| - \ln L_0}{2} \right) (2t+L_0)$

I want to get rid of the absolute value. I think we can. The natural logarithm is only defined for positive numbers (at least without using complex numbers), so the absolute value allows our function to be defined for all nonzero arguments (just like $1/x$). If I remove the absolute value function, then the logarithm and therefore the equation will not be defined for 2t + L0 < 0, or when t < –L0/2. Since negative time is meaningless in this example (the snail started at time t = 0), I don’t mind discarding those times. (As an aside, I haven’t kept the units, but the 2 in the denominator is actually 2 cm/d — the speed at which the twig grows. The time –L0/2 corresponds to the time at which the twig had length zero. Clearly it would be meaningless in this problem to consider times before this.)

Back to the problem:

$\displaystyle x = \left[ \frac{\ln (2t+L_0) - \ln L_0}{2} \right] (2t+L_0)$

$\displaystyle x = [\ln (2t+L_0) - \ln L_0] \cdot \frac{2t+L_0}{2}$

$\displaystyle x = \ln \frac{2t+L_0}{L_0} \cdot \left(t + \frac{L_0}{2}\right)$

$\displaystyle x = \left(t+\frac{L_0}{2}\right) \ln \left(\frac{2t}{L_0} + 1\right)$

And that’s it! That is the equation for the distance the snail has crawled, x, at any given time t. We haven’t actually answered the question of if the snail will reach the end and when that would be, but we can save that for the next post.

# Snail Problem

A friend mentioned this problem a while back, and while I was able to use a computer to get an accurate numerical solution, I really want to find an analytical solution using math. The problem is that it will require differential equations, which I no longer remember. Edit: I haven’t yet been able to solve this problem, but I’m preserving my initial attempts below. See Part 2 where I made more progress.

The problem is this: a snail starts crawling along a twig, from one end towards the other. The snail can crawl at 1 cm/d. But the twig is growing at 2 cm/d. The twist is that the twig is adding material along its entire length, so the snail will be carried forward a bit, too, depending on where it is. Will the snail ever reach the end? Let’s let L0 be the initial length of the twig.

Let’s say the snail crawls at 1 cm/d and the twig grows at 2 cm/d. The length of the twig at time t would be

$\displaystyle L(t) = L_0 + 2t$.

For any point along the twig, the velocity will be proportional to the distance along the length of the twig, so at a distance x

$\displaystyle v_t(x, t) = \frac{x}{L_0 +2t} \cdot 2 = \frac{2x}{L_0 + 2t}$

Let’s double-check this: the beginning of the twig is $x = 0$:

$\displaystyle v_t(0,t) = \frac{2 \cdot 0}{L_0 + 2t} = 0$.

And at the end of the twig, $x = L_0 + 2t$:

$\displaystyle v_t(L_0+2t,t) = \frac{2(L_0+2t)}{L_0+2t} = 2$.

The velocity of the snail will include both its movement along the twig (at 1 cm/d) and the growth of the twig. It will be therefore

$\displaystyle v_s(x,t) = \frac{2x}{L_0+2t} + 1$

Since the velocity is the derivative of its position,

$\displaystyle \frac{dx}{dt} = \frac{2x}{L_0 + 2t} + 1$

and we want to know if and when $x(t) = L(t)$. In other words, solve for t:

$\displaystyle x(t) = L_0 + 2t$

Taking the derivative with respect to t,

$\displaystyle \frac{d}{dt} x(t) = \frac{d}{dt} (L_0 + 2t)$

$\displaystyle \frac{dx}{dt} = 2$

Note that this makes sense, at the time t when the snail reaches the end, … wait, no it doesn’t, that’s not correct. Since the functions are only equal at a specific time t, I can’t differentiate them and expect them to be equal.

Going back:

$\displaystyle \frac{dx}{dt} = \frac{2x}{L_0 + 2t} + 1$

Is this an linear differential equation? I hope so, since I’m hoping that will make it easier to solve (though at this point, I don’t remember how to solve linear or nonlinear differential equations.

$\displaystyle \frac{dx}{dt} - \frac{2}{L_0 + 2t} \cdot x = 1$.

I think I got it into the correct form. I don’t yet know what to do from here, so I’ll read on and also refresh my memory of differentiation rules.

I actually don’t think we’ll need complex differential equation techniques. We should be able to just integrate this entire equation with respect to t. I think I see why linear differential equations are easier to solve.

$\displaystyle \int ( \frac{dx}{dt} - \frac{2}{L_0 + 2t} \cdot x )\,dt = \int 1\,dt$

By the sum rule,

$\displaystyle \int \frac{dx}{dt} \,dt - \int \frac{2}{L_0+2t} \cdot x\,dt = \int 1\,dt$.

I spoke too soon. The first term is easy to integrate and the last is trivial, but I don’t know how to integrate the second.

$\displaystyle x + c_1 - \int \frac{2}{L_0+2t} \cdot x\,dt = t + c_2$

I can rearrange the terms and combine the constants

$\displaystyle \int \frac{2}{L_0+2t} \cdot x\,dt = x - t + c_3$

and I’m now stuck.

OK, I think we might be able to use integration by parts, using the formula

$\displaystyle \int u\,dv = uv - \int v\,du$.

If I set

$\displaystyle u =\frac{2}{L_0+2t}$

and set

$\displaystyle dv = x\,dt$

then to find v, we need to integrate:

$\displaystyle v = \int x\,dt$

$\displaystyle v = \frac{x^2}{2} + c_4$.

And to find du, we need to take the derivative of u. I’m just going to use the product rule, since I’m rusty at this and I don’t remember the quotient rule.

$\displaystyle du = \frac{d}{dt}\frac{2}{2t+L_0} = \frac{d}{dt}[2\cdot (2t+L_0)^{-1}]$

$\displaystyle du = \left(\frac{d}{dt}2\right) \cdot \frac{1}{2t+L_0} + 2 \cdot \frac{d}{dt}(2t+L_0)^{-1}$

$\displaystyle du = 0 + 2 \cdot (-1)\cdot(2t+L_0)^{-2}\cdot 2$

I’m going to keep going, but I just realized that I am not going to be able to integrate $\int v\,du$.

$\displaystyle du = -\frac{4}{(2t+L_0)^2}$

Shoot.

$\displaystyle uv - \int v\,du = \frac{2}{2t+L_0}\cdot \left(\frac{x^2}{4}+c_4 \right) + \int \left(\frac{x^2}{4}+c_4 \right) \left[\frac{4}{(2t+L_0)^2}\right]\,dt$.

This is a disaster.

I will have to study this more and return to this problem later.