Steply

Solve y' + 2xy = 4x, y(0) = 5

Step by step, with the reason for every step · The integrating factor · Differential Equations

Step by step

The question

Question: solve y′ + 2xy = 4x, with y(0) = 5.

y′ + 2xy = 4x

y(0) = 5 is the starting value.

y(0) = 5

1 Standard form

Linear means this form: y′ + P y = Q.

P and Q have only x.

linear: y′ + P(x) y = Q(x)

Here P = 2x and Q = 4x.

P = 2x, Q = 4x

2 The integrating factor

The integrating factor is e to the integral of P.

Multiplying by it makes the left side one derivative.

integrating factor: μ = e^(∫P dx)

First the integral of P: the integral of 2x is x².

∫ 2x dx = x2

So the integrating factor is e^(x²).

μ = e^(x²)

3 Multiply both sides

Multiply both sides by e^(x²).

Every term, on both sides.

e^(x²)y′ + 2xe^(x²)y = 4xe^(x²)

Careful!

The right side is multiplied by e^(x²) too.

Both sides, always.

Careful: not (e^(x²)y)′ = 4x ✗

4 One derivative on the left

By the product rule, the derivative of e^(x²) × y is exactly our left side.

(μy)′ = μy′ + μ′y
μ′ = 2xe^(x²)

So the left side is just (e^(x²)y)′: one derivative.

(e^(x²)y)′ = 4xe^(x²)

5 Integrate both sides

This integral needs u-substitution: the power's derivative, 2x, is outside.

u = x2, du = 2x dx

Integrate both sides.

The integral of a derivative is the function itself.

e^(x²)y = ∫ (4xe^(x²)) dx

On the right: 2e^(x²), and + C.

e^(x²)y = 2e^(x²) + C

6 Solve for y

Divide both sides by e^(x²).

y = 2e^(x²) + Ce^(x²)

Divide each term.

Dividing by e to a power is the same as e to minus that power.

y = 2 + Ce^(−x²)
C over e^(x²) = Ce^(−x²)

7 Use the starting value

Put in x = 0 and y = 5.

e⁰ = 1.

5 = 2 + C × 1

So C = 3.

C = 3

So y = 2 + 3e^(−x²).

y = 2 + 3e^(−x²)

8 Check

Let's check with a calculator.

At x = 1: y is about 3.104, and its slope about −2.207.

x = 1: y ≈ 3.104, slope ≈ −2.207

The equation wants y′ = Q − Py: about −2.207.

The same.

Right!

Q − Py: 4x − 2xy ≈ −2.207

Let's look back.

First: standard form.

Then: the integrating factor.

Then: multiply both sides.

Then: one derivative on the left.

Then: integrate both sides.

Then: solve for y.

Then: use the starting value.

Last: check.

Answer
y = 2 + 3e^(−x²)

Your turn

Try this one yourself, then check:

Solve y′ + 2xy = 2x
Show the answer
y = 1 + 3e^(−x²)

More from The integrating factor

The whole lesson: The integrating factor →