# Homework Help: First order DE with integrating factor

1. Oct 5, 2012

### fluidistic

1. The problem statement, all variables and given/known data
I'm having a hard time to solve the following DE using an integrating factor, I'm asked to find one and solve the DE.
$(x+y^2)-2xyy'=0$.

2. Relevant equations

3. The attempt at a solution
If I call u=u(x) (I assume the integrating factor depends only on x, not on y), the following must hold: $\frac{\partial}{\partial y} [u\cdot (x+y^2)]= \frac{\partial}{\partial x} (-2xyu)$. This lead me to $2yu=-2(y'ux+yu'x+yu)$. I tried to find u(x) but this lead me nowhere. Any idea on how to proceed?

Edit: Nevermind guys I got it! I had to assume that y didn't depend on x. I reached the result that wolfram alpha gives so problem solved!

Last edited: Oct 5, 2012
2. Oct 5, 2012

### gabbagabbahey

Sounds like you lucked into the correct final answer. $y(x)$ is clearly a function of $x$, so assuming that it isn't is a bad idea.

Instead, start by recalling what form your differential equation must be in to use an integrating factor: is your DE in that form? If not, is there a substitution you can use to get it into that form?

3. Oct 5, 2012

### Simon Bridge

Not only that but if y does not depend on x then y' = dy/dx = 0 right?
Which makes nonsense of the question!

If this is a long-answer question, the marks will not depend so much on the answer but on the method used. This is a good example of why that is: you can just luck-out.

4. Oct 5, 2012

### fluidistic

Here is my work, it's not graded by the way.
$\frac{\partial}{\partial y} [u\cdot (x+y^2)]= \frac{\partial}{\partial x} (-2xyu) \Rightarrow 2uy=-2y(u'x+u)\Rightarrow 2u =-u'x \Rightarrow \ln u = -2 \ln x$ (I omitted the constant of integration but it's fine in this case), thus $u=x^{-2}$ which is the integrating factor. It works, I've checked that it indeed makes the DE as a perfect differential.
So that there exist a function $F(x,y)$ such that $\frac{\partial F}{\partial x} = \frac{x+y^2}{x^2}$ and $\frac{\partial F}{\partial y}=-\frac{2xy}{x^2}$. After integrating twice; once for each case, I reached that $F(x,y)=\ln x - \frac{y^2}{x}$.
Therefore the general solution to the DE under the implicit form is $\ln x - \frac{y^2}{x}=c$ but I notice it's easy to get the explicit form for y(x), namely $y(x)=\pm \sqrt {x(c+\ln x)}$.
A guy in a go server told me that in general for these kind of DE's: $P(x,y)dx+Q(x,y)dy=0$ one consider x and y as independent variables for P and Q. I said ok thank you I'm going to try out... turns out that it worked well.
Is that just luck?!
Because if I consider that y depends on x, as I wrote in my first post I reach a nightmare of an equation.
In any case, I'm looking forward your substitution way gabbahey. I've no idea how to guess a good one.

5. Oct 7, 2012

### Simon Bridge

Well: I'm not convinced you understand why what you did worked - in which case it was luck yes.

Formally, you'd put the DE in the form $$\frac{dy}{dx}+py = q$$... where everything is a function of x.

The integrating factor is $$f=e^{v(x)} : \frac{dv}{dx}=p$$

Starting with: $$\frac{dy}{dx}=\frac{x+y^2}{2xy}$$

I'd have substituted $z=y^2$ [1] to give:$$\frac{dz}{dx}-\frac{z}{x}=1$$suggesting that $p=-1/x$, $q=1$ and $v=\ln|1/x|$ for an integrating factor: $f=1/x$ and $$z=x\int\frac{dx}{x} = x(\ln|x|+c)$$ $$\Rightarrow y = \pm\sqrt{x\ln|kx|}$$... which is what you have except I have brought the constant inside the natural logarithm - but that's a matter of taste if there is nothing else to go on.

Probably the takeaway lesson here is to make your reasoning as well as your calculation clear when you answer these things. Otherwise it all looks like happenstance ;)

-------------------

[1] Since you mentioned it:
I chose it because of the $2yy^\prime$ in the DE - if it was $y^2+2yy^\prime$ instead of $y^2-2yy^\prime$ I'd have gone for $z=xy^2$.
You get used to it - the idea is to look for things that look like derivatives of another term in the DE.

6. Oct 7, 2012

### fluidistic

First of all thanks a lot. I've found out that I'm not good at all when searching for substitutions. In fact I had tried "hard" to transform the DE into the form $\frac{dy}{dx}+py = q$ but failed to do so. I did not find the substitution you found out.

I'm so perplexed that I got the result by luck that I'm reading about perfect differential, namely http://en.wikipedia.org/wiki/Exact_differential#Two_and_three_dimensions and apparently when they do the partial derivatives, they consider all the other variables as constant. They say that $A(x,y)dx+B(x,y)dy$ is a perfect differential if and only if $\left( \frac{\partial A}{\partial y} \right)_x = \left( \frac{\partial B}{\partial x} \right)_y$ holds.
So when I did $\left ( \frac{\partial (-2xyu)}{\partial x} \right )$ it was perfectly fine to take y as a constant instead of y(x). So that would justify that I did not get the result by luck. However I'm still unsure why I take u as u(x) and not u only.
I still can't swallow that I got the result by error! That would be too much of a coincidence.

7. Oct 7, 2012

### Simon Bridge

It is practice ... nobody starts out good at it. I gave you the basic guideline: you end up making guesses from slight hints and trying them out to see if they work. Gaining this skill is the purpose for giving you these problems to do.

Yep - you treat x and y as independent variables in A and B even though you know y is a function of x. It is not the same as "not assuming y(x)".

Yep - though your statement that you did not assume y(x) gave the game away a bit because
See? You don't know why you used the method you did. The method was a useful one ... but when do you use y(x) and when just plain y?

You could try other examples and see how the u pans out as u(x) and not.
Look to the derivation of the method to see why it is u(x) ...

(Hint: difference between partial and regular differentiation.)