Why does integration by parts give me the wrong answer?

195 Views Asked by At

I'm solving a first order differential equation.

$$\frac{dy}{dx}+2xy=x$$

I multiplied by the integration factor to get the equation in the form $f\left(x\right)\frac{dy}{dx}+f'\left(x\right)y=f\left(x\right)Q$

$$f\left(x\right)=e^{x^{2}}$$

so

$$e^{x^{2}}\frac{dy}{dx}+2xe^{x^{2}}y=xe^{x^{2}}$$

Rearranged

$$e^{x^{2}}y=\int{xe^{x^{2}}}dx$$

I know the easiest and correct way to do this is by using a u substitution for $e^{x^{2}}$ but I tried using integration by parts and I got a completely different answer to using a u sub.

I got $$y=\frac{1}{2}-\frac{1}{4x^{2}}+\frac{c}{e^{x^{2}}}$$

The correct answer using u sub is $$y=\frac{1}{2}+\frac{c}{e^{x^{2}}}$$

I don't understand why I'm getting a different answer.

If I take $u = x$ and $\frac{dv}{dx} = e^{x^{2}}$

Using integration by parts I get $$\int{xe^{x^{2}}}=x\left(\frac{1}{2x}e^{x^{2}}\right)-\int\frac{1}{2x}e^{x^{2}}dx$$

Can anyone explain what am I doing wrong, or why this is getting me different answer? Or why can I not use to it to get the same answer?

Thank you to whoever can tell me what I'm doing wrong.

4

There are 4 best solutions below

0
On

$$\int x e^{x^2}dx $$

Is immediate being the integrand in the form $f' e ^f$.

$$\frac{1}{2}\int 2x e^{x^2}dx =\frac{1}{2}e^{x^2}$$

1
On

As mentioned in the comments, you make a mistake when you assume

$$\frac{dv}{dx}=e^{x^2} \implies v=\frac{e^{x^2}}{2x}$$

This is not true (use the quotient rule and check for yourself!). $e^{x^2}$ has no elementary antiderivatives: in other words, you can't integrate it and get a result in terms of elementary functions, like polynomial functions, trigonometric functions, exponential functions, etc.

I attempted to perform the integration by parts with $\frac{dv}{dx}=x$ and $u=e^{x^2}$, and unless I made a mistake somewhere in my calculations, you end up subtracting an integral that has $e^{x^2}$ multiplied by higher powers of $x$, so you get nowhere*. I would suggest the $u$-substitution method instead as you have described it.


* Actually, I just found this answer which manages to do it, but only through the use of infinite series. So it is possible, but I doubt this is really worth all that work.

0
On

You have, $$ e^{x^2}y=\int xe^{x^2}dx=\frac{1}{2}\int d(e^{x^2})=\frac{1}{2}(e^{x^2}+C) $$ where $C$ is the constant of integration. Therefore, $$ y= \frac{1}{2}(1+ Ce^{-x^2}) $$ which satisfies the differential equation.

0
On

I will just add, that you can solve this ordinary differential equation in a simpler way. This ordinary differential equation is separable.

$$\dfrac{dy}{dx} = x -2xy$$ $$\dfrac{dy}{dx} = x(1-2y)$$ $$\dfrac{dy}{1-2y}=xdx$$ $$-\dfrac{1}{2}\ln (1-2y) = \dfrac{1}{2}x^2 - \dfrac{1}{2}c$$ $$\ln(1-2y)=c-x^2$$ $$1-2y=\exp(c)\exp(-x^2)$$ $$y=\dfrac{1-\exp(c)\exp(-x^2)}{2}$$ $$y=\dfrac{1}{2}-c_0\exp(-x^2)$$

Our solution implies $1-2y>0 \implies y<1/2$. Hence, $c_0>0$.