Euler Lagrange equation for an objective function with integral I came across a dynamic optimization problem. I looked at several references, but none of them had an example of my problem. It seems to be related to Euler-Lagrange, but the inclusion of integral makes me a headache.  
$$\int_0^\infty e^{-rt}f(c(t))\,e^{-\left(\int_0^t c(h)\,dh\right)t}dt $$
Note that $f(t) = u(t)+w-p\,c(t),$ where $u(t)$ is a concave function with $w$ as endowment and $p$ as a price.
I am maximizing this objective function with a function $c(t).$ Shall I use a chain rule to take a derivative of the integral with $c(t)$ and $d(c(t))/dt$ for both? or only for $c(t)?$  Thank you

My second question supposes that we take
$$C(t)=\int_0^t c(h)\,dh. $$
Then we can reformulate the objective function as
$$\int_0^\infty e^{-rt}f(\dot{C}(t))\,e^{-t\,C(t)}\,dt. $$
Then the Lagrangian is
$$L(t;C,\dot{C})=e^{-rt}f(\dot{C}(t))\,e^{-t\,C(t)} $$
with initial condition $C(0)=0.$
 A: The Euler-Lagrange equation for this problem says that, given the integral
$$\int_0^\infty \underbrace{e^{-rt}f(c(t))\,e^{-\left(\int_0^t c(h)\,dh\right)t}}_{=\,L(c,\dot{c};t)}dt,$$
the extremum is given by
$$\frac{\partial L}{\partial c}-\frac{d}{dt}\,\frac{\partial L}{\partial \dot{c}}=0. $$
But now $\dot{c}$ does not appear in $L,$ so this simplifies down to
$$\frac{\partial L}{\partial c}=0.$$
We compute
\begin{align*}
\frac{\partial L}{\partial c}
&=e^{-rt}\bigg[\underbrace{f'(c(t))\,e^{-\left(\int_0^t c(h)\,dh\right)t}
+f(c(t))\,\frac{d}{dc}e^{-\left(\int_0^t c(h)\,dh\right)t}}_{\text{product rule}}\bigg]\\
&=e^{-rt}\bigg[f'(c(t))\,e^{-\left(\int_0^t c(h)\,dh\right)t}
-tf(c(t))\,\underbrace{e^{-\left(\int_0^t c(h)\,dh\right)t}\,\frac{d}{dc}\left(\int_0^t c(h)\,dh\right)}_{\text{chain rule}}\bigg]\\
&=e^{-rt}e^{-\left(\int_0^t c(h)\,dh\right)t}\left[f'(c(t))
-tf(c(t))\,\frac{d}{dc}\left(\int_0^t c(h)\,dh\right)\right].
\end{align*}
Now the expression $\displaystyle \frac{d}{dc}\left(\int_0^t c(h)\,dh\right)$ is a bit problematic. To calculate this, we actually need to use the Calculus of Variations again, with a different $\tilde L=c(h).$ Then 
\begin{align*}
\frac{d}{dc}\left(\int_0^t c(h)\,dh\right)
&=\frac{\partial\tilde L}{\partial c}-\frac{d}{dh}\,\frac{\partial\tilde L}{\partial\dot{c}}\\
&=1.
\end{align*}
Hence,
\begin{align*}
\frac{\partial L}{\partial c}
&=e^{-rt}e^{-\left(\int_0^t c(h)\,dh\right)t}\left[f'(c(t))
-tf(c(t))\right]\\
&=0.
\end{align*}
This implies that
\begin{align*}
f'(c(t))-tf(c(t))&=0.
\end{align*}
The form of $f$ is $f(t)=u(t)+w-p\,c(t),$ and note that, according to our calculations, $f'(c(t))=df/dc.$ We see that $df/dc=-p,$ so that this equation becomes
$$-p-t(u(t)+w-p\,c(t))=0. $$
Solving for $c(t)$ yields
$$c(t)=\frac{p+t u(t)+t w}{p t}. $$
As for the reformulation, we can write
\begin{align*}
L&=f(\dot{C}(t))\,e^{-t(r+C(t))}\\
\frac{\partial L}{\partial C}&=-tf(\dot{C}(t))\,e^{-t(r+C(t))}\\
\frac{\partial L}{\partial\dot{C}}&=f'(\dot{C}(t))\,e^{-t(r+C(t))}\\
\frac{d}{dt}\frac{\partial L}{\partial\dot{C}}&=f''(\dot{C}(t))\,\ddot{C}(t)\,e^{-t(r+C(t))}+f'(\dot{C}(t))\,e^{-t(r+C(t))}\,(-t\dot{C}(t)-r-C(t)).
\end{align*}
These are the ingredients for the EL equation: $L_C-d\!\left(L_{\dot{C}}\right)/dt=0:$
\begin{align*}
-tf(\dot{C}(t))\,e^{-t(r+C(t))}-f''(\dot{C}(t))\,\ddot{C}(t)\,e^{-t(r+C(t))}-f'(\dot{C}(t))\,e^{-t(r+C(t))}\,(-t\dot{C}(t)-r-C(t))&=0\\
-tf(\dot{C}(t))-f''(\dot{C}(t))\,\ddot{C}(t)-f'(\dot{C}(t))\,(-t\dot{C}(t)-r-C(t))&=0.
\end{align*}
Then you would need to substitute in to what $f$ is, and try to solve for $C.$ It all looks rather complicated.
