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

• You should google for discrete methods in variational calculus. There are plenty of good books that treat the matter with more elemmental or advanced approaches – user335721 Jun 4 '16 at 7:36
• No, this has nothing to do with discrete methods; the discretisation just distracts from the simple structure of the problem. – joriki Jun 4 '16 at 7:38

No fancy calculus is required. Since there are no constraints and no derivatives of $y$ occur in the integral, only $y$ itself, the integral is directly maximised by maximising the integrand at each point separately. Setting the derivative of $2cxy-ey^2$ with respect to $y$ to $0$ yields $2cx-2ey=0$ and thus $y=\frac{cx}e$.
• @AyleanClaraGrandieur: I don't know about books, but the property you need is the monotonicity of integration -- integration (both Riemann and Lebesgue) is monotonic in the sense that if $f\le g$ everywhere, then $\int f\mathrm dx\le\int g\mathrm dx$. That's all you need to formally prove that if you maximise the integrand at every point, you maximise the integral. – joriki Jun 4 '16 at 7:47
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.