Adjoint equation
An adjoint equation is a linear differential equation, usually derived from its primal equation using integration by parts. Gradient values with respect to a particular quantity of interest can be efficiently calculated by solving the adjoint equation. Methods based on solution of adjoint equations are used in wing shape optimization, fluid flow control and uncertainty quantification. For example formula_1 this is an Itō stochastic differential equation. Now by using Euler scheme, we integrate the parts of this equation and get another equation, formula_2, here formula_3 is a random variable, later one is an adjoint equation. Example: Advection-Diffusion  PDE. Consider the following linear, scalar advection-diffusion equation for the primal solution formula_4, in the domain formula_5 with Dirichlet boundary conditions: Let the output of interest be the following linear functional: Derive the weak form by multiplying the primal equation with a weighting function formula_8 and performing integration by parts: where, Then, consider an infinitesimal perturbation to formula_11 which produces an infinitesimal change in formula_12 as follows: Note that the solution perturbation formula_14 must vanish at the boundary, since the Dirichlet boundary condition does not admit variations on formula_15. Using the weak form above and the definition of the  adjoint formula_16 given below: we obtain: Next, use integration by parts to transfer derivatives of formula_14 into derivatives of formula_20: The adjoint PDE and its boundary conditions can be deduced from the last equation above. Since formula_14 is generally non-zero within the domain formula_5, it is required that formula_24 be zero in formula_5, in order for the volume term to vanish. Similarly, since the primal flux formula_26 is generally non-zero at the boundary, we require formula_20 to be zero there in order for the first boundary term to vanish. The second boundary term vanishes trivially since the primal  boundary condition requires formula_28 at the boundary. Therefore, the adjoint problem is given by: Note that the advection term reverses the sign of the convective velocity formula_30 in the adjoint equation, whereas the diffusion term remains self-adjoint.