Showing posts with label calculus of variations. Show all posts
Showing posts with label calculus of variations. Show all posts

Friday, March 10, 2017

Underground from Portland to New York (Part 2)

Underground from Portland to New York (Part 2) This post is part two of what will be a three part series on the derivation of the equations of an underground tunnel that minimizes travel time when only gravity is used for propulsion. We left our subterranean tunnel problem with the following equation we wished to minimize. $$ \eqalign{ I &= \int_a^b\frac{\sqrt{(dr)^2+(rd\theta)^2}}{\sqrt{\frac{g}{R}(R^2-r^2)}} } $$ Our first issue is figuring out what to do with \(\sqrt{(dr)^2+(rd\theta)^2}\) so that we can integrate it. We could choose to factor out either the \(dr\) or the \(d\theta\) and could solve the problem either way. We'll choose to factor out the \(dr\) because that leaves us an integrand that is not a function of the path variable (in this case \(\theta\)) which means that \(\pard{F}{\theta} = 0\) and \(\pard{F}{\theta'} = constant\). So, we have the Euler-Lagrange equation for this problem (remember that \(r\) is our variable of integration): $$ \eqalign{ \frac{d}{dr}\pard{F}{\theta'} - \pard{F}{\theta} = 0 \cr \text{but}\enspace \pard{F}{\theta} = 0 \cr \text{therefore}\enspace \frac{d}{dr}\pard{F}{\theta'} = 0 \cr \text{so}\enspace \pard{F}{\theta'} = k } $$ $$ \pard{}{\theta'} \left(\frac{\sqrt{1+(r\theta')^2}}{\sqrt{\frac{g}{R}(R^2-r^2)}}\right) = k $$ Performing the differentiation we have $$ \frac{1}{\sqrt{\frac{g}{R}(R^2-r^2)}}\cdot\frac{r^2\theta'}{\sqrt{1+(r\theta')^2}} = k $$ Squaring both sides and solving for \((r\theta')^2\) first $$ \frac{1}{\frac{g}{R}(R^2-r^2)}\cdot\frac{(r^2\theta')^2}{1+(r\theta')^2} = k^2 $$ $$ \begin{equation} \frac{\frac{k^2g}{R}(R^2-r^2)}{r^2-\frac{k^2g}{R}(R^2-r^2)} = (r\theta')^2 \label{eq:rt2} \end{equation} $$ We solve for \((r\theta')^2\) and mark that equation because in the end, our original integral for the minimum time is a function of \((r\theta')^2\) and we don't want to have to recompute it. Going the final step to solve for \(\theta'\) we have $$ \begin{equation} \theta' = \frac{1}{r}\sqrt{\frac{\frac{k^2g}{R}(R^2-r^2)}{r^2-\frac{k^2g}{R}(R^2-r^2)}} \label{eq:tp} \end{equation} $$ At this point we pause to consider the variable and limits of integration. If you look at the figure below, we can see that to traverse the curve, \(r\) goes from \(R\) to \(R\). That doesn't help us much because the definite integral would end up being 0.
We do notice, however, that the curve must be symmetric (the path shouldn't matter on which side you start) and so the deepest part of the curve is in the middle at \(r_0\). At this value of \(r=r_0\), we can see that \(\frac{dr}{d\theta} = 0\) since \(r(\theta)\) is mimimized. Conversely, this means that \(\theta' = \frac{d\theta}{dr} \rightarrow \infty\). This happens when the denominator of equation \ref{eq:tp} becomes zero. So, solving for the constants in this case when \(r=r_0\) $$ r_0^2 - \frac{k^2g}{R}(R^2-r_0^2) = 0 $$ yields $$ \frac{k^2g}{R} = \frac{r_0^2}{R^2-r_0^2} $$ Before we find the path, we'll find the time it takes to traverse the curve. Of course, this time will be a function of \(r_0\) so we will still have some work to do. Rewriting equation \ref{eq:rt2} with the above substitution and then cleaning up some of the fractions yields $$ (r\theta')^2 = \frac{\frac{r_0^2}{R^2-r_0^2}(R^2-r^2)}{r^2-\frac{r_0^2}{R^2-r_0^2}(R^2-r^2)} $$ yields $$ \begin{equation} (r\theta')^2 = \frac{r_0^2(R^2-r^2)}{r^2(R^2-r_0^2)-r_0^2(R^2-r^2)} \label{eq:rt2r0} \end{equation} $$ Now, going back to our original functional we factor out the \(dr\) and put in the actual limits of integration, multiplying the whole thing by 2 because we're only going halfway in the integral. $$ \Delta t = 2\int_{R}^{r_0}\frac{\sqrt{1+(r\theta')^2}}{\sqrt{\frac{g}{R}(R^2-r^2)}}dr $$ Substituting \ref{eq:rt2r0} into the above and moving some constants over to the left hand side $$ \frac{1}{2}\sqrt{\frac{g}{R}}\Delta t = \int_{R}^{r_0}\frac{1}{\sqrt{(R^2-r^2)}}\cdot\frac{r\sqrt{R^2-r_0^2}}{\sqrt{r^2(R^2-r_0^2) - r_0^2(R^2-r^2)}}dr $$ And after a little more algebra, factoring out the \((R^2-r_0^2)\) $$ \frac{1}{2}\sqrt{\frac{g}{R}}\Delta t = \int_{R}^{r_0}\frac{r}{\sqrt{(R^2-r^2)(r^2 - \frac{r_0^2}{R^2-r_0^2}(R^2-r^2))}}dr $$ Sometimes at points like this it helps to look at the units to make sure we at least have a sanity check. On the left hand side we have \(\sqrt{\frac{m}{s^2}\cdot\frac{1}{m}}\cdot s\) which is unitless. On the right, we have \(\frac{m\cdot m}{\sqrt{m^4}}\) which is also unitless. So we at least have that going for us. We're almost home for this part. We now have a relatively straightforward integration. We let \(u=R^2-r^2\), \(du = -2rdr\) and \(r^2 = R^2 - u\). These substitutions result in $$ \frac{1}{2}\sqrt{\frac{g}{R}}\Delta t = -\frac{1}{2}\int_{R}^{r_0}\frac{1}{\sqrt{u((R^2-u) - \frac{r_0^2}{R^2-r_0^2}u)}}dr $$ Simplifying the denominator $$ \frac{1}{2}\sqrt{\frac{g}{R}}\Delta t = -\frac{1}{2}\int_{R}^{r_0}\frac{1}{\sqrt{u(R^2-(1+\frac{r_0^2}{R^2-r_0^2})u)}}dr $$ A little more $$ \frac{1}{2}\sqrt{\frac{g}{R}}\Delta t = -\frac{1}{2}\int_{R}^{r_0}\frac{1}{\sqrt{u(R^2-\frac{R^2}{R^2-r_0^2}u)}}dr $$ A little more algebra by factoring out an \(R^2\) from the to get the integral into a more recognizable form $$ \frac{1}{2}\sqrt{\frac{gR^2}{R}}\Delta t = -\frac{1}{2}\int_{R}^{r_0}\frac{1}{\sqrt{u(1 - \frac{1}{R^2-r_0^2}u)}}dr $$ Simplifying the left a little and with a little help from Wolfram-Alpha we have (putting back the \(u=R^2-r^2\)) $$ \eqalign { \frac{1}{2}\sqrt{gR}\Delta t &= 2\sqrt{(R^2-r_0^2)}\sin^{-1}\left(\sqrt{\frac{R^2-r^2}{R^2-r_0^2}}\right) \Bigg \bracevert_R^{r_0} \cr \frac{1}{2}\sqrt{gR}\Delta t &= 2\sqrt{(R^2-r_0^2)}(\frac{\pi}{2} - 0) \cr \frac{1}{2}\sqrt{gR}\Delta t &= \pi\sqrt{R^2-r_0^2} } $$ And finally solving for \(\Delta t\) $$ \Delta t = 2 \pi \sqrt{\frac{R^2 - r_0^2}{gR}} $$ Here, we can ask the question of how long will it take to go from one side of the earth to the other, straight through the core. At that point, \(r_0 = 0\) so \(\Delta t = 2\pi\sqrt{\frac{R}{g}} \). With \(g=9.8\frac{\text{m}}{\text{s}^2}\) and the radius of the earth \(R=6.4\cdot10^6 \text{m}\) $$ \Delta t = 2\pi\sqrt{\frac{6.4\cdot 10^6}{9.8}} \approx 5078 \text{s} \approx 85 \text{min} $$ Here is a graph of the transit time in minutes versus the depth as a fraction of \(R\).
Solving for the path is coming in part 3.

Tuesday, February 21, 2017

Geodesic on a Plane in Polar Coordinates

Geodesic on a Plane in Polar Coordinates This is a simple problem in the calculus of variations where we prove that the shortest distance between two points is a straight line. But, instead of the normal Cartesian coordinate system, we will use polar coordinates \( \left( r, \phi \right) \). Some people use \( \theta \) for the angle but to be consistent with the cylindrical and spherical coordinate nomenclature, I choose to use \( \phi \). I was somewhat stumped at the end because there is a difficult integral to evaluate but we'll cross that bridge when we get to it.

In typical fashion, we wish to minimize the functional $$ I = \int_a^b ds $$ And the first thing we need to do is figure out what \( ds \) is. Looking at the figure below,

we can see that the differential length of the curve is the hypotenuse of the right triangle (well, not quite a triangle but it approaches one as \(d\phi \rightarrow 0\)) and is given by $$ ds = \sqrt{dr^2 + (rd\phi)^2} $$ In order to get something we can integrate, we have a decision to make: we need to decide which differential to factor out of the radical and integrate by either \(dr\) or \(d\phi\). Do we go with $$ ds = \sqrt{\left(\frac{dr}{d\phi}\right)^2 + r^2} d\phi $$ or $$ ds = \sqrt{1 + (r\frac{d\phi}{dr})^2} dr $$ In order to decide, we need to look at the Euler-Lagrange equation knowing that the \(F\) in the equation is the integrand in our functional. $$ F = F(x,y,y') : \frac{d}{dx}\left(\frac{\partial F}{\partial y'}\right) - \frac{\partial F}{\partial y} = 0 $$ The equation becomes significantly simpler to solve if we can choose an integrand that is not a function of the middle argument, i.e. a function only of the independent variable and the derivative. If this is the case, then \(\frac{\partial F}{\partial y} = 0 \) leaving the first term to be 0 as well. If the first term is 0, then inner partial derivative must be a constant because the derivative of a constant is 0. $$ \frac{\partial F}{\partial y'} = K $$ In our case,that leads us to use the second equation $$ ds = \sqrt{1 + (r\frac{d\phi}{dr})^2} dr = \sqrt{1 + (r\phi')^2} dr $$ because the first form contains a dependency on \(r\) as well as \(r'\).

So we now have to solve $$ F = F(r,\phi,\phi') : \frac{\partial F}{\partial \phi'} = \frac{\partial}{\partial \phi'}\left(\sqrt{1 + (r\phi')^2}\right) = K $$ Taking the partial derivative with respect to \(\phi'\), we have $$ {{r^2\phi'} \over \sqrt{1 + r^2\phi'^2}} = K $$ Squaring both sides gives $$ {{r^4\phi'^2} \over {1 + r^2\phi'^2}} = K^2 $$ Then $$ {r^4\phi'^2} = K^2 \left( 1 + r^2\phi'^2 \right) $$ and solving for \(\phi'2\) gives us $$ \phi'^2 = \frac{K^2}{r^2\left( r^2 - K^2 \right)} $$ Taking the square root and moving \( dr \) to the right side, gives $$ d\phi = \frac{K}{r\sqrt{ r^2 - K^2 }}dr $$ So, here is where it got tricky for me. If you type the above integral into Wolfram-Alpha you'll get something ridiculously complicated. If you're smarter than me, you might be able to simplify it but I had to look at this integral for a while before I came up with an answer. The trick with this stuff is knowing what spell to cast.

Whenever you see square-roots with squares and quotients, think right-triangles.

You can see that the \( \frac{K}{\sqrt{r^2 - K^2}} \) term is \(\tan \alpha\). So, we make that substitution giving us $$ d\phi = \frac{\tan \alpha}{r} dr $$ Now, what do we do about the \( r \)? Well, looking at the triangle, $$ \sin \alpha = \frac{K}{r} $$ This also means that $$ r = K\csc \alpha $$ so $$ dr = -K\cot(\alpha) \csc(\alpha) d\alpha $$ Making those substitutions leaves us with $$ d\phi = \frac{1}{K}\frac{K}{r}\tan(\alpha)dr = -\frac{1}{K}\sin(\alpha)\tan(\alpha)K\cot(\alpha)\csc(\alpha)d\alpha $$ And lo and behold, the entire thing becomes $$ d\phi = -d\alpha $$ which is something even I can solve. $$ \phi = -\alpha + C $$ Solving for \(\alpha\) in terms of \(r\), $$ \sin(\alpha) = \frac{K}{r} \Rightarrow \alpha = \sin^{-1}(\frac{K}{r}) $$ Plugging this back into our result gives us $$ \phi = -\sin^{-1}\left(\frac{K}{r}\right) + C $$ $$ \sin(C-\phi) = \frac{K}{r} $$ $$ r\sin(C-\phi) = K $$ If you don't recognize the above as a line in polar coordinates, we can go one step further using the sin-of-the-sum-of-angles identity $$ r\left(\sin(C)\cos(\phi)-\cos(C)\sin(\phi)\right) = K $$ and gathering up constants, we are left with $$ Ar\cos(\phi) + Br\sin(\phi) = K $$ and since \(x = r\cos(\phi), y = r\sin(\phi)\) are the transformations for polar to Cartesian coordinates $$ Ax + By = K $$ which is the general form of a line in Cartesian coordinates.

It's always satisfying to see something work out.