$\int (1+2x^2)e^{x^2}dx$ in one line? My professor gave me the integral
$$\lambda = \int (1+2x^2)e^{x^2}dx$$
and I solved through substituition $y=x^2$ and then by parts $u=\sqrt{y}$, $dv=e^y dy$.
$$
\lambda = \int e^y(1+2y) \frac{dy}{2 \sqrt y}
= \int \frac{e^y}{2y^{1/2}}dy + \int e^y y^{1/2} dy
$$
And
$$
\int \frac{e^y}{2y^{1/2}}dy = e^y y^{1/2} - \int e^y y^{1/2}dy
$$
Thus $\lambda = e^yy^{1/2}+C=xe^{x^2}+C$.
He said that there's a trick that solves in one line, and told me that is a trick in the same sense of the one used in
$$\int \cos(x)e^xdx$$
Can someone see this trick? Or maybe there isn't one and he got confused.
 A: So, if you differentiate $e^{x^2}$ twice (as one would be inclined to do on trying integration by parts, where you have to differentiate the exponential - and is how I found it), you get
$$\newcommand{\dd}{\mathrm{d}}
\newcommand{\dv}[2]{\frac{\dd #1}{\dd #2}}
\dv{^2}{x^2} e^{x^2} = 2 \cdot \color{blue}{e^{x^2} (1+2x^2)}$$
Hence,
$$\lambda = \frac 1 2 \int \dv{^2}{x^2} e^{x^2} \, \dd x=C+\frac 1 2 \dv{}{x} e^{x^2}=C+\frac 1 2 \cdot 2xe^{x^2}=xe^{x^2}+C$$

Note that this is actually the answer since, after all, your answer on differentiation gives
$$\dv{}{x} \Big( xe^x + C \Big) = (x+1) e^x \ne e^{x^2} (1+2x^2)$$
If you make the substitution $y := x^2$ and hence $\dd y = 2x \, \dd x$ in the original integral, you get
$$\lambda = \int e^y(1+2y) \frac{\dd y}{2 \sqrt y}=\frac 1 2 \int e^y \Big( y^{-1/2} + 2y^{1/2} \Big) \, \dd y$$
so I'm not sure how your claimed integration by parts would apply here.
A: Splitting into 2 integral and then integrating the second integral by parts yields
\begin{aligned}
I &=\int e^{x^{2}} d x+\int x d\left(e^{x^{2}}\right) \\
&=\int e^{x^{2}} d x+x e^{x^{2}}-\int e^{x^{2}} d x \\
&=x e^{x^{2}}+C
\end{aligned}
A: Note that
$$\boxed{(ue^x)'=e^x(u+u')}$$
This is a pretty useful fact in evaluating integrals which are of the form exponential*some function. (It can be derived from the other direction by integrating by parts as well.) In this case, let $w=x^2$ to get the desired form of the integral $I$:
$$I=\int e^w(1+2w)\dfrac{\textrm dw}{2\sqrt w}$$
$$I=\int e^w\left(\sqrt{w}+\dfrac{1}{2\sqrt{w}}\right)\textrm dw$$
$$I=\int(e^w\sqrt{w})'\textrm dw=\sqrt{w}e^w+C$$
Undo the substitution and you have your answer:
$$I=xe^{x^2}+C$$

You want a one-line answer so you can use this generalised version (which may be harder to remember but useful nonetheless):
$$\boxed{(ue^v)'=e^v(v'u+u')}$$
(The way I remember this is by using arrows, one from the $v$ to $v'$ and then $u$ to $u'$.) 
So to solve your integral in "one-line", note that the integral is same as
$$\int e^{\color{blue}{x^2}}(\color{blue}{2x}\cdot \color{green}{x}+\color{green}{1})\textrm dx=\color{green}{x}e^{\color{blue}{x^2}}+C$$
as desired.
Hope this helps. :)
