I'm trying to understand what my professor wrote, maybe it's a stupid question..
I lost him in the step from $1D$ diffusion equation:
$\frac{d}{dx}(g\frac{du}{dx})=f(x)$
where $f$ is a given forcing function, $g$ diffusion coefficient and $u$ is the solution we are seeking.
As a next step he wrote:
$f(u)=\int[\frac{1}{2}g(x)|\frac{du}{dx}|^2+f(x)u(x)]dx$
Maybe I didn't understand something he write, but basically I can't follow how this step done.
I see that it's look a bit similar to $\frac{d}{dx}(g\frac{du}{dx})=\frac{dg}{dx}\frac{du}{dx}+g\frac{d^2u}{dx^2}$ from here.
Any good tutorial of FEM is welcome as well.