This tutorial was made solely for the purpose of education and it was designed for students taking Applied Math 0340. It is primarily for students who have some experience using Mathematica. If you have never used Mathematica before and would like to learn more of the basics for this computer algebra system, it is strongly recommended looking at the APMA 0330 tutorial. As a friendly reminder, don't forget to clear variables in use and/or the kernel. The Mathematica commands in this tutorial are all written in bold black font, while Mathematica output is in regular fonts.

Finally, you can copy and paste all commands into your Mathematica notebook, change the parameters, and run them because the tutorial is under the terms of the GNU General Public License (GPL). You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately. The tutorial accompanies the textbook Applied Differential Equations. The Primary Course by Vladimir Dobrushkin, CRC Press, 2015;

Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to the main page for the first course APMA0330
Return to the main page for the second course APMA0340
Return to Part VII of the course APMA0340
Introduction to Linear Algebra with Mathematica


Example 1: The scaled equations (see Hal L. Smith and Paul Waltman, The Theory of the Chemostat: Dynamics of Microbial Competition, Cambridge University Press, 1995) for the growth of two populations of microorganisms x1 and x2, with corresponding parameters ai and mi, i=1,2, in a chemostat are

\[ \begin{cases} \frac{{\text d}S}{{\text d}t} &= 1 - S - \frac{m_1 S\,x_1}{a_1 +S} - \frac{m_2 S\,x_2}{a_2 +S} , \\ \frac{{\text d}x_1}{{\text d}t} &= x_1 \left( \frac{m_1 S}{a_1 +S} - 1 \right) , \\ \frac{{\text d}x_2}{{\text d}t} &= x_2 \left( \frac{m_2 S}{a_2 +S} - 1 \right) , \end{cases} \qquad\qquad S(0) \ge 0, \quad x_1 (0) > 0, \quad x_2 (0) > 0. \]
Here S(t) denotes the concentration of the nutrient at time t. Letting Σ = a - S - x1 - x2, we can see that
\[ \begin{cases} \frac{{\text d}\Sigma}{{\text d}t} &= - \Sigma , \\ \frac{{\text d}x_1}{{\text d}t} &= x_1 \left( \frac{m_1 \left( 1- \Sigma - x_1 - x_2 \right)}{a_1 + 1 - \Sigma - x_1 - x_2} - 1 \right) , \\ \frac{{\text d}x_2}{{\text d}t} &= x_2 \left( \frac{m_2 \left( 1- \Sigma - x_1 - x_2 \right)}{a_2 + 1 - \Sigma - x_1 - x_2} - 1 \right) , \end{cases} \qquad\qquad \Sigma (0) \le 1 , \quad x_1 (0) > 0, \quad x_2 (0) > 0. \]
It can be shown that
\[ \lim_{t\to \infty} \Sigma (t) =0 , \]
where the convergence is exponential. Introducing the break-even concentrations
\[ \lambda = \frac{a}{m-1} , \]
the trajectories on the set Σ=0 satisfy
\[ \begin{cases} \frac{{\text d}x_1}{{\text d}t} &= x_1 \left( \frac{m_1 \left( 1 - x_1 - x_2 \right)}{a_1 +1 -x_1 - x_2} -1 \right) , \\ \frac{{\text d}x_2}{{\text d}t} &= x_2 \left( \frac{m_2 \left( 1 - x_1 - x_2 \right)}{a_2 +1 -x_1 - x_2} -1 \right) , \end{cases} \qquad\qquad x_1 (0) > 0, \quad x_2 (0) > 0, \quad x_1 + x_2 \le 1; \]
\[ \begin{cases} \frac{{\text d}x_1}{{\text d}t} &= x_1 \, \frac{m_1 -1}{1+ a_1 -x_1 - x_2} \left( 1- \lambda_1 - x_1 - x_2 \right) , \\ \frac{{\text d}x_2}{{\text d}t} &= x_2 \, \frac{m_2 -1}{1+ a_2 -x_1 - x_2} \left( 1- \lambda_2 - x_1 - x_2 \right) , \end{cases} \qquad\qquad x_1 (0) > 0, \quad x_2 (0) > 0, \quad x_1 + x_2 \le 1. \]
The above system has three equilibrium solutions:
\[ E_0 = (0,0), \qquad E_1 = (1- \lambda_1 , 0), \qquad E_2 = (0,1-\lambda_2 ) . \]
If λ1 is different from λ2, then there is no "interior" rest point, that is, a rest point with both components positive. The only interesting cases are where mi > 1 and 0 < λi < 1 for i = 1,2.
Theorem: Suppose that mi > 1, i = 1,2, and that 0 < λ1 < λ2 < 1. Then any solution of the above chemostat system with xi > 0 satisfies
\begin{eqnarray*} \lim_{t\to \infty} S(t) &=& \lambda_1 , \\ \lim_{t\to \infty} x_1 (t) &=& 1- \lambda_1 , \\ \lim_{t\to \infty} x_2 (t) &=& 0. \end{eqnarray*}

Example 2: A standard single-species logistic model with continuous constant dispersal rate between two heterogeneous patches can be written as follows

\begin{eqnarray*} \frac{{\text d}N_1}{{\text d}t} &=& r_1 N_1 \left( 1 - \frac{N_1}{M_1} \right) - m\,N_1 + m \left( 1 - \delta \right) N_2 , \\ \frac{{\text d}N_2}{{\text d}t} &=& r_2 N_2 \left( 1 - \frac{N_2}{M_2} \right) - m\,N_2 + m \left( 1 - \delta \right) N_1 , \end{eqnarray*}
where N1, N2 represents the population density in the corresponding habitat at time t, ri and Mi are the intrinsic rate of population increase and the carrying capacity of population with index i, δ is the fraction of migrants dying during migration and m is the emigration rate, a constant. Above dispersal model may be used to characterize the mobility of bird or, insect    ■

Example 3: N. Gregory Mankiw, David Romer, and David Weil created a human capital augmented version of the Solow–Swan model that can explain the failure of international investment to flow to poor countries. In this model output and the marginal product of capital (K) are lower in poor countries because they have less human capital than rich countries.

The mode is augmentation by human capital shares some similarities with the basic model but, on the other hand, it solves some problems imposed by the latter. They are summarized as follows: There is still no long run growth of GDP per capita due to the presence of decreasing returns to capital accumulation. There is still no role for technological progress or the latter, if any, cannot be explained. Convergence to the steady-state is slower as human capital accumulation partly offsets the impact of decreasing returns to physical investments. It is equivalent to allowing for a broader capital share in the Solow model. The slower convergence rate is in conformity with the real-life pattern.

On the empirical side, the MRW model is usually solved by a restricted regression equation that relates the GDP per capita or working age population to the inputs of production. The saving rate s is measured by the share of overall or business k investments in GDP. The parameter s is calculated h as the average percentage of the working-age population in secondary school over a long time period. Mankiw et al. relate the latter over the period 1960-1985 to GDP per working age person in 1985.

Similar to the textbook Solow–Swan model, the production function is of Cobb–Douglas type:

\[ Y(t) = A * K(t)^{\alpha} * L(t)^{1-\alpha} \]
The MRW model uses its modification
\[ Y(t) = A * K(t)^{\alpha} * H(t)^{\beta} * L(t)^{1-\alpha - \beta} , \]
\begin{align*} L(t) &= L(0) * e^{nt} , \\ A(t) &= a(0) * e^{gt} , \end{align*}
representing labor supply and level of technology, growing exogenously at rates n and g.

Thus k, denoting the stock of human capital and h, representing the stock of human capital can be derived, and then modified to represent the steady state.

\[ \dot{k} = s_k * y_t - \left( n + g + \delta \right) * k_t , \tag{3.1} \]
\[ \dot{h} = s_h * y_t - \left( n + g + \delta \right) h_t . \tag{3.2} \]
The equilibrium position is
\[ k^{\ast} = \left( \frac{s^{1-\beta}_k * s^{\beta}_h}{n+g+ \delta} \right)^{1/(1-\alpha - \beta )} \tag{3.3} \]
\[ h^{\ast} = \left( \frac{s^{\alpha}_k * s^{1 -\alpha}_h}{n+g+ \delta} \right)^{1/(1-\alpha - \beta )} \tag{3.4} \]

Example 4: The Ramsey–Cass–Koopmans model, or Ramsey growth model, is a neoclassical model of economic growth based primarily on the work of Frank P. Ramsey (1903--1930), with significant extensions by David Cass (1937--2008) and Tjalling Koopmans (1910--1985).

The Ramsey-Cass-Koopsmans model is an economic growth model written by Frank Ramseywith extensions by David Cass and Tjalling Koopmans. It is built on another famous economicmodel, the Solow-Swan model, and the goal of the model is to act as a social planning tool bytrying to maximize consumption over many successive generations.

Let f(k) = kα be a production function measuring therelative economic output in terms of k and a capital elasticity parameter α (the responsiveness of the output production to changes in the input capital).

ϕ be the growth rate of labor productivity (for example, due to technological innovation or efficiency improvements).

ξ be the growth rate of labor supply (for example, due to migration or population increase).

δ be the depreciation rate of capital (for example,due to inflation).

θ be an elasticity parameter indicating the tendencyof consumers to smooth out their consumption over time.

ρ be the rate at which consumers discount theirfuture consumption (for example, by indicating a preference for immediate consumption or attempting to preserve their long-term average onsumption).

The Ramsey-Cass Koopmans Model is composed of two coupled differential equations

\[ \frac{{\text d}k}{{\text d}t} = f(k) -c-k \left( \phi + \xi + \delta \right) , \]
\[ \frac{{\text d}c}{{\text d}t} = \frac{c}{\rho} \left( f' (k) - \theta - \xi\delta - \rho\phi \right) . \]
The former equation models the rate of change of per capita wealth, k, with respect to time. The latter models the rate of change of per capita consumption, c, with respect to time.

We can find its steady state (k*, c* ) by setting both derivatives to zero. This when solved would lead us to the steady state equations of \( f_k (k^{\ast}) = \delta + \rho \) and \( c^{\ast} = f(k^{\ast}) - \left( \phi + \delta \right) k^{\ast} . \)

The Jacobian of this system of equations becomes

\[ {\bf J} \left( k^{\ast}, c^{\ast} \right) = \begin{bmatrix} \rho - \phi & -1 \\ \frac{1}{\theta}\,f_{kk} (k^{\ast}) c^{\ast} & \phantom{-}0 \end{bmatrix}. \]
  1. Cass, David (1965). "Optimum Growth in an Aggregative Model of Capital Accumulation". Review of Economic Studies. 32 (3): 233–240. doi:10.2307/2295827
  2. Gourinchas, P.-O., The Ramsey-Cass-Koopmans Model, Berkely.
  3. Koopmans, T. C. (1965). "On the Concept of Optimal Economic Growth". The Economic Approach to Development Planning. Chicago: Rand McNally. pp. 225–287.
  4. Ramsey, Frank P. (1928). "A Mathematical Theory of Saving". Economic Journal. 38 (152): 543–559. doi:10.2307/2224098


Return to Mathematica page
Return to the main page (APMA0340)
Return to the Part 1 Matrix Algebra
Return to the Part 2 Linear Systems of Ordinary Differential Equations
Return to the Part 3 Non-linear Systems of Ordinary Differential Equations
Return to the Part 4 Numerical Methods
Return to the Part 5 Fourier Series
Return to the Part 6 Partial Differential Equations
Return to the Part 7 Special Functions