# Solving a differential equation using integrating factor

1. Jul 5, 2016

### chwala

1. The problem statement, all variables and given/known data
Solve ${dy/dx}-2xy=2x$

2. Relevant equations

3. The attempt at a solution

Let $P= -2x$ and Q= 2x,
Integrating factor =$e^{-x^2}$
$y.e^{-x^2} = ∫ 2x.e^{-x^2} dx$
$y.e^{-x^2}={x^2} e^{-x^2}+∫ 2{x^3} e^{-x^2}dx$
since $y.e^{-x^2} = ∫ 2x.e^{-x^2} dx$
then $y.e^{-x^2}={x^2}e^{-x^2}+{x^2}.y.e^{-x^2}$ dividing through by $e^{-x^2},$ we have
$y={x^2}+{x^2}y.$
$y= {x^2}({1+y})$
now textbook says answer is $y+1=c{x^2}$ where have i gone wrong?

Last edited: Jul 5, 2016
2. Jul 5, 2016

### ehild

Use substitution u=x2 to find the integral. Do not forget the integration constant.

Last edited: Jul 5, 2016
3. Jul 5, 2016

### chwala

thanks i am getting
$du= 2x dx$
on substitution to the right hand side of the integral:, we get
$ye^{-x^2} = ∫2xe^{-x^2} dx$
$ye^{-x^2}= ∫(2xe^{-u})/(2x)du$
$ye^{-x^2} = -e^{-u} + c$
$y= -e^{-x^2}+c$
$y +1 = ce^{x^2}$ looks like text book answer is wrong...am i right?

Last edited: Jul 5, 2016
4. Jul 5, 2016

### MidgetDwarf

I would just let $$u=-x^2$$

Does not really matter, but it is easier to remember the negative sign.
Also, depending on the teacher they may want to see the arbitrary constants of integration. Even tho we can ignore them throughout the problem and just tack them onto the final solution. Ask your instructor. Mine was very picky when I took this course.

5. Jul 5, 2016

### ehild

Yes, the answer in the book is wrong. You can check your solution and that from the book if you substitute them into the original equation.

6. Jul 5, 2016

### chwala

right.
$y= ce^{x^2}-1$
$\frac {dy} {dx}= ce^{x^2}2x$
substituting this in
$\frac {dy} {dx}-2xy=2x$
we have:,
$ce^{x^2}2x-2x(ce^{x^2}-1)= ce^{x^2}2x-2xce^{x^2}+2x= 2x$
thus shown

7. Jul 6, 2016

### ehild

OK, so your solution is correct. What about the formula from the book?

8. Jul 6, 2016

### chwala

The book does not show the method used, it only indicates solutions.

9. Jul 6, 2016

### ehild

Well, but you can substitute it into the differential equation and see if it is really solution.

10. Jul 15, 2016

### chwala

yes, it is a solution.

11. Jul 15, 2016

### Irene Kaminkowa

Another approach
dy/dx = 2x(y+1)
dy/(y+1) = 2xdx
y+1 = Cex2

12. Jul 15, 2016

### Ray Vickson

Multiplying both sides of your DE by $e^{-x^2}$ we have
$$\frac{d}{dx} e^{-x^2} y = e^{-x^2} 2x \Longrightarrow e^{-x^2} y(x) = k + \int_0^x e^{-t^2} 2t \, dt = k - e^{-x^2}+1,$$
or
$$y(x) = e^{x^2} (c - e^{-x^2}) = -1 + c e^{x^2},$$
where $c = k-1$. Basically, $k=y(0)$ is a constant of integration.

I urge you to ALWAYS use definite integration when you solve DE's like you tried to do, and ALWAYS make a distinction between $x$ outside the integral and the dummy variable of integration; that is why I used $\int \cdots \, dt$ instead of $\int \cdots \, dx$. Doing that makes everything clearer and reduces the chance of making elementary blunders.

Both your solutions and those of the book are incorrect, although the book's solution is correct in the special case that $c = 0$ (giving the trivial solution $y(x) = -1$ for all $x$).

Last edited: Jul 15, 2016