Consider an inhomogenous exponential process
$t \sim \lambda(p(t)) e^{-\int_{0}^{t} \lambda(p(s)) ds}$
where $\lambda > 0$ and monotonically decreases on the reals. Now define the reward function
$\pi(p(t), t) = \begin{cases} 0 &\text{ if } t > T\\ p(t) &\text{ else } \end{cases}$
The expected reward is then
$E[\pi] = \int_{0}^{T} \lambda(p(t)) e^{-\int_{0}^{t} \lambda(p(s)) ds} p(t)dt$
Directly applying the calculus of variations, I get the Euler-Lagrange conditions for extremizing this
$0 = \exp\big(- \int_{0}^{t} (\lambda \circ p)(t) ds\big) \big((\lambda' \circ p)(t) \times p(t) + (\lambda \circ p)(t) - (\lambda \circ p)(t) \times p(t) \times \int_{0}^{t} (\lambda' \circ p)(s) ds\big)$
$0 = (\lambda' \circ p)(t) \times p(t) + (\lambda \circ p)(t) - (\lambda \circ p)(t) \times p(t) \times \int_{0}^{t} (\lambda' \circ p)(s) ds$
This seems like an absurd result to me. How can the result be independent of the boundary conditions $t = T$?
Putting this into concrete terms, say I'm choosing to set the price for a single good that expires at time $t = T$. The sale time is inhomogenous exponential with a demand-curve like rate parameter $\lambda(p)$, and I'm trying to choose the price trajectory through time that maximizes my expected revenue. This result tells me that my revenue maximizing price trajectory doesn't depend on how much time I have to sell the good?
Alternatively, I can discretize the same problem with an equivalent sequence of poisson processes. I'll spare you the tedious details, but rescaling $\lambda$ for the timestep length, letting $\pi^{*}_{t}$ be the optimum price for a discrete time step and $\pi^{*}_{T+1} = 0$, the inductive discrete solution is
$0 = 1 + \exp(-\lambda(p_{t})) \big(\lambda'(p_{t}) (p_{t} - \pi^*_{t+1}) - 1\big)$
which is obviously completely different, and doesn't converge in the limit to the continuous solution. I'm pretty sure I did something wrong here, but for the life of me I can't think of what.
EDIT: I've figured out my error. I can't naively apply the Euler-Lagrange result because my action here depends on both $p(t)$ and $\int_{0}^{t} \lambda(p(s))ds$. Taking the rigorous functional derivative of the action, with perturbation $p + \epsilon \phi$, wrt $\epsilon$ evaluated at $\epsilon = 0$, I get the first order condition
$$0 = \int_{0}^{T} \exp\bigg(- \int_{0}^{t} \lambda p ds\bigg) \bigg(\lambda' p \phi - \lambda p \int_{0}^{t} \phi \lambda' ds + \lambda \phi \bigg) dt$$
$$\forall \phi: \mathbb{R} \rightarrow \mathbb{R} \mid \phi(0) = \phi(T) = 0$$
Because $\phi$ can't be easily factored out of the inner integral, this is not as straightforward as the usual calculus of variations problem. But at least things are making sense now.