Linear equations and the integrating factor ·… | StemPy Lab
Course 13.2·Lesson 3 of 3
Linear equations and the integrating factor
A linear first-order equation has the form dxdy+Py=Q
Lesson 3 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
write a linear equation in the standard form and find its integrating factor;
solve it, with the constant fixed from a point;
solve the same kind of equation with x as the unknown function of y, and read the transient and the steady state.
Pour hot water into a mug
You pour hot water into a mug in a cool room. The temperature falls towards the room temperature. The rate of fall depends on how far the water is above the room. An equation of the type dxdy+ay=b describes this, and the solution settles to a fixed value. The simulation below shows how.
An equation is linear (of the first order) when y and dxdy appear only to the first power and are not multiplied together. In standard form
dxdy+Py=Q,
where P and Q are functions of x, or constants. The coefficient of dxdy must be 1. If it is not, divide first.
Where the integrating factor comes from
The product rule says dxd(Iy)=Idxdy+dxdIy. Multiply the standard form by a function I(x):
Idxdy+IPy=IQ.
The left side becomes dxd(Iy) if dxdI=IP. This is a separable equation for I, and its solution is I=e∫Pdx. We need only one such I, so no constant is added. This I is the integrating factor (IF). Now
dxd(Iy)=IQ⟹Iy=∫IQdx+C.
The steps
Standard form. Divide so that the equation reads dxdy+Py=Q.
Integrating factor.I=e∫Pdx.
Integrate.Iy=∫IQdx+C.
Divide by I. The constant is divided too. Then use the point to fix C.
The same method works when x is the unknown. The equation dydx+P1x=Q1, with P1 and Q1 functions of y, has the integrating factor e∫P1dy and the solution x⋅IF=∫Q1⋅IFdy+C.
Worked examples
Example 1. Solve xdxdy+2y=x2 for x>0.
Divide by x: dxdy+x2y=x. So P=x2.
I=e∫2/xdx=e2lnx=x2.
x2y=∫x2⋅xdx=4x4+C.
Divide by x2: y=4x2+x2C.
Example 2. Solve dxdy+ytanx=sin2x for −2π<x<2π.
P=tanx, so I=e∫tanxdx=elnsecx=secx.
ysecx=∫sin2xsecxdx. Since sin2x=2sinxcosx, the integrand is 2sinx.
ysecx=−2cosx+C, so y=−2cos2x+Ccosx.
Example 3. Solve ydx+(x−y3)dy=0 for y>0. Here x is the unknown.
Divide by ydy: dydx+yx=y2. So P1=y1 and the IF is y.
xy=∫y⋅y2dy=4y4+C.
Example 4. Transient and steady state. Solve dxdy+2y=6 with y=−2 at x=0.
I=e2x. So dxd(ye2x)=6e2x and ye2x=3e2x+C.
y=3+Ce−2x. At x=0: −2=3+C, so C=−5.
y=3−5e−2x.
The term 3 is the steady state, because it stays when time passes. The term −5e−2x is the transient, which dies away. Whatever the start, every solution settles to y=3.
A graph of solutions of dy/dx + 2y = 6 for x from 0 to 3. A red dashed horizontal line marks the steady state y = 3. Five blue curves start at y = -2, 0, 1, 5 and 8 on the vertical axis, and all of them bend towards the red line and are almost on it by x = 2. An orange dotted curve starts at -5 and rises to 0: it is the transient part, minus 5 times e to the power minus 2x.
Practise with new numbers
Try it in Python
Euler's method steps along the slope: ynext=y+hf(x,y). The program uses it on dxdy+2y=x with y(0)=1, and compares the result with the exact answer from the integrating factor.
Common mistakes
Not dividing first. In xdxdy+2y=x2 the coefficient of dxdy is x, so P=x2, not 2.
A wrong integrating factor. Check dxdI=IP. For P=x2 we get I=x2, not 2x.
Not multiplying the right side by I. The integral is ∫IQdx, not ∫Qdx.
Forgetting to divide the constant. In y=4x2+x2C the constant is divided by I too.
Using the method on a nonlinear equation. A term such as y2 or ydxdy breaks linearity.
Remember these
Standard form: dxdy+Py=Q. Integrating factor: I=e∫Pdx.
Iy=∫IQdx+C.
For dydx+P1x=Q1 use e∫P1dy.
A solution is a transient part, which fades, plus a steady part.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Find the integrating factor of dxdy+x3y=x2 for x>0.