# integrating a line with a changing slope

I'm trying to figure out the following: You're at a point on a graph $(x_0, 1-x_0)$, and you have to obey the following rules:

1. You're allowed to move down as much as you wish, "banking" the amount you moved down. Let's call this amount $\Delta y$.

2. You are moved from your current position on a line between your current position and the origin $(0,0)$ until you hit the line $y=1-x$.

3. At this point, you're allowed to move up by the amount you "banked" in step 1.

4. You can repeat steps 1-3 as often as you want, in as small increments as you want.

Question: If you do this until you reach $x=x_f=x_0+\Delta x$, what is the maximum $y$ you can reach as a function of $\Delta x$? In other words, what is $y_{max}(x)$?

Let's illustrate this question with this graph. This illustrates only doing steps 1-3 a single time, starting at the top blue point, going down to the green point in step 1, moving up and to the right to the red point in step 2, and then moving up to the red point in step 3.

Of course, if you move the same $\Delta x$ in 2 moves (each time choosing a particular $\Delta y$ such that you move $\Delta x/2$), the final red point will be higher than with 1 move because you're taking advantage of a higher slope. Following this logic, the maximum $y$ will be reached by following this procedure with an infinitely small $\Delta y$ each time.

Any ideas how I can figure out what this $y_{max}(x)$ is? For a given $\Delta x$, I can use simple geometry to figure out what $y(x_0+\Delta x)$ is using 1 step or 2 steps, but I obviously have to use calculus to get the answer when using an infinitesimally small $\Delta y$. However, with the slope of the line changing every time, I can't figure out how to do this!

Edit: I think that the key to solving this question is putting it into a form that can be solved analytically. I can develop a function that says what is added to the height everytime you move to the right by a given $\Delta x$ (choosing the correct $\Delta y$ to allow you to do this) if you're currently at position $(x_1,y_1)$. Let's call this function $f(x_1, \Delta x)$. The resulting height would then be something like $y_{max}(x-x_0)-y_0=\int_{x_0}^{x_0+\Delta x} dx \frac{df}{dx}$. (That's not right, but if I got the right equation here, I could solve.)

• I retagged, differential geometry definitely doesn't describe this question. I'm not really sure whether this question falls more into calculus or algebra-precalculus, so feel free to retag again if one seems inappropriate. – jgon Jan 2 '18 at 22:00
• I have no clue what describes this question. It's some kind of application of calculus to geometry, but it's not really either...Thanks for helping me get this to the right community though. – efremdan1 Jan 2 '18 at 22:01

Suppose you start at $(x_0,y)$, and you want to move to a point on the line $x=x_1$ in a single step. Then we need to move down to the point $(x_0,\frac{1-x_1}{x_1}x_0)$, so $\Delta y = y - \frac{x_0(1-x_1)}{x_1}$, and the new point will have $y$-value $y-\frac{x_0(1-x_1)}{x_1} + (1-x_1)= y+(1-x_1)(1-\frac{x_0}{x_1})$. Thus if we move from $x_0$ to $x_1$ in a single step, the amount $y$ changes doesn't depend on anything except $x_0$ and $x_1$, it is $(1-x_1)(1-\frac{x_0}{x_1})$.

Therefore if we move $x_0$ to $x_f$ by a sequence of moves from $x_0$ to $x_1$ to $x_2$ to $\cdots$ to $x_k=x_f$, the $y$ value changes by $$\sum_{i=1}^k (1-x_{i})\left(1-\frac{x_{i-1}}{x_{i}}\right) = \sum_{i=1}^k \left(1+x_{i-1} - x_{i}-\frac{x_{i-1}}{x_{i}}\right).$$ Expanding this sum, the middle two terms telescope, so we get $$x_0 - x_k + \sum_{i=1}^k 1-\frac{x_{i-1}}{x_i}.$$ Now $x_k$ is the final position, so this is $$(x_0 - x_f) + \sum_{i=1}^k 1- \frac{x_{i-1}}{x_i},$$ and the first part doesn't depend on the sequence of moves taken. So let's maximize over all possible sequences of $x_i$ the sum $$\sum_{i=1}^k \frac{x_i-x_{i-1}}{x_i}.$$ Now we note that this is actually the lower Riemann sum for $\frac{1}{x}$ over the partition of the interval $[x_0,x_f]$ into the intervals $[x_0,x_1]$, $[x_1,x_2]$, $\ldots$, $[x_{k-1},x_k]$. Hence for any sequence of $x_i$, this is bounded above by (and approaches as you refine the partition) $$\int_{x_0}^{x_f} \frac{1}{x} \,dx= \ln x_f - \ln x_0 = \ln (x_f/x_0).$$

Hence $y_{\text{max}}(x)= y_0+x_0-x + \ln(x/x_0)$. In particular, if $y_0=1-x_0$, $$y_{\text{max}}(x) = 1-x+\ln(x/x_0).$$

• Exactly right! Thanks so much! – efremdan1 Jan 3 '18 at 9:54
• And this answer has inspired me to give a differential answer based on simpler calculus! – efremdan1 Jan 4 '18 at 9:57

The easy thing to do is just to write down the mapping that given $x_0$ and $\Delta y$ sends you to the red dot.

Your first position is $(x_0,1-x_0)$. Then you move to $(x_0,1-x_0-\Delta y)$. Then you follow a line with slope $m=\frac{1-x_0-\Delta y}{x_0}$ until you reach $(x_1,1-x_1)$. This requires you to increase $x+y$ by $\Delta y$. On the other hand, $x+y$ increases by $(m+1)\Delta x$. So $\Delta x=\frac{\Delta y x_0}{1-\Delta y}$ and consequently $x_1=\frac{x_0}{1-\Delta y}$.

Then the red dot is at

$$(x_1,1-x_1+\Delta y)=\left ( \frac{x_0}{1-\Delta y},1-\frac{x_0}{1-\Delta y}+\Delta y \right )$$

and you want to maximize the slope of the line between this point and the starting point (since each "move" only "costs" you $\Delta x$). Can you finish now?

• "This requires you to increase $x+y$ by $\Delta y$, while $x+y$ increases by $(m+1)\Delta x(m+1)\Delta x$." Can you clarify this? – efremdan1 Jan 2 '18 at 22:38
• @efremdan1 Before that step, $x+y=1-\Delta y$. After that step, $x+y=1$. Meanwhile, the actual change in $x+y$ is $(m+1)\Delta x$ if $m$ is the slope. – Ian Jan 2 '18 at 22:41
• Clarified. Now to think... – efremdan1 Jan 2 '18 at 22:46

I've figured out an alternative method to answering the question. If you start at position $(x_0, 1-x_0)$ and move a tiny bit down, the line you follow back to the line $y=1-x$ must have slope equal to $\frac{1-x_0}{x_0}$. Putting this into a differential equation form: $\frac{dy}{dx}=\frac{1-x_0}{x_0}=\frac{1}{x_0} -1$

Solving the differential equation gives: $y=\ln(x)-x+C$

To solve for $C$, we know that $y(x=x_0)=1-x_0=\ln(x_0)-x_0+C$

Rearranging, $C=1-\ln(x_0)$

So the full equation is: $y=\ln{\frac{x}{x_0}}-x+1$

Of course, this is exactly the same answer as given by the method of @jgon