Hello it's a me drifter1! Today we will do some **exercises **in the **first-order differential equations** that we covered in my two previous posts. I highly suggest you to read about them first, but don't worry we will get very in depth in most of them, so it's not important to know them perfectly!

So, without further do, let's get straight into it!

## Separable ( P(x)*dx + Q(y)*dy = 0 )

*1) y' = x^3/y^2*

y' = dy/dx = x^3/y^2 =>

x^3*dx = y^2 * dy. Separable ODE

And so we find the integral on both sides

integral (x^3*dx) = integral (y^2 * dy ) =>

x^4/4 = y^3/3 + c1 =>

y^3 = 3x^4/4 + 3c1 = 3x^4/4 + c2 =>

**y = root-3(3x^4/4 + c2)**

*2) (xy^2 - x) dx = (y+x^2y) dy*

We take x as a common term for the left side and y for the right side.

That way:

x(y^2 - 1)dx = y(1 + x^2)dy =>

x /( 1+x^2) dx = y / (y^2 - 1) dy. Separable ODE.

So, we take the integral in both sides.

integral [ x /( 1+x^2) dx ] = integral [ y / (y^2 - 1) dy ].

Both are ln(x) cases, because both are of the form: f'(x)/f(x) = ln(f(x))

That way we get:

1/2 ln|1+x^2| = 1/2 ln|y^2 - 1| + c1.

Let's suppose c1 as lnc and also take the coefficients of the ln's and put them as exponents.

That way we can do the following:

ln(x^2 + 1)^1/2 = ln(y^2 - 1)^1/2 + lnc =>

ln(root(x^2 + 1) = ln(root(y^2 - 1)*c).

Supposing y^2 >= 1 we then get:

**root(x^2 + 1) = root(y^2-1)*c**

From this final equation we can find our y solution

## Homogeneous ( y' = P(x,y) / Q(x,y), P/Q is 0-order homogeneous )

*1) y' = (x - y)/(x + 2y)*

P(λx, λy) = λx - λy = λ(x - y) = λ P(x, y)

and

Q(λx, λy) = λx + 2λy = λ(x+2y) = λ Q(x, y)

This means that the quotient P/Q is 0-order homogeneous and so we have a homogeneous ODE.

Diving the numerator and denominator with x!= 0 we get:

y' = (x-y/x)/[(x+2y)/x] =>

y' = (1 - y/x)/(1 + 2y/x). A function of y/x.

We substitute y/x with u = y/x and get:

y = ux => y' = (ux)'= u'x + u.

That way our given equation now is:

y' = u'x + u = (1 - u)/(1 + 2u) =>

(du/dx) x + u = (1 - u)/(1 + 2u) =>

(du/dx) x = (1 - u - 2u^2) /(1 + 2u) =>

[(1 + 2u) / (1 - u - 2u^2)] du = (1/x) dx. A separable ODE.

By finding the integral in both sides we get:

integral [(1 + 2u) / (1 - u - 2u^2)] du = integral [ (1/x) dx ].

The left one is an Rational integral and needs to be solved with a special technique I covered here.

The right one is a basic ln(x) case.

Solving the left one (that I will not do now for simplicity) you get:

−2ln|2u−1|/3 − ln|u+1|/3 + c = ln|x|.

Substituting u back to u = y/x we then get our final solution:

**−2ln|2(y/x)−1|/3 − ln|(y/x)+1|/3 + c = ln|x|.**

From there we can find y if we want.

*2) xy' - y = xe^(y/x)*

Let's first move y to the other side:

xy' = xe^(y/x) + y

Dividing with x!=0 we get:

y' = e^(y/x) + y/x = F(x, y) (I)

where F(x, y) is off course homogeneous of 0-order.

Let's substitute using u = y/x => y = ux => y' = u'x + u.

From (I) we get:

y' = u'x + u = e^u + u =>

u'x = e^u =>

(du/dx) x = e^u =>

e^(-u)du = (1/x) dx. Separable ODE

Finding the simple integral from both sides we get:

integral[ e^(-u)du ] = integral [ (1/x) dx ] =>

-e^(-u) = ln|x| + c1 = ln|x| + lnc.

Substituting back using u = y/x and doing the ln addition we finally get:

**-e^(-y/x) = ln|cx|**

## Exact ( P(x, y)*dx + Q(x, y)*dy = 0, P'y == Q'x )

*1) (x - 2xy - 5)*dx -(x^2 +3y - 2)*dy = 0*

Derivating P using y (partial derivative) we get:

P'y = (x - 2xy - 5)'y = 0 - 2x - 0 = -2x

Derivating Q using x (partial derivative) we get:

Q'x = [-(x^2 +3y - 2)]'x = -2x + 0 - 0 = -2x

P'y == Q'x and so we have an exact ODE.

Let's now find the solution using the method we discussed in part 1.

f(x, y) = integral[P(x,y)dx] = f1(x, y) + c1(y) =>

f(x, y) = integral[x - 2xy - 5]dx = x^2/2 - x^2*y - 5x + c1(y) (I)

f'y = Q(x, y) and so from (I) we have:

[ x^2/2 - x^2*y - 5x + c1(y) ]'y = -(x^2 +3y - 2) =>

0 - x^2 - 0 + c1'(y) = -x^2 -3y + 2 =>

c1'(y) = -3y + 2 =>

c1(y) = integral(-3y + 2)dy = -3y^2/2 + 2y + c2 (II)

From (I) and (II) we now have:

f(x, y) = x^2/2 - x^2*y - 5x -3y^2/2 + 2y + c2.

Because f(x, y) = c =>

** x^2/2 - x^2*y - 5x -3y^2/2 + 2y = c**

This is our final solution!

*2) 2yy' +2x + x^2 + y^2 = 0*

By writing y' as dy/dx we can get to the form:

(2x + x^2 + y^2)dx + 2ydy = 0

P'y = 2y and Q'x = 0

This means that P'y != Q'x and so the given ODE is not exact.

Let's find the correct integrating factor (μ) to multiply with.

If μ = μ(x) then:

(P'y - Q'x)/Q : function of x

We have that:

(P'y - Q'x)/Q = (2y - 0)/2y = 1. A function of x!

So, μ = e^integral(1*dx) = e^x

Multiplying our ODE with e^x we get:

2ye^xdy +e^x(2x + x^2 + y^2)dx = 0.

Q'x = 2ye^x and P'y = 2ye^x

This means that we now have an exact ODE!

f(x, y) = integral[2ye^xdx] = 2ye^x - 2*integral(e^xdx) = 2ye^x - 2*e^x + c(y) (I)

f'y = Q(x, y) =>

[2ye^x - 2*e^x + c(y) ]'y = e^x (2x + x^2 + y^2) =>

2e^x - 0 + c'(y) = e^x (2x + x^2 + y^2) =>

c'(y) = e^x (2x + x^2 + y^2) - 2e^x =>

c(y) = integral[e^x (2x + x^2 + y^2) - 2e^x ]dy =>

c(y) = e^x*(2xy + x^2y + y^3/3) - 2ye^x) + c2 (II)

From (I) and (II) we get:

f(x, y) = 2ye^x - 2*e^x + e^x*(2xy + x^2y + y^3/3) - 2ye^x) + c2 =>

**2ye^x - 2*e^x + e^x*(2xy + x^2y + y^3/3) - 2ye^x) = c**

That was some quick mafs! ;P

## Linear ( y' + P(x)*y = Q(x) )

*1) y' = x (x^2 - 2y)*

Let's solve it using the first method.

y' = x^3 - 2xy =>

y' + 2xy = x^3 [of the form: y' + P(x)*y = Q(x)]

Let's use the two equations we talked about last time.

u = e^integral[P(x)dx] = e^integral[2xdx] = e^(x^2) + c

y = (1/u)* integral[u*Q(x)dx] =>

y = e^(-x^2)*integral[e^(x^2)*x^3dx].

The integral can be solved using "by parts" and we get the solution:

y =1/2 * e^(-x^2) * [(x^2 − 1)*e^(x^2)] + c =>

**y = 1/2 * e^(-x^2) * [x^2*e^(x^2) - e^(x^2)] + c**

*2) xy' + x + y = 0*

Let's solve this one with the second method.

Dividing with x!=0 we get:

y' + 1 + y/x = 0 =>

y' + (1/x)*u = -1 [of the form: y' + P(x)*y = Q(x)]

We will substitute using y = gY.

Let's use the equations for g and Y to find them.

g = e^[-integral(Pdx)] = e^[-integral(1/xdx)] =>

g = e^(-lnx) = e^ln(x^-1) =>

g = x^(-1) = 1/x

Y = integral[(Q/g)dx] + c = integral[-1/(1/x)dx] +c =>

Y = -integral(xdx) = -x^2/2 + c.

That way:

y = gY = 1/x*(-x^2/2 + c) =>

**y = -x/2 + c/x**

## Bernoulli ( y' + P(x)*y + Q(x)*y^a = 0, a != 0, 1 )

*xy' - (1 - xy)y = 0*

Let's do some calculations to end up with the correct form.

xy' - y + xy^2 = 0 =>

y' - (1/x)y + y^2 = 0 [of the form: y' + P(x)y +Q(x)y^a = 0]

a = 2 and so we substitute using u = y^(1-2) = y^(-1) = 1/y.

u' = (-y')/y^2 =>

u' = u^2*[(1/x)(1/u) - 1/u^2] => ... =>

u' = - u/x + 1 => u' +(1/x)u = 1 [linear ODE]

To solve the linear we substitute using u = gU.

g = e^(-lnx) = 1/x

U = integral(1/(1/x))dx = integral(x)dx = x^2/2 + c.

That way u = 1/x * (x^2/2 + c) => u = x/2 + c/x

(almost the same as in the previous example)

By substituting y with 1/u we now get our final solution:

**y = 1 / (x/2 + c/x)**

## Riccati ( y' + P(x)*y^2 + Q(x)*y + R(x) = 0 )

*y' = 1 - x - x^2 + (1 + 2x^2) y - xy^2 and y1 = x one solution*

y1 = x = h.

We substitute using y = Y + h = Y + x.

y' = Y' + 1 =>

1 - x - x^2 + (1 + 2x^2) (Y+x) - x(Y + x)^2 = Y' + 1 =>

Y' + x(Y^2 + 2Yx + x^2) - (1+x^2)(Y+x) + x + x^3 = 0 => ... =>

Y' + xY^2 - Y = 0 => Y' - Y + xY^2 = 0 [Bernoulli ODE]

We substitute using u = Y^(1-2) = 1/Y => u' = -Y'/Y^2.

u' = -u^2*(1/u - x/u^2) =>

u' = -u + x => u' + u = x [Linear ODE]

So, we substitute again using u = gU.

g = e^(-integral(1dx)) = e^(-lnx) = 1/x.

U = integral(Q/g)dx = integral[x/(1/x)] dx = integral(x^2dx) = x^3/3 + c.

And so u = 1/x*(x^3/3 + c) = x^2/3 + c/x

Substituting back to Y we get:

Y = 1/u = 1/( x^2/3 + c/x)

And again to y we get:

y = Y + x =>

**y = 1/( x^2/3 + c/x) + x**

### Image sources:

### Previous posts of the series:

Introduction -> Definition and Applications

First-order part(1) -> Separable, homogeneous and exact 1st-order ODE's

First-order part(2) -> Linear, Bernoulli and Riccati first-order ODE's

And this is actually it!

Next time we will get into linear 2nd-order DE's with constant coeffs.

Bye bye!