Solutions to 1st-order ODEs
1. Solution by direct integration¶
When equations are of this form, we can directly integrate:
dxdy∫dyy(x)=y′=f(x)=∫f(x)dx=∫f(x)dx+C For example:
dxdyy(x)=x2=31x3+C While these problems look simple, there may not be an obvious closed-form solution to all:
dxdyy(x)=e−x2=∫e−x2dx+C (You may recognize this as leading to the error function, erf:
21πerf(x)+C,
so the exact solution to the integral over the range [0,1] is 0.7468.)
2. Solution by separation of variables¶
If the given derivative is a separate function of x and y, then we can solve via separation of variables:
dxdy∫g(y)1dy=f(x)g(y)=j(y)h(x)=∫f(x)dx For example, consider this problem:
y′=dxdy=1+y2 We can separate this into a problem that looks like f(y)dy=g(x)dx, where dy=1+y21 and g(x)=1.
∫1+y2dyarctanyy(x)=∫dx=x+c=tan(x+c) Unfortunately, not every separable ODE can be integrated:
dxdy(y2+cosy)dy=y2+cosyex/2+5=(ex/2+5)dx 3. General solution to linear 1st-order ODEs¶
Given a general linear 1st-order ODE of the form
dxdy+p(x)y=q(x) we can solve by integration factor:
y(x)=e−∫p(x)dx[∫e∫p(x)dxq(x)dx+C] For example, in this equation
y′+xy−5ex=0 after rearranging to the standard form
y′+xy=5ex we see that p(x)=x and q(x)=5ex.
4. Solution to nonlinear 1st-order ODEs¶
Given a general nonlinear 1st-order ODE
dxdy+p(x)y=q(x)ya where a=1 and a is a constant. This is known as the Bernoulli equation.
We can solve by transforming to a linear equation, by changing the dependent variable from y to z:
letzdxdz=y1−a=(1−a)y−adxdy Multiply the original equation by (1−a)y−a:
(1−a)y−adxdy+(1−a)y−ap(x)ydxdz+p(x)(1−a)z=(1−a)y−aq(x)ya=q(x)(1−a), which is now a linear first-order ODE, that looks like
dxdz+p(x)′z=q(x)′ where p(x)′=(1−a)p(x) and q(x)′=(1−a)q(x).
We can solve this using the integrating-factor approach discussed above. Then, once we have z(x), we can find y(x):
zy=y1−a=z1−a1