import sympy as sp
x = sp.Symbol("x")
y = sp.Function("y")
ode = sp.Eq(sp.diff(y(x), x) + 2 * y(x), 6)
sp.dsolve(ode)\(\displaystyle y{\left(x \right)} = C_{1} e^{- 2 x} + 3\)
First-order linear equations are another important solvable family. They may not separate easily, but they have a reliable method called an integrating factor.
After this lesson you should be able to:
p(x) and q(x);A first-order linear differential equation has the form
dy/dx + p(x)y = q(x)
The term p(x)y often represents feedback, decay, growth, resistance, or a proportional response to the current state. The term q(x) is often called a forcing or input term.
If the equation starts as
2 dy/dx + 6y = x
divide everything by 2 before identifying p(x) and q(x):
dy/dx + 3y = x/2
The integrating factor is
mu(x) = e^(∫ p(x) dx)
It is chosen so that after multiplying the equation by mu(x), the left side becomes
d/dx [mu(x)y]
That is the product rule working backward.
y' + p(x)y = q(x).mu(x)=e^(∫p(x)dx).mu(x).(mu y)'.mu(x) to solve for y.Solve
dy/dx + 2y = 6
Here p(x)=2, so
mu(x)=e^(∫2 dx)=e^(2x)
Multiply the equation by e^(2x):
e^(2x)y' + 2e^(2x)y = 6e^(2x)
The left side is a product derivative:
d/dx [e^(2x)y] = 6e^(2x)
Integrate:
e^(2x)y = 3e^(2x) + C
Divide by e^(2x):
y = 3 + Ce^(-2x)
The solution approaches 3 as x increases if C is finite.
Solve for x > 0:
dy/dx + (1/x)y = x
Here p(x)=1/x, so
mu(x)=e^(∫1/x dx)=e^(ln x)=x
Multiply by x:
x y' + y = x^2
The left side is (xy)', so
(xy)' = x^2
Integrate:
xy = x^3/3 + C
Divide by x:
y = x^2/3 + C/x
The restriction x > 0 matters because ln x appeared during the process.
q(x) instead of p(x) in the integrating factor.x > 0.Identify p(x) and q(x) in y' + 5y = sin(x).
Put 3y' + 6y = x into standard form.
Find the integrating factor for y' - 4y = x^2.
Explain why the left side becomes a product derivative after multiplying by the integrating factor.
p(x)=5, q(x)=sin(x).3: y' + 2y = x/3.p(x)=-4, so mu(x)=e^(-4x).mu y' + mu p(x)y.The integrating-factor method is reliable when you follow the same order every time. Most mistakes happen before the integration: wrong standard form, wrong p(x), or multiplying only part of the equation.
Guess first. In 4y' + 8y = 12x, is p(x) equal to 8 or 2?
Guided exercise.
First divide every term by 4:
4y' + 8y = 12x
y' + 2y = 3x
Now compare with y' + p(x)y = q(x):
p(x) = 2
q(x) = 3x
Checkpoint. Put 3y' - 6y = x^2 in standard form. Identify p(x) and q(x).
Guess first. For y' - 5y = x, should the exponent in the integrating factor be 5x or -5x?
Guided exercise.
p(x) = -5
mu(x) = e^(∫p(x) dx)
= e^(∫-5 dx)
= e^(-5x)
The sign comes from the coefficient of y in standard form.
Checkpoint. Find the integrating factor for y' + (2/x)y = x, assuming x > 0.
Guess first. After multiplying y' + 2y = 6 by e^{2x}, what product should appear on the left?
Guided exercise.
y' + 2y = 6
mu = e^(2x)
e^(2x)y' + 2e^(2x)y = 6e^(2x)
The left side is exactly the derivative of e^{2x}y:
d/dx[e^(2x)y] = e^(2x)y' + 2e^(2x)y
Checkpoint. For y' - 3y = 9, multiply by the integrating factor and write the left side as a product derivative.
Guess first. If (e^{2x}y)' = 6e^{2x}, what do you do next?
Guided exercise.
(e^(2x)y)' = 6e^(2x)
e^(2x)y = ∫6e^(2x) dx
e^(2x)y = 3e^(2x) + C
y = 3 + Ce^(-2x)
If y(0)=5, then:
5 = 3 + C
C = 2
The particular solution is y = 3 + 2e^{-2x}.
Checkpoint. Solve y' + y = 4, y(0)=1. Show the integrating factor, the product derivative, and the value of C.
SymPy’s dsolve can solve first-order linear equations.
\(\displaystyle y{\left(x \right)} = C_{1} e^{- 2 x} + 3\)
Use edumath to generate integrating-factor practice.