Optimization inside integral I want maximize the integral
$$\int_a^b \left( 2 cx y(x) - e y(x)^2 \right) \, \mathrm{d}x$$
with respect to to $y(x)$.
If I discretize the problem, I get
$$ \frac{b-a}{n}\sum_{i=1}^n 2c(i/n(b-a)+a)y_i-eyi^2$$
If I take the derivative with respect to each $y_i$, I find in undiscretized version $y(x)$ as $\frac{cx}{e}$
If i plugin the values i get my optimization result.
I can understand the dynamics of the problem, but my calculus is a bit rusty, Is there anyone who can pinpoint which chapter of the calculus book should i skim in order to get more formal explanation. Thanks in advance

The Lagrangian is $\mathcal{L} (y) := 2 cx y(x) - e y(x)^2$. From the Euler-Lagrange equation, we get $2 c x - 2 e y = 0$ and, thus, $y = \left(\frac{c}{e}\right) x$ maximizes the integral.
