Week 1 and 2: 1st-order ODE
Contents
Week 1 and 2: 1st-order ODE¶
What is an ODE¶
For any equation, which shares the form of
and x is the only independent variable (or in plain language: coordinate), then it’s called an ordinary differential equation. We can also use different forms to represent the differential terms ex: \(y'\) or \(y^{(n)}\), where n indicates how many times we take the derivative of y with respect to x. An ODE can be found in many places such as calculating the trajectory of a moving object, the temperature/energy change of a system (e.g., how the Earth temperature change in response to greenhouse gas radiative forcing), the transverse circulation of tropical cyclones, the overturning circulation of ITCZ, and even used in a more general concept of dynamical systems. Solving an ODE is exactly finding its integrated form e.g., represent y as a function x without any differential operator (\(\frac{d}{dx}\)).
1st-order ODE¶
According to how many times we take the derivative of y, we can decide the order of differential equations. In general, we are more likely to find the analytical solution in a lower order problem. (and it’s impossible to find an analytical solution when the order is higher than 5. I will leave this question to readers.) Luckily, in most cases, we only need to worry about 1st- and 2nd-order ODEs while higher order problems are relatively rare. More details about how to solve a higher order ODE was covered in Numerical Analysis and the end of this course. Based on the order of ODE, different amounts of boundary (initial) conditions are required. For example, for a moving object with a constant velocity (\(\frac{dx}{dt}=c\)), we need to know where it starts to precisely calculate its path. Otherwise, we can only know how far it travels but have no idea where it ends. From the above example, we can see for an 1st-order ODE, we need at least 1 boundary (initial) condition i.e., \(x_0=?\). Following similar veins, we need 2 initial conditions for a 2nd-order ODE (i.e., \(x^{''}=a\), if \(x^{''}\) represents acceleration, then \(x(t=0)=x_0\) is the initial condition for location and \(x'(t=0)=x'_0\) is the initial velocity) and so on and so forth…
For an 1st-order ODE, we can further categorize it according to its forms, which can help us find the proper way to solve it. Some common forms of 1st-order ODE including (but not limited to):
Forms of ODE
– Separable form: \(\frac{dy}{dx}=F(x)G(y)\)
– Linear form: \(y'+p(x)y=q(x)\)
– Exact form: \(M(x,y)dx+N(x,y)dy=0\) where \(\frac{d M(x,y)}{d y }=\frac{d N(x,y)}{d x }\)
– Homogeneous form: \(y'=f(y/x)\)
– Bernoulli form: \(y'+P(x)y=R(x)y^n\)
– Riccati form: \(y'=P(x)y^2+Q(x)y+R(x)\)
we will walk through each of these in details. One should notice that it is possible to have multiple ways to approach one problem. Categorizing the problems only helps us do it more efficiently but we can certainly solve the problem in different ways.
Categories of 1st-order ODE¶
Separable form¶
For any ODE, which can be rearranged as the following form,
we call it a separable ODE. There is a very straightforward way to solve this kind ODE. We can simply move all of the terms related to y to the left hand side and the terms related to x to the right hand. i.e.,
by integrating both sides of (3), we can have.
The readers can complete the last few steps to derive a form of \(y=f(x)\).
Example 1
Using separable form to solve the following ODE, \(\frac{dy}{dx}=(1-y)x\)
We can first reorganize the equation to have
then replace \(dy\) with \(d(1-y)\) by using the relation \(d(1-y)=-dy\)
Integrate both side of the equation, we can have
and
Example 2
In this example, we will walk through a more practical case: terminal velocity. For a free-falling object, it experiences two forces: gravity (mg) and drag from the air \(\alpha v^2\). Usually, the drag is proportional to the velocity square and counteracts the gravity (hint: we ignore buoyancy here which is a very important term when the falling object has a density close to the air). Therefore, we can write down the following equation to represent balance between different forces
By rearranging the equation, we can have
We can partition the left hand side and make it into an integratable form
and
Similarly, using the relation \(d\sqrt{\frac{\alpha}{gm}}v =\sqrt{\frac{\alpha}{gm}}dv\), we can have
which gives us
Rearranging the equation again, we can have the final solution
we can test if we derive the right answer by substituting t with \(\infty\). The corresponding velocity is so-called terminal velocity.
Note
when all three forces are all considered (gravity, buoyancy, and drag). It will lead to Rayleigh-Bernard convection, which is an important atmospheric phenomenon. The Lorenz 69 chaos model, also know as the butterfly model, is a reduced dimension of Rayleigh-Bernard convection.
Linear ODE¶
Linear 1st-order ODE is one of the most widely used ODEs in our field, since it’s easy to approach and can be solved (numerically or analytically) in most cases. To tell if an ODE is linear or not, we can simply check its operator.
For example, the following equation
we can find that both 3 operators, \(\frac{d}{dx}\), \(p(x)\), and \(q(x)\) are not a function of y. Therefore, this ODE is linear. We can also use traditional way of testing linear operator i.e., \(L(Ay)=AL(y)\), \(L(-y)=-L(y)\), and \(L(y_1+y_2)=L(y_1)+L(y_2)\), where L is the operator that we would like to test, to examine if the whole equation is linear.
For a linear ODE, the easiest way to approach it is using integrating factor. i.e., multiply the whole equation by \(\mathrm{e}^{\int p(x)dx}\). This leads to
By integrating both side of (6) and reorganizing it, we can have the final form
Now let’s take a look of an example in thermodynamics.
Example 3
In the first law of thermodynamics equation, we have
where \(c_v\) is specific heat in constant volume, \(\mathrm{dQ}\) is the heat exchange, and \(\mathrm{Pd\alpha}\) is the work done by pressure.
Using the relation \(\mathrm{dP\alpha} = \mathrm{Pd\alpha}+\mathrm{\alpha dP}\) as well as the ideal gas law, \(\mathrm{P\alpha}=RT\). we can rewrite the above equation to
or
where \(c_p=c_v+R\)
Then divide the whole equation by \(\mathrm{c_p }\), we can have
By rearranging the equation,
one can find the integrating factor \(=-\mathrm{\frac{R}{c_p}\frac{dP}{P}}\).
Following the traditions, we multiply the entire equation by \(\mathrm{e}^{\int{-\mathrm{\frac{R}{c_p}\frac{dP}{P}}}}\) or \(\mathrm{e}^{\int{-\mathrm{\frac{R}{c_p}d ln (p)}}}\) and integrate both side to have the final form of thermodynamics equation
One can easily find that as long as \(dQ=0\) (adiabatic), the left hand side of the equation above is always conserved. This term is called potential temperature, which is a very important thermodynamics variable in atmospheric science.
Exact Form¶
Exact equation is a special type of ODE, where we can’t implicitly write down a solution as a function of independent variable. For example, \(e^{y}sin(x)+2y=x^2\), where no differential form exists. In such case, it is usually impossible to approach the problem using integrating factor or separation of variable
It usually shares the form of
For this type of ODE, we can test if a potential function \(\varphi\) can be found, which satisfies the following definition.
Then solving for the potential function is equivalent to solving the ODE. This can be proofed by substituting \(M(x,y)\) and \(N(x,y)\) in (8) with the definitions in (9), which gives us
One can carry out the integration of (10) to find the solution.
Here we provide a quick way to test if a potential function exists or not. By inspecting (9), one can easily find that a potential function exists only if \(\frac{\partial M(x,y)}{\partial y}=\frac{\partial N(x,y)}{\partial x}=\frac{\partial ^2 \varphi}{\partial x\partial y}\)
Example 4
Use Exact form to solve the following ODE
Let \(M(x,y)=\mathrm{e^x sin(y)}-2x\) and \(N(x,y)=\mathrm{e^x cos(y)}+1\), we can find that \(\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}\) indicating the existence of a potential function.
To find the corresponding potential function, we can integrate \(M(x,y)\) with respect to \(x\) and \(N(x,y)\) with respect to \(y\) i.e.,
and
comparing the above two equations, we can see that \(a(y)=y\) and \(b(x)=-x^2\). Therefore, the potential function is \(\mathrm{e^x sin(y)}-x^2+y+c\)
Homogeneous Form¶
In applied math and atmospheric science, you will learn a lot homogeneous terms. All of them have different meanings. In ODE, the homogeneous form indicates that the equation follows a certain form or can be rearranged to a certain form. i.e.,
When a equation is characterized with the form of (11), we can use separation of equation to solve an ODE. For example, if we let \(u=\frac{y}{x}\), it leads to \(y'=(ux)'=u'x+u=f(u)\). The whole equation can be written as
By inspecting (12), we can find that it has a separable form
and integrate both sides of (13) will yield the final solution.
Example 5
Here we use a pursuit problem as an example. A pursuit problem is widely used in ballistics or calculating the trajectory of a moving object, which is usually subject to a constant forcing e.g., gravity or background flow. It also has some applications in atmospheric sciences when we are calculating the direction of Rossby wave energy dispersion.
Let’s say…if today there is a swimmer who would like to cross a river from point A to point B (see figure below). The current has a constant speed of \(s\). During his swim, he always faced point B (i.e., the angle of \(\alpha\) is changing). \(\mathrm{v}\) is swimmer’s velocity in a vector form. The question is… can we determine the trajectory of the swimmer i.e., y(x).
To solve this problem, let’s first write down the information that we already had. First, we know the x velocity and y velocity can be written as:
by inspecting the equation above, we can find that \(x\) and \(y\) are connected through \(v\) and \(\alpha\). From the FIG1, we also know
Combining all of these equations, we have
Now, we can easily find that it has a homogeneous form, where right hand side is merely a function of \(\frac{y}{x}\).
Let \(y=ux\), and \(y'=u'x+u\), we have
rearrange the equation
Integrating both side of the equations can give us
and remove \(\mathrm{ln}\)
To obtain \(u\), we can first move \(u\) to the right hand side and take the square of both sides of the equation, which gives us
and this leads to the final solution
from this, we can obtain
From the boundary value \(y(x=w)=0\), we know \(K=w^{\frac{s}{v}}\)
Bernoulli Form¶
While most of the techniques above can be applied to a linear ODE problem, it is necessary to consider non-linear cases. In general, certain coordinate transformation will be applied to the ODE and make it linear at the first place. The following example is the well-known Bernoulli equation,
where n is an integer.
An easy way to make it linear is defining another variable \(v=y^{1-n}\). The derivative of \(v\) is \(v'=(1-n)y^{-n}y'\). This gives us
or
One can easily find that (15) is a linear ODE which we can approach with integrating factor. By multiplying both sides of equation with \(e^{\int(1-n)P(x)dx}\). We have
which further leads to
Riccati Form¶
Riccati form is another special case of 1st-order ODE, which shares a similar form with Bernoulli differential equation and linear ODE.
One can see that when \(P(x)=0\), (19) is linear. On the other hand, if \(R(x)=0\), we will have a Bernoulli equation. Unfortunately, Riccati form can’t be solved with the approaches that we use to solve the other two equations. However, we can take advantage of both approaches. In applied math I, we have learned that if we can find a particular solution, we can get rid of \(R(x)\). As long as we get rid of \(R(x)\), the entire equation can be solved by using the same procedure as we solve the Bernoulli equation.
Based on this concept, we can first assume the solution is the combination of two solutions. Let
where \(S(x)\) is a particular solution and \(\frac{1}{z}\) comes from how we solve the Bernoulli form. By substituting (20) into (19), we can have
Expand the whole equation and we can see that
Since \(S(x)\) is a solution of (19), we can rewrite (22) into.
By multiplying both sides of equation with \(-\frac{1}{z^2}\) and reorganizing it, we have
Using integrating factor \(e^{\int 2P(x)S(x)+Q(x) dx}\), we have
this will lead to the final solution of z
then substitute (26) back to (20), we can have the solution of \(y\)