First Order ODEs
Contents
13. First Order ODEs¶
Definition
In general a first order ordinary differential equation (ODE) is of the form:
where \(f(x,\,y)\) is some function, which can in general have \(x\) and \(y\) dependance.
13.1. Separation of variables form¶
Of all the techniques for solving first order ODEs, separation of variables is the simplest to understand, being essentially a direct application of Fundamental Theorem of Calculus. The technique requires us to take a look at whether the variable dependence can be totally separated on different sides of the equation.
Definition
A separable first order ODE is of the form:
where we have separated out the \(x\) dependance into the function \(f(x)\) and \(y\) dependance into the function \(g(y)\). Using the FTC we find:
which we can then be integrated:
and then we would rearrange to (if possible) find \(y(x)\).
Practice questions
Decide which of the following expressions are separable, and have a go at solving those that are separable:
1. \(\displaystyle (1+e^x)y\frac{\mathrm{d}y}{\mathrm{d}x} = e^x\)
2. \(\displaystyle \frac{\mathrm{d}y}{\mathrm{d}x} = (3x + 2y + 1)^2\)
3. \(\displaystyle \frac{1}{x} + x\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{\mathrm{d}y}{\mathrm{d}x}\)
4. \(\displaystyle \frac{x}{y}\frac{\mathrm{d}y}{\mathrm{d}x} = x^2 - 1\)
5. \(\displaystyle x^2\frac{\mathrm{d}y}{\mathrm{d}x} = y^2 - 1\)
6. \(\displaystyle xy\frac{\mathrm{d}y}{\mathrm{d}x} = \ln(x),\ y(1)=0,\ x \geq 1\)
7. The rate of growth of a population 𝑃 is proportional to itself. Set up and solve a differential equation for the population, given that the initial population is \(P_0\) and it doubles after 10 years.
Solutions
1. Rearranging and separating out variables:
This can then just be integrated:
2. This problem is not separable.
3.
If we use partial fractions we find that this fraction can be simplified:
which we can integrate to find:
4.
5.
If we use partial fractions, we can reduce the fraction on the LHS down to:
and so to solve:
which after some rearrangement gives:
6.
If \(y(1) = 0 \Rightarrow C = 0\) so solution is:
7. The differential equation will therefore have the form:
Which can be separated to:
If \(P(10) = 2P_0 \Rightarrow \lambda = \displaystyle \frac{1}{10}\ln(2)\), so the solution is:
13.2. Integrating factor form¶
The integrating factor technique can be written down in the form of an algorithm:
1. Compute the integrating factor \(\displaystyle \mu(x) = e^{\int f(x) \,\mathrm{d}x}\).
2. Multiply the whole ODE by \(\mu(x)\):
3. We find that the left-hand-side can be rewritten as a derivative \(\displaystyle \frac{\mathrm{d}}{\mathrm{d}x}(\mu\, y)\):
4. Integrate both sides with respect to \(x\):
5. Rearrange to find \(y(x)\):
where \(C\) is a constant.
Worked example
Consider the following differential equation:
A quick check will show that this equation is not separable. If we try to integrate directly, then we obtain:
We can deal with the integral on the right (in principle) but the term \(\displaystyle \int \frac{y}{x}\mathrm{d}x\) appearing on the left cannot be evaluated without knowing \(y\), so this is a dead end.
But observe that we can multiply equation (13.4) throughout by \(x\), to obtain:
The expression on the left-hand side is an exact derivative:
Neat - this means that we can integrate equation (13.5) to obtain:
The final solution therefore is:
where \(k\) is an arbitrary constant.
If we want to verify that the solution satisfies equation (13.4):
Practice questions
In each of the following, determine whether the left-hand side is in the form of an exact derivative. If it is, then go ahead and solve the problem by direct integration. If the left hand side is not an exact differential then you do not have to solve the problem.
1.
2.
3.
Solve the following ODE problems using the integrating factor technique:
4.
5.
Solutions
1. The LHS is given by the exact derivative \(\displaystyle \frac{\mathrm{d}}{\mathrm{d}x}\left(y\, e^{\cos(x)}\right)\) and so the solution to this problem can be found by direct integration. The result is;
where \(k\) is an arbitrary constant.
2. The LHS is not an exact derivative.
However if we multiply throughout by a factor \(\mu = \text{sech}^2(x)\) then we obtain:
Now the LHS can be written as an exact derivative \(\frac{\mathrm{d}}{\mathrm{d}x}(\text{sech}(x)y)\) and so the problem can be solved by direct integration.
3. The LHS is given by the exact derivative \(\displaystyle \frac{\mathrm{d}}{\mathrm{d}x}(\tan(x)y)\) and so the solution to the problem is:
where \(k\) is an arbitrary constant.
4.
First divide through by \(x\) to put the ODE into the correct form, assuming that \(x \neq 0\):
Comparing this form to the template equation we see that \(\displaystyle f(x) = \frac{2}{x}\) and so:
The IF is
and multiplying through by the IF gives:
The left-hand side is now an exact derivative of \((x^2y)\)! We can write the modified equation as:
Finally, integrating both sides with respect to \(x\) gives:
where \(K\) is an arbritary constant. We can verify that the solution works by substituting it into the original ODE.
5. Firstly rearrange this equation to:
The IF is:
Multiplying through by the IF gives:
Integrating with respect to \(x\) to solve:
where \(K\) is an arbritary constant.
13.3. Perfect differential form¶
If we are struggling to find a first order ODE method that works and has clearly integrable terms, we can try the perfect differential test.
Recall from the multivariable change rule, the total differential of a function \(f(x,\,y)\) is:
now if we examine the most general form of a first order ODE:
which we can rewrite as:
we can see that these bear a striking resembalance and remember that if:
then this is a perfect differential, where here \(\mathrm{d}f = 0\) and so:
where \(C\) is a constant.
Worked example
Lets try to solve the non-linear, first order ODE:
we find that we can identify:
so we check that the partial derivatives agree:
which they do and therefore we want to obtain the function \(f(x,\, y)\):
which we can see will agree if \(g(y) = 0,\, h(x) = -x\):
and given that here \(f(x,\,y) = C\), where \(C\) is a constant, this means that we have:
Practice questions
1. Solve the non-linear ODE:
with the condition \(y(0) = 1\).
2. Solve the non-linear ODE:
with the condition \(y(0) = 1\).
Solutions
1. First write in total differential form:
then check that this is an exact differential:
this condition is met and so to detemine \(f(x,\, y)\):
which agree if \(g(y) = h(x) = 0\), therefore:
where \(C\) is a constant. Given the condition \(y(0) = 1\):
which we could then solve to find \(y(x)\), as this is quadratic \(xy^2 + y\,e^{-x^2} - 1 = 0\):
2. First write in total differential form:
then check that this is an exact differential:
this condition is met and so to detemine \(f(x,\, y)\):
We could attempt the same process on \(f_y\) however this will involve multiple integration by parts calculations (we could simplify this with a reduction formula \(\int y^n\,e^{axy}\,\mathrm{d}y\)), but here we will instead differentiate this preliminary expression for \(f(x,\,y)\) and then compare \(f_y\) with what is left to figure out the anti-derivative:
which tells us that \(g'(y) = 0\) hence at most \(g(y)\) is a constant, which we can absorb into the constant value for \(f(x,\, y)\), therefore:
where \(C\) is a constant. Given the condition \(y(0) = 1\):
Thus the solution is:
Which we have to leave in this form as no simple elementary function solution exists.
13.3.1. Fixing the perfect form¶
This method relies on the differential given being perfect, if it is not, then we cannot find the function \(f(x,\, y)\). However there is an analagous method for finding a multivariable integrating factor, allowing us to potentially convert imperfect differentials into a perfect form .
The form of the multivariable integrating factor means that:
Solving the key requirement for a perfect differential:
our aim here is separate out variables. If each of \(P(x,\,y),\, Q(x,\,y)\) are in a separable form:
which means therefore:
where \(C\) is a constant. We find that this expression is a constant, because although the LHS depends only on \(y\), the RHS does not, hence the LHS is overall a constant in \(y\). A similar argument holds for \(x\) and the RHS, meaning that overall the two expressions are constant. This mean therefore:
Worked example
Consider the differential:
Looking at the derivatives:
hence this is not an exact differential.
However since here the functions \(P(x,\,y),\, Q(x,\,y)\) are separable, we can find:
This means that our differential function is satisfied by:
and so \(K_1 = K_2\) are constants here, which we can absorb into the constant for \(f(x,\,y)\):
where \(K\) will be fixed by initial conditions, however \(C\) is a system parameter - it shows that this systems integrating factor is not unique! We could simplify this down to:
13.4. Substitution methods¶
We sometimes find that we can reduce more complicated (even non-linear) first order differential equations down to a solvable form using a substitution.
13.4.1. \(y' = f(y/x)\) form¶
Definition
A homogeneous first order differential equation is one of the form:
and this is typically one that, through a substitution, can be solved using separation of variables. Let our substitution here be \(u = \displaystyle\frac{y}{x}\):
and depending on the complexity of this LHS integral, this problem is solvable!
Worked example
Solve the ODE \(\displaystyle \frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x^2 + y^2}{xy}\).
Rewriting this to be in the form \(y' = f(y/x) = f(u)\), means:
This is now in a form for separation of variables and integrating:
Remember that before finishing the question, we must convert this back into \(y(x)\):
Practice questions
1. Solve the following ODEs:
a.
with condition \(y(1) = 1\).
b.
with condition \(y(1) =\displaystyle \frac{\pi}{4}\).
Solutions
1. Solve the following ODEs
a. Rearrange to get into the form \(y' = f(y/x) = f(u)\):
and then use the result \(y' = xu' + u\):
Using the condition \(y(1) = 1\):
gives the final solution:
b. Rearrange to get into the form \(y' = f(y/x) = f(u)\):
and then use the result \(y' = xu' + u\):
using the fact that \((\cot(u))' = -\text{cosec}^2(u)\), this means:
Using condition \(y(1) = \displaystyle \frac{\pi}{4}\):
gives a solution:
and we could simplify further even:
13.4.2. \(y' = f(ax+by)\) form¶
Definition
A first order differential equation of the form:
can also be solved through a substitution which leads to separation of variables. Let our substitution here be \(u = ax+by\):
and depending on the complexity of this LHS integral, this problem is solvable!
Practice questions
1. Solve the following ODEs:
a.
with condition \(y(0) = 2\).
b.
with condition \(y(0) = 0\).
Solutions
1. Solve the following ODEs
a. Writing this in the form \(y' = f(ax+by) = f(u)\):
means we can pick our substitution to be \(u = 4x - y\):
This integrand can be represented in terms of partial fractions:
For \(u = 1\), \(4A = 1 \Rightarrow A = \displaystyle \frac{1}{4}\) and for \(u = -3\), \(-4B = 1 \Rightarrow B = \displaystyle -\frac{1}{4}\), hence:
We then need to think about converting this back into \(u = u(x,\,y)\), so lets try to collect together terms:
and using the condition \(y(0) = 2\):
giving a final solution of the form:
b. Writing in the form \(y' = f(ax+by) = f(u)\):
which suggests we pick a substitution \(u = 9y - x\):
separating out the variables:
and using the condition \(y(0) = 0\):
hence the final solution is:
13.4.3. Benoulli form¶
Defintion
A Benoulli differential equation takes the form:
We see that for \(n = 0,\, 1\) this reduces to cases already discussed, but for any other \(n\) this equation is clearly non-linear in \(y\).
We can make progress in solving these sorts of ODEs by using the substitution:
which transforms (13.6) into a linear differential equation, since:
and as this ODE is linear in \(u\), it can be solved using the integrating factor method.
Worked example
If we want to solve the ODE:
we need to put it in the form \(y' = f(u,\,x)\):
as the highest power on the RHS is \(n=2\), using the substitution \(u = y^{1-n} = y^{-1}\):
and therefore:
which we can then solve using the IF method, with \(\mu = e^{\int -1/x\,\mathrm{d}x} = e^{-\ln|x|} = \frac{1}{x}\):
where we must not forget to return the answer back to the form of \(y(x)\) at the end (if possible).
Practice questions
1. Solve the following ODEs:
a.
which satisfies the condition \(y(0) = -2\).
b.
which satisfies the condition \(y(1) = 0\),
Solutions
a.
since the highest power on the RHS is \(n = 4\), this means the substitution we need is \(u = y^{1-n} = y^{-3}\) and hence:
which suggests an IF of the form \(\mu = \displaystyle e^{\int\,\mathrm{d}x} = e^x\), hence:
Using the condition \(y(0)=-2\):
meaning the final solution is:
b.
since the highest power on the RHS is \(n = \frac{1}{2}\), this means the substitution we need is \(u = y^{1-n} = y^{1/2}\) and hence:
which suggests an IF of the form \(\mu = \displaystyle e^{\int\frac{1}{2x}\,\mathrm{d}x} = e^{\frac{1}{2}\ln|x|} = x^{1/2}\), hence:
Using the condition \(y(1)=0\):
meaning the final solution is:
13.4.4. Riccati form¶
Defintion
A Riccati differential equation takes the form:
which we can recast in terms of a variable \(u(x)\), which satisfies an ODE:
and we can solve to find \(y(x)\):
Using the transformation \(v = p\,y\) we find:
and then switching to the variable \(u(x)\), where \(v = -\displaystyle \frac{1}{u}\frac{\mathrm{d}u}{\mathrm{d}x}\) means:
We see that if \(r=0\), then this just reduces to a Benoulli equation with \(n=2\) and if \(p=0\), then this is just in integrating form factor, so this equation can be thought of as a hybrid between the two.
Worked example
Consider the ODE:
this equation can be rewritten as:
and then transformed into the 2nd order ODE:
which we can solve using an IF method, with \(\mu = e^{-\int 4/x\,\mathrm{d}x} = x^{-4}\):
Since the derivative of a constant is zero, this means:
where \(C_1,\, C_2\) are constants. We can tidy this expression up:
and \(C_3\) is a constant.
We note that this problem has \(r(x) = 0\), therefore is also a Bernoulli type expression, with highest power \(y^2\), so \(u = y^{1-2} = y^{-1}\):
which is also solveable using an IF, \(\mu = \displaystyle e^{\int \frac{2}{x}\,\mathrm{d}x} = x^2\):
which agrees with the earlier result.
Whilst this method is good at converting a non-linear 1st order ODE into a linear 2nd order ODE, most of the time the resulting equation will need some quite powerful techinques to solve, especially if \(R(x)\) and \(S(x)\) are both functions of \(x\).