Chapter 6 Differential Equations

6.1 Introduction

Differential equations arise nearly every time we try to model real world phenomena using mathematics. We recall that the derivative measures the of one quantity with regards to another. Newton’s second law says:

The rate of change of momentum of a body is equal to the applied external force.

Newton’s 2nd Law

The momentum of a body is the product of the mass m and the velocity v (in one dimension). Thus, if a body is experiencing a force F then Newton’s law can be written mathematically as ddt(mv)=F. Thus we get an equation involving differentiation, and such an equation we call a differential equation. You have already met simple differential equations of the form (6.1)dfdt=g(t), for then the answer is f(t)=f(a)+atg(x)dx. It is important that we know the value of f at some point, or else we cannot exactly say what f is. We need a constant of integration. Below we have a picture where we can see that all these functions have the same derivative, so to choose which is the right one for our situation we have to know a point through which the function goes.

Different constants of integration

Here is a web page with more examples of differential equations Differential equations at Mathisfun.com

6.1.1 The cultural heritage of mathematics

6.2 Separable equations

The next most straightforward sort of differential equation that we can solve is one of the form (6.2)dydx=f(x)g(y), for then we can write dyg(y)=f(x)dx. We still need a boundary condition (we will assume that x and y are spatial variables here). We can integrate both of these in principle to get a solution.

Example 6.1
Constant of integration

A projectile moving upwards is subject to a force due to gravity equal to mg where m is its mass, and g is acceleration due to gravity. It is also slowed down by an air resistance which is equal to mkv, where v is its speed and k is some positive real constant which depends on the geometry of the projectile. The speed of the projectile at time t=0 is u (this is the initial condition).

Newton’s second law says ddt(mv)=mkvmg. Since m is constant in this equation (the projectile does not change mass as it flies) we can cancel m from both sides above to get dvdt=(kv+g). This is separable. Rearranging we have the equation dvkv+g=dt. Integrating both sides we have 1klog(kv+g)=t+C, where C is a constant of integration that we find using the initial condition. When t=0 v=u so that 1klog(ku+g)=C. Thus 1klog(kv+g)=t+1klog(ku+g). Rearranging the above equation we have t=1k(log(ku+g)log(kv+g))=1klog(ku+gkv+g). Thus exp(kt)=(ku+gkv+g). Multiplying both sides by kv+g we have kvexp(kt)+gexp(kt)=ku+g. Hence kvexp(kt)=ku+g(1exp(kt)), so that v=uexp(kt)+gk(exp(kt)1).
Remark. Check that this solves the original equation.

You can find more examples of separable equations and their solutions at Math24.net.

Example 6.2 Find the general solution of the separable differential equation y=y(1y).

The equation is separable with f(x)=1 and g(y)=y(1y). Now g(y)=0 if and only if y=0 or y=1. So the equation can be solved by separating variables in the three intervals y<0, 0<y<1), and y>1. On any such interval, we have: dyy(1y)=dx+C1, with C1R. This means that (1y+11y)dy=dx+C1. Therefore ln|y|ln|1y|=x+C1ln|y1y|=x+C1, and taking the exponential of both sides we have |y1y|=exp(x+C1)=exp(C1)exp(x). Since C1 is constant, exp(C1)>0 is also constant. Let us call this C2. Then, |y1y|=C2exp(x). Now, y/(1y) is positve if 0<y<1. In this case |y1y|=y1y=C2exp(x), so that y=C2exp(x)C2exp(x)+1=exp(x)exp(x)+1/C2,C2>0.

Now y/(1y) is negative if y<0 or y>1. In this case
|y1y|=y1y=C2exp(x), so that y=C2exp(x)C2exp(x)1=exp(x)exp(x)1/C2C2>0. Now, if exp(x)>1/C2, i.e. x>log(C2), then y>1, and if x<log(C2), then y<0. Hence we will have a vertical aymptote in y at x=log(C2).

Remark IN the picture above you can see where the asymptotes are by the wierd jum in the graph. I have left this in, so that you can see how the solution changes from negative to greater than 1 as we move through log(C2). The situation seen with the previous example is typical of separable equations. You always need to examine the case g(y)=0 separately. Notice that if g(y)=0 then y=0 thanks to the differential Equation (6.2). So the values y for which g(y)=0 are constant stationary solutions of the equation.

We can get a qualitative (behavioural) understanding of the solutions of these sort of equations by drawing the so-called direction fields.

Example 6.3 Sketch the direction field for the equation y=y(1y).

We have g(x,y)=y(1y). We have seen already in Example 6.2 that y=0 and y=1 corresponding to zero rate of change (slope is horizontal) are stationary solutions. For y<0 and y>1 we have g(x,y)<0 (negative slope) and for 0<y<1 we have g(x,y)>0 (positive slope). Thus qualitatively we can depict the equation’s direction fields as in the figure below.
Direction filed Direction fields and sketches of a few integral curves for Example ??

6.2.1 Test yourself

6.2.1.1 Equations of the form dydx=axy and dydx=ayx

6.2.1.2 Equations of the form dydx=1+y2a+bx

6.3 Linear first order equations

The main idea behind solving these equations is to rearrange the equation into (6.3)dydx+p(x)y(x)=q(x), and to try to turn the left hand side into the derivative of a product.

Recall that ddx(I(x)y(x))=I(x)dydx+y(x)dIdx. Multiply (6.3) by I(x) (we use I because this is going to be called the integrating factor) and then try to make it look like the equation above. Multiplying by I(x) gives I(x)dydx+I(x)p(x)y(x)=I(x)q(x) We want I(x)dydx+I(x)p(x)y(x)I(x)dydx+y(x)dIdx. For this to be true we need I(x)p(x)=dIdx. This is a separable equation: dII=p(x)dx, which we solve to give logI=p(x)dx, so that (6.4)I(x)=exp(p(x)dx).

Thus we have the following theorem:

Example 6.4 Let us try this out with Example 6.2. The equation we had was dvdt=kvg.

We rearrange the last equation to get it into our standard form dvdt+kv=g. which is a linear differential equation for v. The function p(x)=k and q(x)=g. Hence I(t)=exp((k)dt)=exp(kt). Then ddt(exp(kt)v)=kexp(kt)v+exp(kt)dvdx=exp(kt)(dvdt+kv)=gexp(kt). If we integrate both sides we have exp(kt)v=gkexp(kt)+C, where c is a constant of integration. The general solution (multiple both sides by exp(kt)) is v=gk+Cexp(kt). We now use the initial condition that v=u when t=0 to give u=gk+C, in other words C=u+gk. Dividing both sides by exp(kt) we get v=uexp(kt)+gk(1exp(kt)), which is the same result as before.

Example 6.5 Solve the differential equation dydx+2yx=x2, where y(1)=0.

In this case the integrating factor is I(x)=exp(2xdx)=exp(2logx)=exp(logx2)=x2. So ddx(x2y)=x2dydx+2xy=x2(dydx+2yx)=x2(x2)=x4. Hence x2y=x55+C, where C is a constant of integration. Thus we have a general solution y=x35+Cx2. We now use the boundary condition y(1)=0 to find a particular solution, giving C=1/5.

You can find more examples of linear first order differential equations at math24.net.

6.3.1 Test yourself

6.4 Homogeneous equations

In this case we put v=y/x so that y=vx. Then dydx=ddx(vx)=v+xdvdx=f(v). Hence we have a separable equation dvf(v)v=dxx=log(|x|). We can solve this if we can integrate the left hand side.

Example 6.6 Find the general solution of the differential equation dydx=x2+y2xy.

If we divide top and bottom by x2 on the right hand side we get dydx=1+(y/x)2(y/x). In this case the function f(v)=(1+v2)/v=1/v+v. If we make the change of variable y/x=v, we have xdvdx+v=1+v2v. Rearranging this we get xdvdx=1v+vv=1v. Hence vdv=dxx so that v22=log|x|+C=logA|x|, where A=eC>0. Therefore v=±2logAx, where A is an arbitrary positive constant of integration. In order for this to make sense we require that2logA|x|>0, so that |x|>1/A. However v=y/x, so that y=±x2logA|x|,|x|>1/A, is the general solution of the differential equation. We will choose a solution branch depending on where the initial condition is. For instance, y(x)>0 for positive x then we have to choose the positive square root. But if y(x)<0 for positive x we have to choose the negative square root. In the picture below we plot solutions where y(1)=1 (blue) and y(1)=1 (red).

You can find more examples of homogeneous equations and their solutions at Math24.net

6.5 Second order linear differential equations with constant coefficients

The most well-known example of a second order equation with constant coefficients is the harmonic oscillator. In this equation we use Newtons’ second law, but use the fact that the velocity is the rate of change of the position of an object. So we have for acceleration a, velocity v and displacement x, the following relationships a=dvdt=d2xdt2, and v=dxdt.

Hooke’s Law for modelling the motion of a spring

For a spring we have Hooke’s Law which says that if we extend a spring by an amount x from its natural resting position, then the force of resistance to extension of the spring is kx, where k is a constant called the stiffness of the spring.

Thus, if we have a mass m on a spring then the downward force will be mg and the upward force due to the tension in the spring when extended distance l will be kl. If kl=mg then we will have no net force acting and the mass can be stationary. If we extend the spring by a further small distance x and let it go then it will move upwards due to the excess tension in the spring over the weight. The equation of motion is ddt(mv)=k(l+x)+mg. Since kl=mg we get the equation mdvdt=kx. Substituting v=dxdt we obtain the equation (6.5)d2xdt2=kmx. This is a famous differential equation called the equation of simple harmonic motion. This is an example of a second order linear differential equation with constant coefficients. Here is an explanation from a man with an American accent.

We solve equations like these by using the property of the exponential function that we discovered earlier - that these are eigenfunctions of the differentiation operator. We try a solution of the type x(t)=Aexp(λt), for some λ. Let us substitute this into our differential equation and see what happens.

Now dxdt=Aλexp(λt), and d2xdt2=Aλ2exp(λt). Substituting this into (6.5) we get Aλ2exp(λt)=km(Aexp(λt)). Cancelling Aexp(λt)0, we obtain λ2=km. The solution of this equation is λ2=±ikm. Therefore the solution of the differential equation is x=Aexp(ikm)+Bexp(ikm), for arbitrary constant A,B (to be determined by initial conditions). Using the equations exp(iθ)=cosθ+isinθ, we can rewrite this as x=A[cos(km)+isin(km)]+B[cos(km)+isin(km)]=A[cos(km)+isin(km)]+B[cos(km)isin(km)]=(A+B)cos(km)+i(AB)sin(km). So we see we have two different solution cos(km) and sin(km), and the constants A+B and i(AB) depend on the boundary conditions.

Remark. You should check that these two functions satisfy the original differential equation. They are as it is impossible to make a combination of them (except the zero combination) identically equal to 0.

More generally we may have a second order differential equation of the following form ad2ydx2+bdydx+cy=g(x). It is easiest in the first instance if we assume g(x)=0. Such an equation is called a homogeneous differential equation. Then, if we follow the same strategy as above, trying a solution of the form y=eλx, we change the differential equation to the algebraic equation aλ2+bλ+c=0. This equation is called the auxiliary equation.

The solution of the auxiliary equation can be in three different forms depending on the sign of the discriminant b24ac.

Case 1: The easy case: b24ac>0. In this case the two roots of the auxiliary equation are real: λ±=b±b24ac2a, and the general solution of the homogeneous equation is y=Aexp(λ+x)+Bexp(λx), where A and B are arbitrary real constants, which can be determined from boundary conditions.

Example 6.7 Find the general solution of the linear second order differential equation d2ydx2+3dydx+2y=0.

The auxiliary equation is λ2+3λ+2=0, which has solutions λ1=1 and λ2=2. Hence the general solution to this differential equation is y=Aexp(x)+Bexp(2x). Suppose that y(0)=1 and y(0)=0. Then y(0)=A+B=1, and y(0)=A2B=0. We can solve these simultaneous equations to get A=2 and B=1, so that y=2exp(x)exp(2x).

Case 2: b24ac=0. In this case we have two equal roots, λ=b/(2a). Then we have a general solution of the form y=Aexp(λx)+Bxexp(λx). You should check that this is true.

Example 6.8 Find the general solution of the linear second order differential equation d2ydx22dydx+y=0. The auxiliary equation is λ22λ+1=0, which has solution λ=1. Hence the general solution to this differential equation is y=Aexp(x)+Bxexp(x). Suppose that y(0)=2 and y(0)=1. Then y(0)=A=2, and y(0)=A+B=1, so that B=1. Hence the solution in this case is y=2exp(x)xexp(x).

Case 3: b2<4ac. In this case the solutions of the auxiliary equation are complex: λ±=B2A±i4acb22a=λR±iλI, where λR=b2a and λI=4acb22a. The general solution is then y=exp(λRx)(Acos(λIx)+Bsin(λIx)). Again you should check that this is true.

Example 6.9 Find the general solution of the linear second order differential equation d2ydx2+2dydx+3y=0. The auxiliary equation is λ2+2λ+3=0, which has solution λ=1±i2. So λR=1 and λI=2. Hence the general solution to this differential equation is y=exp(x)(Acos(2x)+Bsin(2x)). Suppose that y(0)=1 and y(0)=0. Then y(0)=A=1, and y(0)=A+2B=0, so that B=1/2. Hence the solution in this case is y=exp(x)(cos(2x)+12sin(2x)).
Video revising solution of second order differential equations

6.5.1 Test yourself

6.6 Challenge Yourself

  1. Explore the solution of the Bernoulli equation y+p(x)y=q(x)yn, for n0.
  2. In this question you are going to approximately solve the differential equation y=y, y(0)=2, using the limit definition of differentiation. Let h=0.1. Find the approximate value of y(h) using the approximation y(h)y(0)h=y(0)=y(0), where the second equation follows from the differential equation y=y. Compare the approximate answer to the actual answer by analytically solving the differential equation. Now find approximate values at ih for i1. What happens to the solution as h0.
  3. Can you find an approximation to d2ydx2 at a point a by using y(ah), y(a) and y(a+h). Suppose you know y(a) and y(a). If you have a second order differential equation d2ydx2=y, can you find y(ah) and y(a+h)?
  4. Do some research into second order differential equations with a non-zero right hand side: Ad2ydx2+Bdydx+Cy=g(x).