Given $\int_0^x (x-t+1)g(t)\,\mathrm{d}t = x^4 + x^2,$ Find $g(x)$ (Stanford Math Tournament 2012 #7)
A differentiable function $g$ satisfies $$\int_0^x (x-t+1)g(t)\,\mathrm{d}t = x^4 + x^2,$$ Find $g(x) \, \forall x \geq 0.$
My attempt:
First distribute the integrand to get: $$\int_0^x (x-t)g(t)\,\mathrm{d}t + \int_0^x g(t)\,\mathrm{d}t = x^4 + x^2$$
Then differentiate both sides with respect to $x$ (keeping in mind the Fundamental Theorem of Calculus Part 2 and the Chain Rule).
LHS: $$\frac{\partial}{\partial x} \left[\int_0^x (x-t)g(t)\,\mathrm{d}t + \int_0^x g(t)\,\mathrm{d}t\right] = \frac{\partial}{\partial x} \left[x\cdot\int_0^x g(t)\,\mathrm{d}t - \int_0^x tg(t)\,\mathrm{d}t + \int_0^x g(t)\,\mathrm{d}t\right] = \left[1\cdot \int_0^x g(t)\,\mathrm{d}t + x\cdot g(x) - x\cdot g(x) + g(x)\right] = \int_0^x g(t)\,\mathrm{d}t + g(x)$$
RHS: $$\frac{\mathrm{d}}{\mathrm{d}x} (x^4 + x^2) = 4x^3 + 2x$$
$$\therefore \int_0^x g(t)\,\mathrm{d}t + g(x) = 4x^3 + 2x$$
Differentiating again gives us: $$g(x) + g'(x) = 12x^2 + 2$$.
Now $g(x)$ can be found using undetermined coefficients. If we let $g(x)$ be a third degree polynomial $ax^3 + bx^2 + cx + d$, then $$g(x) + g'(x) = \left(ax^3 + bx^2 + cx + d\right) + \left(3ax^2 + 2bx + c\right)$$ $$g(x) + g'(x) = ax^3 + (3a + b)x^2 + (2b + c)x + (c+d)$$ $$g(x) + g'(x) = 12x^2 + 2$$ $$\implies a = 0, 3a + b = 12, 2b + c = 0, c+d = 2$$ $$\implies b = 12, c = -24, d = 26$$ $$\implies g(x) = ax^3 + bx^2 + cx + d = \boxed{12x^2 -24 x + 26}.$$
But, the answer provided by Stanford was $\boxed{g(x) = 12x^2 - 24x + 26 - 26e^{-x}}.$ Differentiating this function, it is obvious that the exponential part of $g$ will cancel itself out when $g(x)$ is added to $g'(x)$. However, what am I missing that is needed to solve for the $-26x^{-x}$ part, and how do I do so rigorously (i.e. using methods that don't rely completely on  just intuition)?
Sorry for the huge wall of text. I appreciate any and all help :)
Thanks
A
 A: You have
$$g(x) + g'(x) = 12x^2+2$$
Most calculus text books cover basic ODE, the above is a first order linear ODE. To solve it, we introduce an integrating factor and notice
$$ g(x) + g'(x) = 12x^2+2 \iff \frac{d}{dx}  \left ( e^x g(x) \right ) =e^x( 12x^2 + 2) $$
Now integrating the equation will give the result.
A: You have the following ODE:$$g(x) + g'(x) = 12x^2 +2$$
We can find the following integrating factor
\begin{align} I &= e^{\int1dx} \\ &= e^{x}\end{align}
Now multiplying through by $I$ gives
$$e^xg(x) + e^xg'(x)=e^x(12x^2 +2)$$
Thus we have that
\begin{align}\frac{d}{dx}(e^xg(x)) &= e^x(12x^2 +2)\end{align}
Integrating both sides w.r.t $x$ gives
\begin{align} \int\bigg[\frac{d}{dx}(e^xg(x))\bigg]dx &= \int e^x(12x^2 +2)dx \\ \implies e^{x}g(x) &= \int 12x^2e^x dx + \int2e^x dx \\ &= 12e^x(x^2 - 2x +2) + 2e^x + C \\ &= e^x\bigg[ 12x^2 - 24 x + 24 +2\bigg] + C \\ &= e^x\bigg[ 12x^2 - 24 x + 26\bigg] + C \\ \implies g(x) &= 12x^2 - 24x + 26 + e^{-x}C\end{align}
A: you can supose your solution is of the form $ ax^3+bx^2+cx+d+Ee^{-x}$, you have term $e^{-x}$ because homogenus equation $g(x) + g'(x) =0$ have this solution.
A: write your integral equations as $$(x+1)\int_0^x g dt - \int_0^x tg dt = x^4 + x^2$$
differentiate once to get $$g(x)  +  \int_0^x g dt = 4x^3 + 2x  \tag 1$$ putting $x = 0$ gives $g(0) = 0.$  differentiating $(1)$ gives
$$g^\prime + g = 12x^2 + 2  \tag 2$$  try a particular to $(2)$ solution to $(2)$ in the form $g = ax^2 + bx + c$ substituting in $(2)$ we get 
$$2ax + b + ax^2 + bx + c = 12x^2 + 2$$ equating coefficients we get $a = 12, b = -24, c = 26.$ so the general solution is $$g = 26(1 -e^{-x}) + 12x^2 - 24x$$ constant is adjusted to make $g$ satisfy the initial condition.
