import sympy as sp
x = sp.Symbol("x")
y = sp.Function("y")
ode = sp.Eq(sp.diff(y(x), x), 2 * x * y(x))
sp.dsolve(ode)\(\displaystyle y{\left(x \right)} = C_{1} e^{x^{2}}\)
A separable differential equation is one of the most friendly kinds of ODEs. It can be rearranged so all terms involving y stay with dy, and all terms involving x stay with dx.
After this lesson you should be able to:
A separable equation can be written as
dy/dx = g(x)h(y)
When h(y) is not zero, rearrange it as
1/h(y) dy = g(x) dx
Then integrate both sides.
Separate, integrate, simplify, use the initial condition, then check.
x part and the y part.y expressions to the side with dy.x expressions to the side with dx.y if the algebra is reasonable.Solve
dy/dt = ky
where k is a constant.
Separate variables:
1/y dy = k dt
Integrate:
ln|y| = kt + C
Exponentiate both sides:
|y| = e^(kt+C) = e^C e^(kt)
The constant can absorb the sign and e^C, so we write
y = Ce^(kt)
This is the familiar exponential growth or decay family.
Solve
dy/dx = 2xy, y(0)=3
Separate:
1/y dy = 2x dx
Integrate:
ln|y| = x^2 + C
Convert to exponential form:
y = C e^(x^2)
Use y(0)=3:
3 = C e^0
C = 3
So the particular solution is
y = 3e^(x^2)
Solve
dy/dx = x y^2
If y is not zero, divide by y^2:
y^(-2) dy = x dx
Integrate:
-1/y = x^2/2 + C
This gives a family of nonzero solutions. But the original equation also has y=0 as a solution, because both sides become zero. Dividing by y^2 would hide that solution.
When you divide by an expression involving y, ask whether that expression could equal zero. If yes, check whether a constant solution was lost.
Is dy/dx = x(1+y^2) separable?
Separate dy/dx = x y^3.
Solve dy/dx = 4y with y(0)=2.
What constant solution might be lost when solving dy/dx = y(5-y) by dividing by y(5-y)?
g(x)h(y) with g(x)=x and h(y)=1+y^2.y^(-3) dy = x dx.y = Ce^(4x), and y(0)=2 gives C=2, so y=2e^(4x).y=0 and y=5 are equilibrium solutions.A separable-equation solution should read like a careful algebra story: classify, separate, integrate, solve for the constant, and check for lost solutions.
Guess first. Is dy/dx = x(1 + y^2) separable?
Guided exercise.
A separable equation can be written as g(x)h(y). Here
dy/dx = x(1 + y^2)
has g(x)=x and h(y)=1+y^2, so it is separable.
Checkpoint. Decide whether each is separable: y' = x^2 y, y' = x + y, and y' = sin(x) e^y.
Guess first. For dy/dx = 3xy, what should be divided away from the right side?
Guided exercise.
dy/dx = 3xy
(1/y) dy/dx = 3x divide by y, assuming y != 0
(1/y) dy = 3x dx multiply by dx
Now the y expression is with dy, and the x expression is with dx.
Checkpoint. Separate dy/dx = x^2 y^3. State the value of y that needs special attention before dividing.
Guess first. When integrating (1/y) dy = 3x dx, which side produces a logarithm?
Guided exercise.
(1/y) dy = 3x dx
∫(1/y) dy = ∫3x dx
ln|y| = (3/2)x^2 + C
y = C e^((3/2)x^2)
The constant changes form after exponentiating; that is normal.
Checkpoint. Solve the separated equation y^{-2} dy = 4x dx for y if possible. Keep a constant of integration.
Guess first. If y = C e^{x^2} and y(0)=5, what is C?
Guided exercise.
5 = C e^(0^2)
5 = C
So y = 5e^{x^2}. Check by differentiating:
y' = 5e^(x^2) * 2x = 2xy
That matches dy/dx = 2xy.
Checkpoint. Solve dy/dx = -2xy, y(0)=4. Differentiate your answer and substitute it into the original ODE.
SymPy can solve many separable equations with dsolve.
\(\displaystyle y{\left(x \right)} = C_{1} e^{x^{2}}\)
You can also build deterministic practice with edumath.