# Simplifying $r_n = \max(p_n,r_i+r_{n-i})$ to $r_n = \max(p_i + r_{n-i})$

In CLRS (Intro to algorithms) on page 362, it says equation (1):

$$r_n = \max(p_n, r_1+r_{n-1},r_2+r_{n-2},\dots,r_{n-1}+r_1)$$

can be simplified to this equation (2):

$$r_n = \max_{1 \leq i \leq n} (p_i + r_{n-i})$$

I would like to know how this simplification was arrived at. It shouldn't necessarily be a formal proof but one that makes logical and intuitive sense. General arguments or assumptions that lead to this simplification are also welcome. Any effort is much appreciated.

Update

I want to know how the second equation is valid if we are not considering the optimal revenues on both sides but only the optimal revenue of the right-hand piece as suggested by the second equation.

I.e. in the second equation, we use the price of the left piece and then add it to the optimal revenue of the right-hand piece.

• I think you shouldn't think or the second formula as a consequence of the first (although it is of course, as both equal $r_n$), but simply derive it from scratch. This is actually what is done in the CLRS. The paragraph preceding this formula explains how. Maybe you could be a bit more precise about what part of this paragraph you struggle with, to help us help you. (And include definitions of $p_i$ and $r_i$ to make the question more self-contained) Oct 10, 2020 at 19:52
• @Tassle I want to know how is the second equation valid if we are not considering the optimal revenues on both sides but only the optimal revenue of the right-hand piece as suggested by the second equation. Oct 10, 2020 at 20:10

I feel like this is basically paraphrasing the explantion in CLRS but maybe it will help.

Let $$j$$ be the length of the leftmost rod piece in an optimal solution. This piece has a cost of $$p_j$$ and so it contributes exactly that much to the total revenue. It is easy to see that the remaining part of the rod (of length $$n-j$$) must be divided up in an optimal manner as well for the whole thing to be optimal (and thus leads to a revenue of $$r_{n-j}$$).

Thus, we have $$r_n = p_j +r_{n-j}$$. Because $$r_n$$ is the optimal revenue, $$r_n \geq \max_{1\leq i \leq n}\{p_i+r_{n-i}\}$$. But we also have $$r_n = p_j +r_{n-j} \leq \max_{1\leq i\leq n}\{p_i+r_{n-i}\}$$.

Putting both ineqalities together gives $$r_n = \max_{1\leq i \leq n}\{p_i+r_{n-i}\}$$.