# Continuous adjoint of the one-dimensional Laplace equation

Say I have a problem given by the 1D Laplace equation, $$R (T(\alpha), \alpha) = \frac{d^2 T(x)}{dx^2} - \alpha(x) T (x) = 0,$$ with $$x \in [0,1]$$, Dirichlet boundary conditions on $$x=0$$ and $$x=1$$, and an objective function given by the following functional: $$J = \int_0^1 \frac{1}{2} (T(x) - T_{def} (x))^2 dx.$$ I want to obtain the sensitivity of $$J$$ with respect to the spatially varying $$\alpha(x)$$ using the continuous adjoint. Introducing the adjoint variable $$\psi(x)$$ $$\frac{\delta L}{\delta \alpha} = \frac{\delta J}{\delta \alpha} + \int_0^1 \psi (x) \frac{\delta R}{\delta \alpha} dx$$ Deriving the adjoint equation by integrating by parts twice gives (neglecting the boundary terms for now) $$\frac{\delta L}{\delta \alpha} = \int_0^1 (T - T_{def}) \frac{\delta T}{\delta \alpha} dx + \int_0^1 \frac{d^2 \psi(x)}{dx^2} \frac{\delta T}{\delta \alpha} dx - \int_0^1 \psi \alpha \frac{\delta T}{\delta \alpha} dx - \int_0^1 \psi T dx$$

The adjoint equation is obtained by setting the sum of the first three terms to zero. $$\psi(x)$$ can then be used to obtain the gradient using the last term.

However, if I wanted to do the same for the following governing equation, $$R (T(\alpha), \alpha) = \frac{d^2 T(x)}{dx^2} - \frac{d \alpha(x)}{dx} T (x) = 0,$$ using the same strategy for the second term, $$\int_0^1 \psi \frac{\delta}{\delta \alpha} \left( \frac{d \alpha(x)}{dx} T(x) \right) dx = \int_0^1 \psi \frac{d}{d x} \left( \frac{\delta \alpha(x)}{\delta \alpha} \right) T(x) dx + \cdots = \int_0^1 \psi \frac{d}{d x} \left( 1 \right) T(x) dx + \cdots = 0 +\cdots,$$ the gradient resulting from the continuous adjoint will always be zero, while this is clearly not necessarily the case.

Where do I go wrong in my reasoning?