1 Introduction

Spectral methods belong to the class of discretization schemes for differential equations and are based on the choice of trial functions—also called expansion or approximating functions—and test functions—also called weight functions. As described in [4], trial functions are used as the basis functions for a truncated series expansion of the solution. Using a truncated expansion instead of the exact solution generates an error, called residual. Test functions are used to minimize the residual with respect to a norm or an orthogonality condition (specific to the chosen test function).

The method employed (Galerkin, collocation, or tau) and the choice of the trial functions are features that characterize particular spectral methods. Moreover, the choice of trial functions is what actually distinguishes spectral methods from finite element and finite difference methods. In this survey, we will employ a tau method choosing the Chebyshev polynomials as trial functions. For this reason, the spectral method we will describe is called Chebyshev-\(\tau\) method [5]. This method takes advantage of the orthogonality of Chebyshev polynomials with respect to a suitable scalar product to discretize the differential eigenvalue problem. Moreover, Chebyshev polynomials are particularly efficient for discretizing a differential problem because they exhibit some very nice recursive properties, as we will see in this survey.

For many years, spectral methods have been successfully used in many hydrodynamic stability problems (see [6,7,8,9,10,11]) and many authors have pointed out the advantages and disadvantages of spectral methods applied to stability problems (see [5, 12,13,14,15,16]). Particular attention has been devoted to the Chebyshev-\(\tau\) method as it finds eigenvalues and the eigenfunctions of a differential problem very efficiently. Despite the method being able to determine as many eigenvalues as required, in many stability problems one may only be interested in determining the dominant eigenvalue, which generates the most destabilizing mode [5].

This survey is intended to show, in a pedagogical manner, how to implement the Chebyshev-\(\tau\) method. Besides a comprehensive description of the theoretical basis for the method, we will provide detailed procedures for discretizing the differential problem. Moreover, we will describe the algorithms we employed to solve some classical convection problems.

The onset of convection in clear fluids and fluid-saturated porous media is a widely studied problem due to its theoretical and practical implications (in geophysics, engineering fields and so on, see, for instance, [17,18,19,20,21,22,23,24]). When dealing with convection problems, the aim is to determine conditions for the onset of convection via linear instability and nonlinear stability analyses of the motionless state (thermal conduction solution). These conditions involve a dimensionless control parameter, the Rayleigh number \({\textsf{R}}\) and, in particular, its threshold value \({\textsf{R}}_c\). The linear analysis provides a sufficient condition for convection to arise: if \({\textsf{R}}>{\textsf{R}}_c\), then instability occurs. Hence, to determine \({\textsf{R}}_c\), the differential eigenvalue problem arising from the linear instability analysis of the conduction solution needs to be solved. However, in some cases, the resolution of the resulting eigenvalue problem requires a numerical approach since, analytically, one would encounter huge difficulties. One of the numerical approaches is the Chebyshev-\(\tau\) method (see [25,26,27,28,29,30]).

The survey is organized as follows: in Chapter 2, the physical phenomenon of thermal convection is described and mathematical models for cases of interest are presented. Chapter 3 is devoted to introducing Chebyshev polynomials, their key properties and theoretical aspects of the Chebyshev-\(\tau\) method. In Chapter 4 algorithms to implement the method are shown in detail and applications to interesting hydrodynamics stability problems are developed. Finally, further numerical results are shown in Chapter 5 for the more curious reader.

2 Physical and mathematical setup

When a horizontal layer of fluid at rest is uniformly heated from below, a temperature gradient is generated across it and the heat is transmitted by conduction. On the other hand, the fluid particles near the lower boundary tend to expand and, therefore, the buoyancy force (once a certain critical value of the temperature gradient has been exceeded) will overcome the braking action of the viscous and gravitational forces, generating a convective motion. As we anticipated in the introduction, the mathematical analysis suggests that the onset of convection is related to a dimensionless number, called Rayleigh number \({\textsf{R}}\). This number gives a measure of the destabilizing effect of the buoyancy over the stabilizing effect of molecular diffusion of momentum. Once the Rayleigh number exceeds a critical value \({\textsf{R}}_c\), the heat will be transmitted by convection and a regular pattern of convective cells will form within the layer. Since the fluid motion is periodic in each of these cells, the perturbation fields are required to be periodic functions in the horizontal directions x and y, with period \(2 \pi / a_x\) and \(2 \pi / a_y\), respectively. Therefore, solutions can be assumed as two-dimensional periodic waves with an associated wavenumber \(a^2=a^2_x+a_y^2\). In particular, the motionless state solution (the conduction solution) is stable if it is stable with respect to all disturbances, and instability will result from its instability to disturbances of just one wavenumber \(a^2_c\). The pair \((a^2_c,{\textsf{R}}_c)\) detects the marginal stability state, where \(a^2_c\) is such that if the basic solution is stable with respect to perturbations with \(a^2_c\), it will be stable with respect to perturbations with all other wavenumbers (see [1, 3]).

When the fluid saturates a porous medium, we speak of convection in porous media, while if it can flow freely in the layer, we speak of convection in clear fluid.

When the fluid density exhibits a density inversion phenomenon, i.e. the fluid density has a maximum inside the layer, a potentially unstable layer of fluid lies below a layer that is stably stratified. When convection occurs in the lower layer, the motion will penetrate into the stable upper layer, and we speak of penetrative convection in clear fluid and, if the fluid saturates a porous medium, of penetrative convection in porous media. All these convection problems are analysed in the present survey.

In the above-mentioned problems, fluid properties are defined as constants. Nevertheless, in some industrial applications, fluid properties are subject to sensible variations. Viscosity is one of the main features which experiences a remarkable dependence on temperature and, as a first approximation, on depth (see [31]). The definition of viscosity as a function of depth leads to interesting computational aspects. For this reason, the convection in porous media with depth-dependent viscosity problem is analysed in this survey.

2.1 Convection in clear fluids

The phenomenon of the onset of convection in a clear, incompressible, non-isothermal Newtonian fluid is known as Rayleigh–Bénard convection, and the related problem is known as the Bénard problem (see [1, chap. II] and [2, chap. 3]). One can show that the following equations govern the linear instability and the nonlinear stability of the conduction solution (see [1, pag. 26] and [2, pag. 54]):

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)^2W-{\textsf{R}} a^2 \Theta =0,\\ (D^2-a^2)\Theta +{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(1)

where, from now on, \(z\in (0,1)\), \(D^2=\tfrac{\textrm{d}^2}{\textrm{d}z^2}\) and functions \(W=W(z)\) e \(\Theta =\Theta (z)\) are obtained by separating off the z dependence from the temperature perturbation and the vertical component of the velocity perturbation, respectively. Finally, \({\textsf{R}}^2\) is the Rayleigh number and, for a fixed fluid, is given by (see [2, pag. 51]):

$$\begin{aligned} {\textsf{R}}^2=\dfrac{\alpha g \beta d^4}{\kappa \nu }, \end{aligned}$$
(2)

where g is the modulus of gravitational acceleration, \(\beta =\tfrac{T_L-T_U}{d}>0\) is the adverse temperature gradient, d is the layer thickness, \(\kappa\) is the thermal diffusivity, and \(\alpha\) and \(\nu\) are the coefficient of thermal expansion and the kinematic viscosity of the fluid, respectively. System (1) is of order six and so we require six boundary conditions. The following four conditions are frequently enforced:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(3)

The final two boundary conditions depend on what type of surfaces bound the fluid layer. The three cases usually considered are (see [1, pag. 21] for a derivation of the following conditions):

  1. (i)

    free–free, bottom and top surface free:

    $$\begin{aligned} D^2W(0)=D^2W(1)=0, \end{aligned}$$
    (4)
  2. (ii)

    rigid–rigid, bottom and top surface fixed:

    $$\begin{aligned} DW(0)=DW(1)=0, \end{aligned}$$
    (5)
  3. (iii)

    rigid-free, bottom surface fixed, top surface free:

    $$\begin{aligned} DW(0)=D^2W(1)=0. \end{aligned}$$
    (6)

Notice that for every fixed wavenumber, system (1) forms a generalized eigenvalue problem for the Rayleigh number. Indeed, the system can be rewritten in matrix form as follows:

$$\begin{aligned} \left( \begin{array}{cc} (D^2-a^2)^2 &{}0\\ 0 &{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{cc} 0&{}a^2\\ -1&{}0 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(7)

that is, more briefly and with evident meaning of the symbols:

$$\begin{aligned} A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}. \end{aligned}$$
(8)

Let \({\textsf{R}}_c\) be the smallest positive eigenvalue satisfying system (8). It can be shown that \({\textsf{R}}<{\textsf{R}}_c\) is a necessary and sufficient condition for the stability of the conduction solution [1], and hence, \({\textsf{R}}_c\) is called the critical Rayleigh number for the onset of convective motions. \({\textsf{R}}_c\) is determined by solving the following minimum problem:

$$\begin{aligned} {\textsf{R}}_c^{\texttt {B}}=\min _{a^2\in {\mathbb {R}}^+} \{ {\textsf{R}}^2(a^2) | \, {\textsf{R}} \ \text {verifies} \ (7) \}. \end{aligned}$$
(9)

It turns out that for the problem under examination the critical Rayleigh number for the onset of instabilities in the case of two free boundaries (4) is analytically determinable (see [1, pag. 36]), and it is actually:

$$\begin{aligned} {\textsf{R}}_c^{\texttt {B}}=\frac{27\pi ^4}{4}\simeq 657.5114, \end{aligned}$$
(10)

in correspondence with the critical wavenumber:

$$\begin{aligned} a^2_c=\frac{\pi ^2}{2}\simeq 4.9348. \end{aligned}$$
(11)

2.2 Convection in porous media

The phenomenon of the onset of convection in a porous medium saturated by an incompressible, non-isothermal Newtonian fluid is known as Rayleigh–Bénard convection in porous media, and the related problem is known as the Bénard problem for the Darcy equation or the Horton–Rogers–Lapwood problem (see [2, chap. 4] and [3, chap. 6]). One can show that the following equations govern the linear instability and the nonlinear stability of the conduction solution (see [2, pag. 68]):

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)W+{\textsf{R}} a^2 \Theta =0,\\ (D^2-a^2)\Theta +{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(12)

where \({\textsf{R}}^2\) is the Rayleigh number and, for given fluid and porous medium, is defined as ([2, pag. 64]):

$$\begin{aligned} {\textsf{R}}^2=\dfrac{\alpha g\beta k d^2}{\kappa \nu }, \end{aligned}$$
(13)

where k is the permeability of the porous medium. System (12) is of order four, so we require four boundary conditions, namely

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(14)

For every fixed wavenumber, system (12) forms a generalized eigenvalue problem for the Rayleigh number. Indeed, the system can be rewritten in matrix form as follows:

$$\begin{aligned} \left( \begin{array}{cc} D^2-a^2 &{}0\\ 0 &{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{cc} 0&{}-a^2\\ -1&{}0 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(15)

that is:

$$\begin{aligned} A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}. \end{aligned}$$
(16)

Let \({\textsf{R}}_c\) be the smallest positive eigenvalue satisfying system (16). Condition \({\textsf{R}}<{\textsf{R}}_c\) is a necessary and sufficient condition for the stability of the conductive solution [3]. The critical Rayleigh number \({\textsf{R}}_c\) for the onset of convection is determined by solving the following minimum problem:

$$\begin{aligned} {\textsf{R}}_c^{\texttt {HRL}}=\min _{a^2\in {\mathbb {R}}^+} \{ {\textsf{R}}^2(a^2) | \, {\textsf{R}} \ \text {verifies} \ (15) \}. \end{aligned}$$
(17)

It turns out that for the problem under examination the critical Rayleigh number for the onset of instabilities is analytically determinable (see [2, pag. 69] and [3, pag. 245]), and it is actually:

$$\begin{aligned} {\textsf{R}}_c^{\texttt {HRL}}=4\pi ^2\simeq 39.4784, \end{aligned}$$
(18)

in correspondence with the critical wavenumber:

$$\begin{aligned} a^2_c=\pi ^2\simeq 9.8696. \end{aligned}$$
(19)

2.3 Penetrative convection in clear fluids

One can show that the following equations govern the linear instability of the penetrative convection in clear fluid problem (see [32, pag. 235]):

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)^2W+2{\textsf{R}} a^2(\zeta -z) \Theta =0,\\ (D^2-a^2)\Theta -{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(20)

where \(\zeta =\tfrac{4}{T_U}\), with \(T_U\ge 4^\circ C\) temperature of the upper layer. The Rayleigh number \({\textsf{R}}^2\) for a given fluid is:

$$\begin{aligned} {\textsf{R}}^2=\dfrac{\alpha g\beta ^2 d^5}{\kappa \nu }, \end{aligned}$$
(21)

where now \(\beta =\tfrac{T_U}{d}\). The associated four boundary conditions are the following:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(22)

The final two boundary conditions depend on what type of surfaces bound the fluid layer. For every fixed wavenumber, system (20) forms a generalized eigenvalue problem for the Rayleigh number. Indeed, the system can be rewritten in matrix form as follows:

$$\begin{aligned} \left( \begin{array}{cc} (D^2-a^2)^2 &{}0\\ 0 &{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{cc} 0&{}-2a^2(\zeta -z)\\ 1&{}0 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(23)

that is:

$$\begin{aligned} A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}. \end{aligned}$$
(24)

It turns out that for the problem under examination the critical Rayleigh number for the onset of instability is not immediately analytically determinable and indeed we will work, for fixed \(T_U\ge 4^\circ C\), on the minimum problem

$$\begin{aligned} {\textsf{R}}_c=\min _{a^2\in \mathbb {R}^+}\{ {\textsf{R}}^2(a^2) | \, {\textsf{R}} \ \text {verifies} \ (23) \}, \end{aligned}$$
(25)

through a numerical theory we are about to introduce in Sect. 3.

2.4 Penetrative convection in porous media

One can show that the following equations govern the linear instability of the penetrative convection in porous medium problem (see [2, pag. 382]):

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)W-2{\textsf{R}} a^2(\zeta -z) \Theta =0,\\ (D^2-a^2)\Theta -{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(26)

where \(\zeta\) and \(T_U\) are defined as in Sect. 2.3. The Rayleigh number \({\textsf{R}}^2\), for an assigned fluid, is given by:

$$\begin{aligned} {\textsf{R}}^2=\dfrac{\alpha g \beta ^2 k d^3}{\kappa \nu }, \end{aligned}$$
(27)

where now \(\beta =\tfrac{T_U}{d}\). System (26) is of order four, and so we require four boundary conditions:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(28)

For every fixed wavenumber, system (20) forms a generalized eigenvalue problem for the Rayleigh number. Indeed, the system can be rewritten in matrix form as follows:

$$\begin{aligned} \left( \begin{array}{cc} D^2-a^2 &{}0\\ 0 &{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{cc} 0&{}2a^2(\zeta -z)\\ 1&{}0 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(29)

that is:

$$\begin{aligned} A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}. \end{aligned}$$
(30)

For the problem under examination, the critical Rayleigh number for the onset of instabilities is not easily analytically determinable; therefore, for fixed \(T_U\ge 4^\circ C\), we will numerically solve the minimum problem

$$\begin{aligned} {\textsf{R}}_c=\min _{a^2\in \mathbb {R}^+}\{ {\textsf{R}}^2(a^2) | \, {\textsf{R}} \ \text {verifies} \ (29) \}, \end{aligned}$$
(31)

through the numerical theory explained in Sect. 3.

2.5 Convection in porous media with depth-dependent viscosity fluid

The linear instability theory for convection in porous media with depth-dependent viscosity fluid provides the following governing equations (see [33, pag. 69]):

$$\begin{aligned} {\left\{ \begin{array}{ll} \left( D^2 - a^2\right) W + \dfrac{f^{\prime }}{f} D W + {\textsf{R}}\dfrac{a^2}{f} \Theta =0,\\ (D^2-a^2)\Theta -{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(32)

where \(D=\frac{\textrm{d}}{\textrm{d}z}\) and function \(f=f(z)\) describes how viscosity changes with depth. Hence, let \(\mu _0\) be the value of viscosity at \(z=\frac{1}{2}\), it turns out that

$$\begin{aligned} \mu (z)=\mu _0 f(z). \end{aligned}$$
(33)

Finally, \({\textsf{R}}^2\) is the Rayleigh number and, for a given fluid, is given by:

$$\begin{aligned} {\textsf{R}}^2=\frac{\beta d^2 k \alpha g \rho _0}{\kappa \mu _0}. \end{aligned}$$
(34)

The following four boundary conditions are frequently enforced:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(35)

Following the choice in [33], we set:

$$\begin{aligned} f(z)=e^{c\left( z-\frac{1}{2}\right) }. \end{aligned}$$
(36)

As a result, system (32) becomes:

$$\begin{aligned} {\left\{ \begin{array}{ll} \left( D^2 - a^2\right) W + c D W + {\textsf{R}} a^2 e^{c\left( \frac{1}{2}-z\right) } \Theta =0,\\ (D^2-a^2)\Theta -{\textsf{R}}W=0. \end{array}\right. } \end{aligned}$$
(37)

Notice that system (37) represents a generalized eigenvalue problem for the Rayleigh number. Indeed, (37) can be written as follows:

$$\begin{aligned} \left( \begin{array}{cc} D^2 +c D-a^2 &{}0\\ 0 &{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{cc} 0&{}-a^2 e^{c\left( \frac{1}{2}-z\right) }\\ 1&{}0 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(38)

that is:

$$\begin{aligned} A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}. \end{aligned}$$
(39)

Looking at (38), unlike the previous cases, the first derivative \(D=\tfrac{\textrm{d}}{\textrm{d}z}\) appears in the operator A. Moreover, an exponential function shows up in B. As consequence, it turns out that for the problem under examination the critical Rayleigh number for the onset of instabilities is not immediately analytically determinable.

The minimum problem

$$\begin{aligned} {\textsf{R}}_c=\min _{a^2\in \mathbb {R}^+}\{ {\textsf{R}}^2(a^2) | \, {\textsf{R}} \ \text {verifies} \ (38) \} \end{aligned}$$
(40)

is going to be solved numerically in Sect. 4.8, once the matrix representation of the exponential \(e^{c\left( \frac{1}{2}-z\right) }\) is built. In Sect. 3.5, specific attention will be devoted to how to construct such a matrix.

3 The Chebyshev-\(\tau\) method

3.1 Remark about general \(\tau\) method

When dealing with ordinary differential equations, one can look for a solution as a formal power series expansion:

$$\begin{aligned} y(z)=b_0+b_1z+b_2z^2+\cdots \end{aligned}$$
(41)

Substituting this solution in the differential equation, it is possible to determine the coefficients with a recurrence relation and boundary conditions allow to uniquely determine the coefficients. However, when dealing with infinite series, convergence problems can occur. It is indeed possible that the series diverges for every point outside \(z=0\). In order to overcome this problem, the expansion can be truncated:

$$\begin{aligned} y(z)=b_0+b_1z+b_2z^2+\cdots + b_nz^n, \end{aligned}$$
(42)

for an arbitrary fixed n. The system becomes overdetermined since we have \(n+1\) coefficients to be determined at our disposal, but the number of equations is larger than \(n+1\). In order to remove the overdetermination, which arises from the reduction of order of polynomial after derivation, an extra term \(\tau p(z)\) (with p a generic polynomial) can be added on the right-hand side of the differential equation. For example, in the case of \(n+1\) coefficients and \(n+3\) equations we will need the error terms:

$$\begin{aligned} \tau _1 p(z)+\tau _2 q(z), \end{aligned}$$
(43)

with p and q polynomials. The coefficient \(\tau\) can be considered as an error term introduced in order to gain the solvability of the system. Since the coefficients were determined by successive recurrence, the only ones that cannot be determined are the last ones.

3.1.1 Example

Let us consider the following Cauchy problem:

$$\begin{aligned} {\left\{ \begin{array}{ll} 3(1-z)y'+y=0,\\ y(0)=1. \end{array}\right. } \end{aligned}$$
(44)

One can look for a solution of the following form:

$$\begin{aligned} y(z)=a_0+a_1z+a_2z^2. \end{aligned}$$
(45)

Now, substituting (45) in (44) it turns out:

$$\begin{aligned} -5a_2z^2+2(3a_2-a_1)z+3a_1+a_0=0. \end{aligned}$$
(46)

From (46), by recurrence one obtains \(a_0=a_1=a_2=0\). The solution will be \(y(z)=0\), which does not satisfy the initial condition (44)\(_2\). Hence, one needs to introduce a truncation term on the right-hand side of (44)\(_1\), which leads to the following equation for the coefficients:

$$\begin{aligned} -5a_2z^2+2(3a_2-a_1)z+3a_1+a_0=\tau p(z). \end{aligned}$$
(47)

In this case, it is convenient to choose \(p(z)=\tau z^2\) because the term that leads to overdetermination is \(-5a_2 z^2\). The auxiliary equation for coefficients becomes:

$$\begin{aligned} -5a_2z^2+2(3a_2-a_1)z+3a_1+a_0=\tau z^2. \end{aligned}$$
(48)

Therefore:

$$\begin{aligned} y_p(z)=1-\tfrac{1}{3}z-\tfrac{1}{9}z^2, \qquad \tau _p=\tfrac{5}{9}. \end{aligned}$$
(49)

If we chose as truncation term \(\tau (2z^2-1)\), then:

$$\begin{aligned} y_c(z)=1-\tfrac{6}{13}z-\tfrac{2}{13}z^2, \qquad \tau _c=\tfrac{5}{13}. \end{aligned}$$
(50)

The chosen polynomial \(p(z)=2z^2-1\) will turn out to be a Chebyshev polynomial of the first kind. This choice leads to a smaller truncation error, i.e. \(\tau _c<\tau _p\). Consequently, in a more general case, it could be convenient to employ Chebyshev polynomials both for the expression of the truncation term and for the expansion of the solution of a specific differential problem. Hence, the method we will describe is a special \(\tau\) method: the Chebyshev-\(\tau\) method. For a more detailed discussion of the subject, see [34, pag. 464]

3.2 Preliminary

Let us rewrite system (12) as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} W''=a^2W-{\textsf{R}}a^2\Theta ,\\ \Theta ''={\textsf{R}}W+a^2\Theta , \end{array}\right. } \end{aligned}$$
(51)

with \(':=D=\tfrac{\textrm{d}}{\textrm{d}z}\). System (51) is a special case of the following more general system of equations:

$$\begin{aligned} {\left\{ \begin{array}{ll} W''=\alpha _1W'+\alpha _2W+\alpha _3\Theta '+\alpha _4\Theta ,\\ \Theta ''=\beta _1W'+\beta _2W+\beta _3\Theta '+\beta _4\Theta , \end{array}\right. } \end{aligned}$$
(52)

where \(\alpha _j,\beta _i\), with \(i=1,2,3,4\), are known coefficients (which may possibly be functions of z) and \(z\in (0,1)\). Furthermore, one or more of those coefficients contains an eigenvalue \({\textsf{R}}\). Boundary conditions are the following:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(53)

We begin to describe Chebyshev-\(\tau\) method in the context of system (52). Having this in mind, let us define two linear operators \(L_1\) and \(L_2\) as follows:

$$\begin{aligned} \begin{aligned} L_1(W,\Theta )&=W''-\alpha _1W'-\alpha _2W-\alpha _3\Theta '-\alpha _4\Theta ,\\ L_2(W,\Theta )&=\Theta ''-\beta _1W'-\beta _2W-\beta _3\Theta '-\beta _4\Theta . \end{aligned} \end{aligned}$$
(54)

System (52) turns out to be equivalent to:

$$\begin{aligned} {\left\{ \begin{array}{ll} L_1(W,\Theta )=0,\\ L_2(W,\Theta )=0, \end{array}\right. } \end{aligned}$$
(55)

in the domain \((-1,1)\) with boundary conditions:

$$\begin{aligned} W(-1)=W(1)=\Theta (-1)=\Theta (1)=0. \end{aligned}$$
(56)

The domains of the functions appearing in system (52) have been transformed from [0, 1] to \([-1,1]\), the latter being the natural domain to work with Chebyshev polynomials. Before proceeding, we need to recall some fundamental properties of these polynomials.

3.3 Chebyshev polynomials: basic properties

The Chebyshev polynomials of the first kind of order n are defined as follows:

$$\begin{aligned} T_n(z)=\cos \left[ n\cos ^{-1}(z)\right] ,\quad z\in [-1,1],\quad n=0,1,\ldots \end{aligned}$$
(57)

From the previous definition, setting \(z=\cos \theta\), it turns out that:

$$\begin{aligned} T_n(z)=\cos (n\theta ),\quad \theta \in [0,\pi ],\quad n=0,1,\ldots \end{aligned}$$
(58)

The Chebyshev polynomials of the second kind of order n are defined, setting \(z=\cos \theta\), as follows:

$$\begin{aligned} U_n(z)=\frac{\sin \bigl ((n+1)\theta \bigr )}{\sin \theta },\quad \theta \in [0,\pi ],\quad n=0,1,\ldots \end{aligned}$$
(59)

Polynomials \(T_n\) and \(U_n\), with \(n\in \mathbb {N}_0\), satisfy the following remarkable properties.

  1. (i)

    The following recurrence relations hold (see [35, pag. 14–16]):

    $$\begin{aligned} \begin{aligned} T_{n+1}(z)&=2zT_n(z)-T_{n-1}(z),\quad n=1,2,\ldots \\[2mm] U_{n+1}(z)&=2zU_n(z)-U_{n-1}(z),\quad n=1,2,\ldots \end{aligned} \end{aligned}$$
    (60)

    where we pose \(T_0(z)=1\), \(T_1(z)=z\) and \(U_0(z)=1\), \(U_1(z)=2z\). The first five Chebyshev polynomials of the first and second kind are explicitly reported:

    $$\begin{aligned} \begin{array}{ccc} \begin{aligned} \begin{aligned} &{}T_0(z)=1\\ &{}T_1(z)=z\\ &{}T_2(z)=2z^2-1\\ &{}T_3(z)=4z^3-3z\\ &{}T_4(z)=8z^4-8z^2+1 \end{aligned} \end{aligned}&{}\qquad &{}\begin{aligned} \begin{aligned} &{}U_0(z)=1\\ &{}U_1(z)=2z\\ &{}U_2(z)=4z^2-1\\ &{}U_3(z)=8z^3-4z\\ &{}U_4(z)=16z^4-12z^2+1 \end{aligned} \end{aligned} \end{array} \end{aligned}$$
    (61)
  2. (ii)

    The following relation between Chebyshev polynomials of the first and second kind holds:

    $$\begin{aligned} U_n(z)-U_{n-2}(z)=2T_n(z),\qquad n=2,3,\ldots \end{aligned}$$
    (62)
  3. (iii)

    Polynomial \(T_n(z)\) has n zeros in the interval \([-1,1]\), given by (see [35, pag. 31–32]):

    $$\begin{aligned} z_k=\cos \left( \tfrac{2k-1}{2n}\pi \right) \qquad k=1,2,\ldots ,n \end{aligned}$$
    (63)

    and \(n+1\) extrema given by (see [35, pag. 33]):

    $$\begin{aligned} {\widehat{z}}_k=\cos \left( \tfrac{k\pi }{n}\right) \qquad k=0,1,\ldots ,n \end{aligned}$$
    (64)

    and in these points we have \(T_n({\widehat{z}}_k)=\cos \left[ n\cos ^{-1}({\widehat{z}}_k)\right] =\cos (k\pi )=(-1)^k\).

  4. (iv)

    The following fundamental product relation holds (see [35, pag. 43]), for every \(r,s\in \mathbb {N}_0\):

    $$\begin{aligned} T_r(z)T_s(z)=\tfrac{1}{2}\left[ T_{r+s}(z)+T_{|r-s|}(z)\right] . \end{aligned}$$
    (65)
  5. (v)

    The following integral relation between Chebyshev polynomials of the first and second kind holds:

    $$\begin{aligned} \int U_n(z)dz=\tfrac{1}{n+1}T_{n+1}(z)+c. \end{aligned}$$
    (66)
  6. (vi)

    The first derivative of \(T_n(z)\) can be written in terms of the polynomials itselfFootnote 1:

    $$T^{\prime}_{n} (z) = 2n\mathop {\sum{'} }\limits_{{\begin{subarray}{1} {k = 0} \\ {n - k{\text{ odd}}} \\ \end{subarray} }}^{{n - 1}} T_{k} (z),$$
    (67)

    where, from now on the prime at the summation symbol means that, if it appears, the term contributed by \(k = 0\) is to be halved.

    A similar relation for the second derivative of \(T_n(z)\) holds (see [35, pag. 50]):

    $$T^{\prime\prime}_{n} (z) = n\mathop {\sum {'} }\limits_{\begin{subarray}{l} k = 0 \\ n - k{\text{ }}even \end{subarray} }^{{n - 2}} (n^{2} - k^{2} )T_{k} (z).$$
    (68)

    Relations (67) and (68) are special cases of following general formula for \(p=1,2,\ldots\) (see [36, pag. 597])

    $$\frac{{{\text{d}}^{p} }}{{{\text{d}}x^{p} }}T_{n} (z) = 2^{p} n\mathop {\sum {'} }\limits_{\begin{subarray}{l} k = 0 \\ n - p - k{\text{ even}} \end{subarray} }^{{n - p}} \left( {\begin{array}{*{20}c} {\frac{{n + p - k}}{2} - 1} \\ {\frac{{n - p - k}}{2}} \\ \end{array} } \right)\frac{{\left( {\frac{{n + p + k}}{2} - 1} \right)!}}{{\left( {\frac{{n - p + k}}{2}} \right)!}}{\mkern 1mu} T_{k} (z).$$
    (69)
  7. (vii)

    Polynomials \(T_n(z)\) can be written in terms of powers of z in the following way (see [35, pag. 35-36]):

    $$\begin{aligned} T_n(z)=\sum _{k=0}^{\lfloor {n}/{2}\rfloor }c_{n,k}z^{n-2k}, \end{aligned}$$
    (70)

    where \(\lfloor \cdot \rfloor\) denotes the largest integer not greater than the number it embraces, with:

    $$\begin{aligned} c_{n,k}=(-1)^k 2^{n-2k-1}\frac{n}{n-k}\left( {\begin{array}{c}n-k\\ k\end{array}}\right) . \end{aligned}$$
    (71)

    For example, if \(n=4\):

    $$\begin{aligned} T_4(z)=\sum _{k=0}^2c_{4,k}z^{4-2k}=c_{4,0}z^{4}+c_{4,1}z^{2}+c_{4,2}=8z^4-8z^2+1. \end{aligned}$$

    Powers of z can be written in terms of polynomials \(T_n(z)\) in the following way.Footnote 2:

    $$\begin{aligned} z^n=2^{1-n}\mathop {{\sum }'}_{k=0}^{\lfloor {n}/{2}\rfloor }\left( {\begin{array}{c}n\\ k\end{array}}\right) T_{n-2k}(z). \end{aligned}$$
    (72)
  8. (viii)

    The following orthogonality relation holds, for every \(r,s\in \mathbb {N}_0\):

    $$\begin{aligned} \left\langle T_r(z),T_s(z)\right\rangle :=\int _{-1}^{1}T_r(z)T_s(z)\tfrac{1}{\sqrt{1-z^2}}dz={\left\{ \begin{array}{ll} \pi &{}\text {if}\quad r=s=0,\\ \tfrac{\pi }{2}&{}\text {if}\quad r=s\ne 0,\\ 0&{}\text {if}\quad r\ne s. \end{array}\right. } \end{aligned}$$
    (73)

    Moreover, we have that:

    $$\begin{aligned} \Vert T_n(z)\Vert ^2:\;=\int _{-1}^1T^2_n(z)\tfrac{1}{\sqrt{1-z^2}}dz={\left\{ \begin{array}{ll} \pi &{}\text {if}\quad n= 0,\\ \tfrac{\pi }{2}&{}\text {if}\quad n\ne 0. \end{array}\right. } \end{aligned}$$
    (74)

Notice that property viii) shows that the set \(\left\{ T_n(z)\right\} _{n\ge 0}\) forms an orthogonal system of \(L^2(-1,1)\) with respect to the weight function \(w(z)=\tfrac{1}{\sqrt{1-z^2}}\).

3.4 Theoretical aspects of the method

We will now describe the procedure for determining eigenvalues and eigenfunctions of systems (55) with associated boundary conditions (56). We defined operators \(L_1\) and \(L_2\) in order to rewrite (52) in the equivalent form (55). The key idea is to write W and \(\Theta\) in truncated Chebyshev series:

$$\begin{aligned} W(z)=\sum _{k=0}^{N+2} w_kT_k(z)\qquad \text {and}\qquad \Theta (z)=\sum _{k=0}^{N+2} \theta _k T_k(z). \end{aligned}$$
(75)

Obviously, the exact solution of the differential equation is an infinite series, i.e. \(N\rightarrow +\infty\). Following the idea introduced in Sect. 3.1 in order to solve (55) within the approximation (75), we solve:

$$\begin{aligned} {\left\{ \begin{array}{ll} L_1(W,\Theta )=\tau _1T_{N+1}(z)+\tau _2T_{N+2}(z),\\ L_2(W,\Theta )=\tau _1'T_{N+1}(z)+\tau '_2T_{N+2}(z), \end{array}\right. } \end{aligned}$$
(76)

where parameters \(\tau _i\) and \(\tau '_i\), \(i=1,2\), are effectively error indicators for the truncation in (75). In order to determine coefficients \(w_k\) and \(\theta _k\) in (75), we use the orthogonality relation (73) of the Chebyshev polynomials in the space \(L^2(-1,1)\):

$$\begin{aligned} {\left\{ \begin{array}{ll} \bigl \langle L_1(W,\Theta ),T_i \bigr \rangle =0,\\ \bigl \langle L_2(W,\Theta ),T_i \bigr \rangle =0. \end{array}\right. }\qquad i=0,\ldots ,N \end{aligned}$$
(77)

In such a way, \(2(N+1)\) equations are obtained, with two additional conditions:

$$\begin{aligned} \bigl \langle L_1(W,\Theta ),T_{N+j} \bigr \rangle =\tau _j\Vert T_{N+j}\Vert ^2\quad \text {and}\quad \bigl \langle L_2(W,\Theta ),T_{N+j} \bigr \rangle =\tau '_j\Vert T_{N+j}\Vert ^2. \end{aligned}$$
(78)

with \(j=1,2\). The four Eq. (78) just determined give us the coefficients \(\tau _i\) and \(\tau '_i\), with \(i=1,2\), which turn out to be the measures of the truncation error.

Let us observe that from definition (57) it follows that:

$$\begin{aligned} \begin{aligned} T_n(1)&=\cos \left[ n\cos ^{-1}(1)\right] =\cos (0)=1\\ T_n(0)&=\cos \left[ n\cos ^{-1}(0)\right] =\cos \left( n\tfrac{\pi }{2}\right) ={\left\{ \begin{array}{ll} 0&{}n=2k+1\\ 1&{} n=4k\\ -1&{}n=4k+2 \end{array}\right. }\, k=0,1,\ldots \\ T_n(-1)&=\cos \left[ n\cos ^{-1}(-1)\right] =\cos (n\pi )=(-1)^n \end{aligned} \end{aligned}$$
(79)

so, in particular \(T_n(\pm 1)=(\pm 1)^n\). Therefore, given boundary conditions (56), we obtain from (75) that:

$$\begin{aligned} \begin{aligned} W(-1)&=\sum _{k=0}^{N+2}w_kT_k(-1)=\sum _{k=0}^{N+2}(-1)^k w_k=0,\\ W(1)&=\sum _{k=0}^{N+2}w_kT_k(1)=\sum _{k=0}^{N+2} w_k=0,\\ \Theta (-1)&=\sum _{k=0}^{N+2}\theta _kT_k(-1)=\sum _{k=0}^{N+2}(-1)^k \theta _k=0,\\ \Theta (1)&=\sum _{k=0}^{N+2}w_kT_k(1)=\sum _{k=0}^{N+2} \theta _k=0. \end{aligned} \end{aligned}$$
(80)

The \(2(N+1)\) Eq. 77) jointly with the 4 Eq. (80) give a system of \(2(N+3)\) equations in \(2(N+3)\) unknowns \(w_k\), \(\theta _k\), with \(k=0,\ldots ,N+2\). Since it will be useful in the sequel, let us consider boundary conditions:

$$\begin{aligned} \begin{aligned} W(0)&=\sum _{k=0}^{N+2}w_kT_k(0)=\sum _{k=0}^{N+2}\cos \left( k\tfrac{\pi }{2}\right) w_k=0,\\ \Theta (0)&=\sum _{k=0}^{N+2}\theta _kT_k(0)=\sum _{k=0}^{N+2}\cos \left( k\tfrac{\pi }{2}\right) \theta _k=0. \end{aligned} \end{aligned}$$
(81)

Having in mind (77), we proceed in the following way: \(\forall i=0,\ldots ,N\)

$$\begin{aligned} {\left\{ \begin{array}{ll} \left\langle L_1(W,\Theta ),T_i\right\rangle =\left\langle W''-\alpha _1W'-\alpha _2W-\alpha _3\Theta '-\alpha _4\Theta ,T_i\right\rangle =0,\\ \left\langle L_2(W,\Theta ),T_i\right\rangle =\left\langle \Theta ''-\beta _1W'-\beta _2W-\beta _3\Theta '-\beta _4\Theta ,T_i\right\rangle =0, \end{array}\right. } \end{aligned}$$
(82)

so, due to the linearity of the scalar product:

$$\begin{aligned} {\left\{ \begin{array}{ll} \left\langle W'',T_i\right\rangle -\alpha _1\left\langle W',T_i\right\rangle -\alpha _2\left\langle W,T_i\right\rangle -\alpha _3\left\langle \Theta ',T_i\right\rangle -\alpha _4\left\langle \Theta ,T_i\right\rangle =0,\\ \left\langle \Theta '',T_i\right\rangle -\beta _1\left\langle W',T_i\right\rangle -\beta _2\left\langle W,T_i\right\rangle -\beta _3\left\langle \Theta ',T_i\right\rangle -\beta _4\left\langle \Theta ,T_i\right\rangle =0, \end{array}\right. } \end{aligned}$$
(83)

therefore, because of (75) it follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} \displaystyle \left\langle \sum _{k=0}^{N+2} w_kT_k'',T_i\right\rangle -\alpha _1\left\langle \sum _{k=0}^{N+2} w_kT_k',T_i\right\rangle -\alpha _2\left\langle \sum _{k=0}^{N+2} w_kT_k,T_i\right\rangle \\ \displaystyle \qquad \qquad \qquad \qquad -\alpha _3\left\langle \sum _{k=0}^{N+2} \theta _k T_k',T_i\right\rangle -\alpha _4\left\langle \sum _{k=0}^{N+2} \theta _k T_k,T_i\right\rangle =0,\\ \displaystyle \left\langle \sum _{k=0}^{N+2} \theta _k T_k'',T_i\right\rangle -\beta _1\left\langle \sum _{k=0}^{N+2} w_kT_k',T_i\right\rangle -\beta _2\left\langle \sum _{k=0}^{N+2} w_kT_k,T_i\right\rangle \\ \displaystyle \qquad \qquad \qquad \qquad -\beta _3\left\langle \sum _{k=0}^{N+2} \theta _k T_k',T_i\right\rangle -\beta _4\left\langle \sum _{k=0}^{N+2} \theta _k T_k,T_i\right\rangle =0. \end{array}\right. } \end{aligned}$$
(84)

Now setting \(\gamma _i=\Vert T_i(z)\Vert ^2\), from (73) it immediately turns out that:

$$\begin{aligned} \left\langle \sum _{k=0}^{N+2} w_k T_k,T_i\right\rangle =w_i\left\langle T_i,T_i\right\rangle =\gamma _i w_i, \end{aligned}$$
(85)

and moreoverFootnote 3:

$$\left\langle {\sum\limits_{{k = 0}}^{{N + 2}} {w_{k} } T_{{k^{\prime}}} ,T_{i} } \right\rangle = \tfrac{2}{{c_{i} }}\gamma _{i} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ odd}} \end{subarray} }^{{N + 2}} {sw_{s} ,}$$
(86)

with \(c_0=2\) and \(c_i=1\) for \(i=1,2,\ldots , N\) and finally\(^3\):

$$\left\langle {\sum\limits_{{k = 0}}^{{N + 2}} {w_{k} } T_{{k^{\prime\prime}}} ,T_{i} } \right\rangle = \tfrac{1}{{c_{i} }}\gamma _{i} \sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ even}} \end{subarray} }^{{N + 2}} {s(s^{2} - i^{2} )w_{s} ,}$$
(87)

always with \(c_0=2\) and \(c_i=1\) for \(i=1,2,\ldots , N\). Analogous conclusions are determined for terms \(\theta _k\). In view of the above, we can write system (84) in the following way:

$$\left\{ \begin{gathered} \sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ }}even \end{subarray} }^{{N + 2}} {\tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )w_{s} - \alpha _{1} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}sw_{s} - \alpha _{2} \delta _{{is}} w_{s} - \alpha _{3} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}s\theta _{s} - \alpha _{4} \delta _{{is}} \theta _{s} = 0,} } \hfill \\ - \beta _{1} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}sw_{s} - \beta _{2} \delta _{{is}} w_{s} } + \sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ }}even \end{subarray} }^{{N + 2}} {\tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )\theta _{s} - \beta _{3} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}s\theta _{s} - \beta _{4} \delta _{{is}} \theta _{s} = 0,} \hfill \\ \end{gathered} \right.$$
(88)

with \(i=0,\ldots ,N\). The \(2(N+1)\) Eq. (88) jointly with the 4 Eq. (80) give us \(2(N+3)\) equations in \(2(N+3)\) unknowns, which are in vector form:

$$\begin{aligned} {{\textbf {x}}}=({\varvec{w}},{\varvec{\theta }})=\left( w_{_{0}},\ldots ,w_{_{N+2}},\theta _{_{0}},\ldots ,\theta _{_{N+2}}\right) . \end{aligned}$$
(89)

System (88) in simple matrix form is:

$$\begin{aligned} B{{\textbf {x}}}={\varvec{0}}, \end{aligned}$$
(90)

with \(i=2(N+1)\) rows and \(s=2(N+3)\) columns, that we can write in blocks:

$$\begin{aligned} B{{\textbf {x}}}=\left( \begin{array}{cc} {{D^2}}-\alpha _1{{D}}-\alpha _2 {{I}}&{}-\alpha _3{{D}}-\alpha _4{{I}}\\ -\beta _1{{D}}-\beta _2 {{I}}&{}{{D^2}}-\beta _3{{D}}-\beta _4 {{I}}\\ \end{array}\right) \left( \begin{array}{c} {\varvec{w}}\\ {\varvec{\theta }} \end{array}\right) . \end{aligned}$$
(91)

By virtue of (85), I is an identity-like matrix, while by virtue of (86) and (87), matrices D and \({{D^2}}\) (\(i=N+1\) rows and \(s=N+3\) columns) are, respectively, given by:

$$\begin{aligned} D_{0,2j-1}=\; & {} 2j-1, \qquad j\ge 1,\nonumber \\ D_{i,i+2j-1}=\, & {} 2(i+2j-1), \qquad i,j\ge 1, \end{aligned}$$
(92)
$$\begin{aligned} {{D}}= & {} \left( \begin{array}{cccccccc} 0 &{} 1 &{} 0 &{} 3 &{} 0 &{} 5 &{} 0 &{} \cdots \\ 0 &{} 0 &{} 4 &{} 0 &{} 8 &{} 0 &{} 12 &{} \cdots \\ 0 &{} 0 &{} 0 &{} 6 &{} 0 &{} 10 &{} 0 &{} \cdots \\ 0 &{} 0 &{} 0 &{} 0 &{} 8 &{} 0 &{} 12 &{} \cdots \\ \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \end{array}\right) , \end{aligned}$$
(93)

and

$$\begin{aligned} D^2_{0,2j}=\; & {} \tfrac{1}{2}(2j)^3, \qquad j\ge 1, \nonumber \\ D^2_{i,i+2j}= & {} (i+2j)\bigl ((i+2j)^2-i^2\bigr )=\,(i+2j)4j(i+j), \qquad i,j\ge 1, \end{aligned}$$
(94)
$$\begin{aligned} {{D^2}}= & {} \left( \begin{array}{cccccccc} 0 &{} 0 &{} 4 &{} 0 &{} 32 &{} 0 &{} 108 &{} \cdots \\ 0 &{} 0 &{} 0 &{} 24 &{} 0 &{} 120 &{} 0 &{} \cdots \\ 0 &{} 0 &{} 0 &{} 0 &{} 48 &{} 0 &{} 192 &{} \cdots \\ 0 &{} 0 &{} 0 &{} 0 &{} 0 &{} 80 &{} 0 &{} \cdots \\ \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \end{array}\right) . \end{aligned}$$
(95)

Notice that \({{D^2}}={{D}}\cdot {{D}}\) can be written as a matrix product of D times itself. In order to close system (88), we add boundary conditions (77) in the following order:

$$\left\{ {\begin{array}{*{20}l} {\sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ even}} \end{subarray} }^{{N + 2}} {\tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )w_{s} - \alpha _{1} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ odd}} \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}sw_{s} - \alpha _{2} \delta _{{is}} w_{s} - \alpha _{3} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ odd}} \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}s\theta _{s} - \alpha _{4} \delta _{{is}} \theta _{s} = 0,} } \hfill \\ {} \hfill \\ {\sum\limits_{{s = 0}}^{{N + 2}} {w_{s} = 0,} } \hfill \\ {} \hfill \\ {\mathop \sum \limits_{{s = 0}}^{{N + 2}} \theta _{s} = 0,} \hfill \\ {} \hfill \\ { - \beta _{1} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ odd}} \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}sw_{s} - \beta _{2} \delta _{{is}} w_{s} } + \sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ even}} \end{subarray} }^{{N + 2}} {\tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )\theta _{s} - \beta _{3} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ odd}} \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}s\theta _{s} - \beta _{4} \delta _{{is}} \theta _{s} = 0,} } \hfill \\ {} \hfill \\ {\sum\limits_{{s = 0}}^{{N + 2}} {( - 1)^{s} } w_{s} = 0,} \hfill \\ {} \hfill \\ {\sum\limits_{{s = 0}}^{{N + 2}} {( - 1)^{s} } \theta _{s} = 0.} \hfill \\ \end{array} } \right.$$
(96)

Ultimately the problem can be written in the following matrix form:

$$\begin{aligned} A{{\textbf {x}}}={\varvec{0}}, \end{aligned}$$
(97)

with A is a numerical squared matrix of order \(2(N+3)\) given in blocks by:

$$\begin{aligned} A{{\textbf {x}}}=\left( \begin{array}{cc} {{D^2}}-\alpha _1{{D}}-\alpha _2 {{I}}&{}-\alpha _3{{D}}-\alpha _4{{I}}\\ \\ {{\text {bc}_{_{W(1)}}}}&{}{\varvec{0}}\\ \\ {\varvec{0}}&{}{{\text {bc}_{_{\Theta (1)}}}}\\ \\ -\beta _1{{D}}-\beta _2 {{I}}&{}{{D^2}}-\beta _3{{D}}-\beta _4 {{I}}\\ \\ {{\text {bc}_{_{W(-1)}}}}&{}{\varvec{0}}\\ \\ {\varvec{0}}&{}{{\text {bc}_{_{\Theta (-1)}}}}\\ \\ \end{array}\right) \left( \begin{array}{c} {\varvec{w}}\\ {\varvec{\theta }} \end{array}\right) . \end{aligned}$$
(98)

We can represent the previous blocks symbolically as follows:

figure a

3.5 Non-constant coefficients

Let us now consider the case where one of the coefficients \(\alpha _2,\alpha _4\) and \(\beta _2,\beta _4\) is a function of z. Assuming \(\alpha _2=\alpha _2(z)\), the system (82) becomes:

$$\begin{aligned} {\left\{ \begin{array}{ll} \left\langle L_1(W,\Theta ),T_i\right\rangle =\left\langle W''-\alpha _1W'-\alpha _2(z)W-\alpha _3\Theta '-\alpha _4\Theta ,T_i\right\rangle =0,\\ \\ \left\langle L_2(W,\Theta ),T_i\right\rangle =\left\langle \Theta ''-\beta _1W'-\beta _2W-\beta _3\Theta '-\beta _4\Theta ,T_i\right\rangle =0, \end{array}\right. } \end{aligned}$$
(99)

with \(i=0,\ldots ,N\).

As first instance, let \(\alpha _2\) be a linear function of z:

$$\begin{aligned} \alpha _2(z)=a_1+a_2z, \end{aligned}$$
(100)

and without loss of generality let us pose \(a_1=0\) and \(a_2=1\). Recalling (61) we have \(z=T_1(z)\), therefore thanks to the product relation (65) it follows that:

$$\begin{aligned} \left\langle \alpha _2(z)W,T_i\right\rangle&=\left\langle zW,T_i\right\rangle =\left\langle T_1\sum _{k=0}^{N+2}w_kT_k,T_i\right\rangle =\left\langle \sum _{k=0}^{N+2}w_kT_1T_k,T_i\right\rangle \\&=\left\langle \sum _{k=0}^{N+2}w_k\tfrac{1}{2}\left[ T_{k+1}+T_{|k-1|}\right] ,T_i\right\rangle \\&=\tfrac{1}{2}\left[ \left\langle \sum _{k=0}^{N+2}w_kT_{k+1},T_i\right\rangle +\left\langle \sum _{k=0}^{N+2}w_kT_{|k-1|},T_i\right\rangle \right] . \end{aligned}$$
(101)

Observe that for \(i=0\):

$$\begin{aligned} \begin{aligned} \tfrac{1}{2}\left[ \left\langle \sum _{k=0}^{N+2}w_kT_{k+1},T_0\right\rangle +\left\langle \sum _{k=0}^{N+2}w_kT_{|k-1|},T_0\right\rangle \right]&=\tfrac{1}{2}\left[ 0+w_1\left\langle T_0,T_0\right\rangle \right] \\ {}&=\gamma _i\tfrac{1}{2} w_1, \end{aligned} \end{aligned}$$
(102)

while for \(i=1\):

$$\begin{aligned} \tfrac{1}{2}\left[ \left\langle \sum _{k=0}^{N+2}w_k T_{k \!+\! 1},T_1\right\rangle \!\!+\!\! \left\langle \sum _{k=0}^{N+2}w_k T_{\vert k \!-\! 1 \vert },T_1\right\rangle \right]&= \tfrac{1}{2} [w_0\left\langle T_1,T_1\right\rangle \!+\! w_0\left\langle T_1,T_1\right\rangle \\&\quad \!+\! w_2\left\langle T_1,T_1\right\rangle ] \!=\! \gamma _i \left[ w_0 \!+\! \tfrac{1}{2}w_2 \right] , \end{aligned}$$
(103)

finally for \(i=2,3,\ldots , N\):

$$\begin{aligned} \begin{aligned} \tfrac{1}{2} \left[ \!\! \left\langle \sum _{k=0}^{N+2}w_k T_{k\!+\!1},T_i\right\rangle \!+\! \left\langle \sum _{k=0}^{N+2}w_k T_{|k\!-\!1|},T_i\right\rangle \!\! \right]&= \tfrac{1}{2} \! \left[ w_{i\!-\!1}\left\langle T_i,T_i\right\rangle \!+\! w_{i\!+\!1}\left\langle T_i,T_i\right\rangle \right] \\&= \gamma _i\left[ \tfrac{1}{2} w_{i\!-\!1} \!+\! \tfrac{1}{2}w_{i\!+\!1}\right] . \end{aligned} \end{aligned}$$
(104)

Therefore, it turns out, for \(i=0,1,\ldots , N\), that:

$$\begin{aligned} \tfrac{1}{2}\left[ \left\langle \sum _{k=0}^{N+2}w_kT_{k+1},T_i\right\rangle +\left\langle \sum _{k=0}^{N+2}w_kT_{|k-1|},T_i\right\rangle \right] =\gamma _i\left[ \tfrac{c_i}{2} w_{|i-1|} +\tfrac{1}{2}w_{i+1}\right] , \end{aligned}$$
(105)

with \(c_0=0\), \(c_1=2\) and \(c_i=1\) for \(i=2,3,\ldots , N\). Let us rewrite the system (99) as follows:

$$\left\{ \begin{aligned} &\sum\limits_{\begin{subarray}{l} s = i + 2 \\ s + i{\text{ }}even \end{subarray} }^{{N + 2}} {\tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )w_{s} - \alpha _{1} } \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}sw_{s} - \alpha _{2} \left[ {\tfrac{{c_{i} }}{2}\delta _{{i,|s - 1|}} w_{{|s - 1|}} + \tfrac{1}{2}\delta _{{i,s + 1}} w_{{s + 1}} } \right]} \hfill \\ & - \alpha _{3} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} \tfrac{2}{{c_{i} }} {s\theta _{s} - \alpha _{4} \delta _{{is}} \theta _{s} = 0,} \hfill \\ &- \beta _{1} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}}\tfrac{2}{{c_{i} }}sw_{s} - \beta _{2} \delta _{{is}} w_{s} + \sum\limits _{\begin{subarray}{1} {s = i + 2} \\ {s + i{\text{ }}even} \\ \end{subarray} }^{{N + 2}} \tfrac{1}{{c_{i} }}s(s^{2} - i^{2} )\theta _{s} \hfill \\ & - \beta _{3} \sum\limits_{\begin{subarray}{l} s = i + 1 \\ s + i{\text{ }}odd \end{subarray} }^{{N + 2}} {\tfrac{2}{{c_{i} }}s\theta _{s} - \beta _{4} \delta _{{is}} \theta _{s} = 0,} \hfill \\ \end{aligned} \right.$$
(106)

or in matrix form:

$$\begin{aligned} B{{\textbf {x}}}={\varvec{0}}, \end{aligned}$$
(107)

with B a matrix of \(i=2(N+1)\) rows and \(s=2(N+3)\) columns. We can write the system (106) in the following block matrix form:

$$\begin{aligned} B{{\textbf {x}}}=\left( \begin{array}{cc} {{D^2}}-\alpha _1{{D}}-a_2 {{Z}}&{}-\alpha _3{{D}}-\alpha _4{{I}}\\ \\ -\beta _1{{D}}-\beta _2 {{I}}&{}{{D^2}}-\beta _3{{D}}-\beta _4 {{I}}\\ \end{array}\right) \left( \begin{array}{c} {\varvec{w}}\\ {\varvec{\theta }} \end{array}\right) , \end{aligned}$$
(108)

where Z is a matrix of \(i=N+1\) rows and \(s=N+3\) columns given by:

$$\begin{aligned}{} & {} \begin{aligned}&Z_{1,0}=1, \\&Z_{i,i+1}={1}/{2}, \qquad i\ge 0, \\&Z_{i+1,i}={1}/{2}, \qquad i\ge 1, \\ \end{aligned} \end{aligned}$$
(109)
$$\begin{aligned}{} & {} {{Z}}=\left( \begin{array}{ccccccccc} 0 &{} {1}/{2} &{} 0 &{} 0 &{} 0 &{} 0&{} \cdots \\ 1 &{} 0 &{} {1}/{2} &{} 0 &{} 0 &{} 0&{} \cdots \\ 0 &{} {1}/{2} &{} 0 &{} {1}/{2} &{} 0 &{}0&{} \cdots \\ 0 &{} 0 &{} {1}/{2} &{} 0 &{} {1}/{2} &{} 0&{} \cdots \\ 0 &{} 0 &{} 0 &{} {1}/{2} &{} 0 &{} {1}/{2} &{} \cdots \\ \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \end{array}\right) . \end{aligned}$$
(110)

By appropriately adding the boundary conditions, matrix forms analogous to (97) and (98) can be obtained.

Let us now consider a more generic function \(\alpha _2(z)\) defined in \(\left( 0,1\right)\) and \(z_0\in \left( 0,1\right)\) such that the derivatives \(\alpha _2^{(1)}(z_0), \alpha _2^{(2)}(z_0),\) \(\dots ,\alpha _2^{(M)}(z_0)\) exist. We consider how such a function can be written in terms of Chebyshev polynomials. The idea we developed involves the Taylor expansion of \(\alpha _2(z)\) in order to take advantage of (72).

For the sake of simplicity, let us assume that \(\alpha _2(z)\) may be written as a second-order polynomial with a good approximation:

$$\begin{aligned} \alpha _2(z)=\alpha _2(z_0)+\alpha _2^{(1)}(z_0)\left( z-z_0\right) +\tfrac{\alpha _2^{(2)}(z_0)}{2}\left( z-z_0\right) ^2. \end{aligned}$$
(111)

Let us define

$$\begin{aligned} c_0=\alpha _2(z_0), \quad c_1=\alpha _2^{(1)}(z_0), \quad c_2=\alpha _2^{(2)}(z_0), \end{aligned}$$
(112)

so that (111) becomes

$$\begin{aligned} \alpha _2(z)=c_0 -c_1 z_0+\tfrac{c_2 z_0^2}{2} + \left( c_1-c_2 z_0\right) z + \tfrac{c_2}{2} z^2. \end{aligned}$$
(113)

From (61), we may determine the expression of \(\alpha _2(z)\) in terms of Chebyshev polynomials:

$$\begin{aligned} \alpha _2(z)= \left( c_0-c_1 z_0 +\tfrac{c_2 z_0^2}{2}+\tfrac{c_2}{4}\right) T_0 + \left( c_1-c_2z_0\right) T_1+\tfrac{c_2}{4}T_2. \end{aligned}$$
(114)

Let us define the following coefficients

$$\begin{aligned} \begin{aligned} b_0&=c_0-c_1 z_0 +\tfrac{c_2 z_0^2}{2}+\tfrac{c_2}{4},\\ b_1&=c_1-c_2z_0,\\ b_2&= \tfrac{c_2}{4}, \end{aligned} \end{aligned}$$
(115)

for a simpler expression of (114).

We now proceed to write the scalar product \(\left\langle \alpha _2(z)W,T_i\right\rangle\) appearing in (99):

$$\begin{aligned} \left\langle \alpha _2(z)W,T_i\right\rangle&=\left\langle \left( b_0T_0+b_1 T_1+b_2 T_2\right) \sum _{k=0}^{N+2}w_kT_k,T_i\right\rangle \\ &=\left\langle \sum _{k=0}^{N+2}b_0w_kT_0T_k,T_i\right\rangle \!+\!\left\langle \sum _{k=0}^{N+2}b_1w_kT_1T_k,T_i\right\rangle \!+\!\left\langle \sum _{k=0}^{N+2}b_2w_kT_2T_k,T_i\right\rangle \\&=\left\langle \sum _{k=0}^{N+2}b_0w_kT_{k},T_i\right\rangle +\left\langle \sum _{k=0}^{N+2}b_1w_k\tfrac{1}{2}\left[ T_{k+1}+T_{|k-1|}\right] ,T_i\right\rangle \\&\quad +\left\langle \sum _{k=0}^{N+2}b_2w_k\tfrac{1}{2}\left[ T_{k+2}+T_{|k-2|}\right] ,T_i\right\rangle .\\ \end{aligned}$$
(116)

Now, for \(i=0\):

$$\begin{aligned} \begin{aligned} \left\langle \alpha _2(z)W,T_0\right\rangle =b_0w_0\gamma _i+\tfrac{1}{2}b_1w_1\gamma _i+\tfrac{1}{2}b_2w_2\gamma _i, \end{aligned} \end{aligned}$$
(117)

for \(i=1\):

$$\begin{aligned} \begin{aligned} \left\langle \alpha _2(z)W,T_1\right\rangle =b_0w_1\gamma _i+b_1w_0\gamma _i+b_1w_2\tfrac{1}{2}\gamma _i+\tfrac{1}{2}b_2w_1\gamma _i+\tfrac{1}{2}b_2w_3\gamma _i, \end{aligned} \end{aligned}$$
(118)

for \(i=2\):

$$\begin{aligned} \begin{aligned} \left\langle \alpha _2(z)W,T_2\right\rangle =b_0w_2\gamma _i+\tfrac{1}{2}b_1w_1\gamma _i+\tfrac{1}{2}b_1w_3\gamma _i+b_2w_0\gamma _i+\tfrac{1}{2}b_2w_4\gamma _i, \end{aligned} \end{aligned}$$
(119)

finally for \(i=3,4,\dots , N\)

$$\begin{aligned} \begin{aligned} \left\langle \alpha _2(z)W,T_i\right\rangle&=\gamma _i[b_0\delta _{k,i}w_k + \tfrac{1}{2}b_1\delta _{k+1,i}w_{k+1}+\tfrac{1}{2}b_1\delta _{k-1,i}w_{k-1}\\&\quad +\tfrac{1}{2}b_2\delta _{k+2,i}w_{k+2}+\tfrac{1}{2}b_2\delta _{k-2,i}w_{k-2}]. \end{aligned} \end{aligned}$$
(120)

Therefore, for \(i=0,1,2,\dots , N\)

$$\left\langle {\alpha _{2} (z)W,T_{i} } \right\rangle = \sum\limits_{\begin{subarray}{l} s = i - 2 \\ s \ge 0 \end{subarray} }^{{i + 2}} {\tfrac{{c_{s} }}{2}\gamma _{i} b_{{|s - i|}} w_{s} + \delta _{{s = i,1}} \tfrac{1}{2}\gamma _{i} b_{{s + i}} w_{s} ,}$$
(121)

where \(c_s=2\) for \(s=0,i\); otherwise \(c_s=1\).

The system (99) becomes

$$\begin{aligned} {\left\{ \begin{subarray}{ll} \displaystyle {{\sum\limits _{\begin{subarray}{1} s=i+2 \\ s+i \text { even} \end{subarray}}^{N+2}\!\!\!\! \tfrac{1}{c_i}s(s^2-i^2)}}w_s -\alpha _1\!\!\!\!{{\sum\limits _{\begin{subarray}{1} s=i+1 \\ s+i \text { odd} \end{subarray}}^{N+2}\!\!\!\!\tfrac{2}{c_i} s}}w_s -{\sum\limits _{\begin{subarray}{1} s=i-2 \\ s \ge 0 \end{subarray}}^{i+2} \frac{c_s}{2} b_{|s-i|}}w_s+{\delta _{s=i,1}\frac{1}{2} b_{s+i}}w_s\\ \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \displaystyle -\alpha _3\!\!\!\!{{\sum\limits _{\begin{subarray}{1} s=i+1 \\ s+i \text { odd} \end{subarray}}^{N+2}\tfrac{2}{c_i} s}}\theta _s -\alpha _4{{\delta _{is}}}\theta _s=0,\\ \\ \displaystyle -\beta _1{{\sum\limits _{\begin{subarray}{1} s=i+1 \\ s+i \text { odd} \end{subarray}}^{N+2}\tfrac{2}{c_i} s}}w_s -\beta _2{{\delta _{is}}}w_s+{{\sum\limits _{\begin{subarray}{1} s=i+2 \\ s+i \text { even} \end{subarray}}^{N+2} \tfrac{1}{c_i}s(s^2-i^2)}}\theta _s\\ \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \displaystyle -\beta _3\!\!\!\!{{\sum\limits _{\begin{subarray}{1} s=i+1 \\ s+i \text { odd} \end{subarray}}^{N+2}\tfrac{2}{c_i} s}}\theta _s -\beta _4{{\delta _{is}}}\theta _s=0 . \end{subarray}\right. } \end{aligned}$$
(122)

that is, in matrix form:

$$\begin{aligned} B{{\textbf {x}}}={\varvec{0}}, \end{aligned}$$
(123)

with B a matrix of \(i=2(N+1)\) rows and \(s=2(N+3)\) columns where

$$\begin{aligned} B=\left( \begin{array}{cc} {{D^2}}-\alpha _1{{D}}- {{F}}&{}-\alpha _3{{D}}-\alpha _4{{I}}\\ \\ -\beta _1{{D}}-\beta _2 {{I}}&{}{{D^2}}-\beta _3{{D}}-\beta _4 {{I}}\\ \end{array}\right) , \end{aligned}$$
(124)

and F is the matrix representation of \(\alpha _2(z)\) of \(i=N+1\) rows and \(s=N+3\) columns:

$$\begin{aligned} {{F}}=\left( \begin{array}{ccccccccccc} b_0 &{} {b_1}/{2} &{} {b_2}/{2} &{} 0 &{} 0 &{} 0&{} 0&{}0&{}\cdots \\ b_1 &{} b_0+{b_2}/{2} &{} {b_1}/{2} &{} {b_2}/{2} &{} 0 &{}0&{} 0&{}0&{} \cdots \\ b_2 &{} {b_1}/{2} &{} b_0 &{} {b_1}/{2} &{} {b_2}/{2} &{}0&{}0&{}0&{} \cdots \\ 0 &{} {b_2}/{2} &{} {b_1}/{2} &{} b_0 &{} {b_1}/{2} &{} {b_2}/{2}&{}0&{}0&{} \cdots \\ 0 &{} 0 &{} {b_2}/{2} &{} {b_1}/{2} &{} b_0 &{} {b_1}/{2} &{} {b_2}/{2}&{}0&{} \cdots \\ \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots &{} \end{array}\right) . \end{aligned}$$
(125)

As the reader may have noticed, when taking advantage of (61) in (113), the term \(z^2\) gives an additional contribution in terms of \(T_0\), unlike the term in z which is simply equal to \(T_1\). Looking at (61), \(z^3\) will provide an additional term in \(T_1\); \(z^4\) in \(T_2\) and \(T_0\) and so on. Once this idea had been understood, we may proceed to write the code we report in the next section.

3.6 Generalized eigenvalue problems

A vector \({{\textbf {x}}}\) is said to be an eigenvector of the matrix A if there is a nonzero real number \(\lambda\), called eigenvalue, such that:

$$\begin{aligned} A{{\textbf {x}}}=\lambda {{\textbf {x}}}. \end{aligned}$$
(126)

Problem (126) is better known as the eigenvalue problem. A vector \({{\textbf {x}}}\) is said to be an eigenvector of matrices A and B if there exists a nonzero real number \(\lambda\), called eigenvalue, such that:

$$\begin{aligned} A{{\textbf {x}}}=\lambda B{{\textbf {x}}}. \end{aligned}$$
(127)

Problem (127) is better known as the generalized eigenvalue problem, and this is precisely the kind of problem we are going to deal with. Let us now go back to the general system (52):

$$\begin{aligned} {\left\{ \begin{array}{ll} D^2W=\alpha _1DW+\alpha _2W+\alpha _3D\Theta +\alpha _4\Theta ,\\ D^2\Theta =\beta _1DW+\beta _2W+\beta _3D\Theta +\beta _4\Theta , \end{array}\right. } \end{aligned}$$
(128)

under the following boundary conditions:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(129)

In case \(\alpha _1=\alpha _3=\beta _1=\beta _3=0\), \(\alpha _2=\beta _4=a^2\), \(\alpha _4=\alpha _4({\textsf{R}})=-{\textsf{R}} a^2\) e \(\beta _2=\beta _2({\textsf{R}})=-{\textsf{R}}\), the system (128) becomes:

$$\begin{aligned} {\left\{ \begin{array}{ll} D^2W=a^2W-{\textsf{R}} a^2\Theta ,\\ D^2\Theta =-{\textsf{R}}W+a^2\Theta , \end{array}\right. } \end{aligned}$$
(130)

and coincides with system (12) which is a generalized eigenvalue problem as we remarked before in (15) and (16). In view of the Chebyshev polynomial theory we have just introduced, we have the following symbolic representation of the problem \(A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}\):

figure b

At first glance, because of the high order of the derivatives, it seems that problem (1) does not fall within the general case (128) for which the theory of Chebyshev decomposition was introduced. Let us reconsider system (1)

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)^2W-{\textsf{R}} a^2 \Theta =0,\\ (D^2-a^2)\Theta +{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(131)

with boundary conditions:

$$\begin{aligned} W(0)=W(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(132)

If we introduce the following auxiliary variable:

$$\begin{aligned} Y=(D^2-a^2)W, \end{aligned}$$
(133)

system (131) can be transformed as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} (D^2-a^2)W-Y=0,\\ (D^2-a^2)Y-{\textsf{R}} a^2 \Theta =0,\\ (D^2-a^2)\Theta +{\textsf{R}}W=0, \end{array}\right. } \end{aligned}$$
(134)

and therefore, the order of derivation is consistent with the theory. Moreover, we need to add new boundary values for the auxiliary variable (133), which, because of (132), are:

$$\begin{aligned} \begin{aligned} Y(0)&=(D^2-a^2)W(0)=D^2W(0)-a^2W(0)=D^2W(0),\\ Y(1)&=(D^2-a^2)W(1)=D^2W(1)-a^2W(1)=D^2W(1). \end{aligned} \end{aligned}$$
(135)

We now need to specify the type of surface bounding the fluid layer. In particular, if we assume free–free conditions (4), i.e. \(D^2W(0)=D^2W(1)=0\), it turns out that:

$$\begin{aligned} Y(0)=Y(1)=0. \end{aligned}$$
(136)

Ultimately we are dealing with the following generalized eigenvalue problem:

$$\begin{aligned} \left( \begin{array}{ccc} D^2-a^2 &{} -1 &{}0\\ 0 &{} D^2-a^2 &{}0\\ 0&{}0&{}D^2-a^2 \end{array}\right) \left( \begin{array}{c} W\\ Y\\ \Theta \end{array}\right) ={\textsf{R}}\left( \begin{array}{ccc} 0&{}0&{}0\\ 0&{}0&{}a^2\\ -1&{}0&{}0 \end{array}\right) \left( \begin{array}{c} W\\ Y\\ \Theta \end{array}\right) \end{aligned}$$
(137)

together with boundary conditions:

$$\begin{aligned} W(0)=W(1)=Y(0)=Y(1)=\Theta (0)=\Theta (1)=0. \end{aligned}$$
(138)

Different boundary conditions will be taken into account in Sect. 5.3.

4 Numerical solutions: computational aspects of the method

We anticipate that the present section concerning the numerical implementation of the first in-depth theoretical part will require some basic knowledge of MATLAB. In any case, the presented codes will be explained as clearly as possible and applied to the previously introduced hydrodynamic stability problems. Moreover, every presented and cited code is available in the GitHub repository [37].

4.1 Construction and visualization of the Chebyshev polynomials

In MATLAB, functions \(\mathtt {chebyshevT(0:n,z)}\) and \(\mathtt {chebyshevU(0:n,z)}\) (for detailed documentation, see [38, 39]) give a vector of length n whose k-th entry is the k-th Chebyshev polynomial, respectively, of the first and second kind, with \(k\in \{0,\ldots ,n\}\). Their behaviour is shown in Figs. 1 and 2.

Fig. 1
figure 1

Chebyshev polynomials of the first kind \(T_n(z)\), \(n=0,1,2,3,4\), see (61)

Fig. 2
figure 2

Chebyshev polynomials of the second kind \(U_n(z)\), \(n=0,1,2,3,4\), see (61)

4.2 Construction of D, \(D^2\) and Z matrices and boundary condition vector

In order to build the matrix D , we have simply to follow what we computed in (86) and (92), so only two nested for loops are needed, see function 1:

figure c

Analogously, building the matrix \({{D^2}}\) simply consists in following what we computed in (100) and (94) therefore only two nested for loops are needed, see function 2:

figure d

Matrix Z can be built following (109), so two consecutive loops for are needed, hence function 3:

figure e

About boundary conditions in \(z=0\) and \(z=1\), we can proceed recalling what we introduced in (80) and (81) and writing the conditional constructs shown in function 4:

figure f

Functions \(\texttt{chebyder}\) 1, \(\texttt{chebyder2}\) 2, \(\texttt{chebyZ}\) 3 and \(\texttt{chebybval}\) 4 are the four fundamental building blocks of the method.

4.3 Horton–Rogers–Lapwood problem

As we said in Sect. 3.6, in order to solve the Horton–Rogers–Lapwood problem, we need to work on the generalized eigenvalue problem \(A{{\textbf {x}}}={\textsf{R}} B{{\textbf {x}}}\) which is symbolically represented in page 27. The next-to-last step is to build matrices A and B, see 5:

figure g
figure h

The real last step is actually the resolution of the generalized eigenvalue problem and the determination of the critical Rayleigh number, as done in 6:

figure i
figure j

Recalling what we analytically found in (18) and (19), setting \(\mathtt {step=0.0001}\) and \(\mathtt {x=9.7:step:10}\), the code gives us as output the following critical numbers:

$$\begin{aligned} a^2_{c,\text {Chebyshev-}\tau }=9.8696\qquad \quad \text {and}\qquad \quad {\textsf{R}}_{c,\text {Chebyshev-}\tau }^{\texttt {HRL}}=39.4784. \end{aligned}$$
(139)

In Fig. 3, the numerically computed neutral curve (i.e. the instability threshold for the onset of steady convection) is depicted. In Fig. 4, the solid blue line depicts the neutral curve determined analytically, while the dashed black line depicts the numerically computed neutral curve. The two lines overlap; therefore, the numerical approach computes the exact solution (17).

Fig. 3
figure 3

Plot of the marginal stability curve for the Horton–Rogers–Lapwood problem

Fig. 4
figure 4

Comparison between the numerical and analytical curves for the Horton–Rogers–Lapwood problem

4.4 Bénard problem

For the Bénard problem, following the procedure we introduced in Sect. 3.6 (page 27), in order to build matrices A and B we may proceed as in function fullmatrices_B, available at [40]. The last step is the resolution of the generalized eigenvalue problem and the determination of the critical Rayleigh number. To this aim, it is sufficient to replace fullmatrices_HRL with fullmatrices_B in code 6 (line 9). Recalling what we analytically found in (10) and (11), the resulting code will produce as output the following critical numbers and the neutral curve depicted in Fig. 5:

$$\begin{aligned} a^2_{c,\text {Chebyshev-}\tau }=4.9348\qquad \quad \text {and}\qquad \quad {\textsf{R}}_{c,\text {Chebyshev-}\tau }^{\texttt {B}_{free-free }}=657.5114. \end{aligned}$$
(140)

In Fig. 6, the solid blue line depicts the neutral curve determined analytically, while the dashed black line depicts the numerically computed neutral curve. The overlapping between these curves shows once again that the Chebyshev-\(\tau\) method manages to find the exact critical Rayleigh number defined by (9).

Fig. 5
figure 5

Plot of the marginal stability curve for the Bénard problem

Fig. 6
figure 6

Comparison between the numerical and analytical curves for the Bénard problem

4.5 Methodological remark

Given a certain generalized eigenvalue problem to solve with the Chebyshev-\(\tau\) method, in order to avoid confusion, it is definitely convenient to sketch a symbolic representation of the system as we did in Sect. 3.6 (page 27). We can therefore identify the blocks that form matrices A and B. Given a certain block of order (pq) in the nested for loops, code 7 follows:

figure k
figure l

4.6 Penetrative convection in clear fluid problem

One can now easily write a code for the determination of matrices A and B concerning the generalized eigenvalue problem for the linear instability in penetrative convection in clear fluids introduced in Sect. 2.3. In order to analyse the behaviour of the critical Rayleigh number \({\textsf{R}}_{c,L}\) with respect to the upper layer temperature, we wrote function \(\mathtt {fullmatrices\_PClear}\) [41] and code [42]. The effect of the upper layer temperature on \({\textsf{R}}_{c,L}\) is depicted in Fig. 7. The stabilizing effect of \(T_U\) on the onset of penetrative convection emerges since the critical Rayleigh number is an increasing function with respect to \(T_U\).

One can numerically find the table given by Straughan in [32, pag. 236].Footnote 4

Fig. 7
figure 7

Stabilizing effect of the upper layer temperature \(T_U\) in clear fluids penetrative convection

4.7 Penetrative convection in porous media problem

We can here easily write a code for the determination of matrices A and B concerning the generalized eigenvalue problem for the linear instability in penetrative convection in porous media introduced in Sect. 2.4. To this aim, it is sufficient to write a suitable \(\mathtt {fullmatrices\_PPorous}\) routine (see [43]), and in order to plot the behaviour of the critical Rayleigh number with respect to the upper layer temperature we just need to substitute \(\mathtt {fullmatrices\_PPorous}\) in line 10 of code [42]. Once the code is fully written, the behaviour of \({\textsf{R}}_c\) with respect to the upper plane temperature \(T_U\), depicted in Fig. 8, can be recovered: \({\textsf{R}}_c\) is an increasing function of \(T_U\); therefore, the upper plane temperature has a stabilizing effect on the onset of penetrative convection.

Fig. 8
figure 8

Stabilizing effect of the upper layer temperature \(T_U\) in porous media penetrative convection

4.8 Convection in porous media with depth-dependent viscosity fluid

In Sect. 3.5, we analytically studied two cases where a non-constant coefficient \(\alpha _2(z)\) appears in (99). We were able to write the matrix representation both when \(\alpha _2(z)\) is a linear function and when it is a generic function that is well approximated by a second-order Taylor polynomial. What happens if we need a greater degree polynomial to approximate \(\alpha _2(z)\)? The determination of the Chebyshev expansion would be very complicated and the representative matrix would involve several Chebyshev polynomials. In studying the onset of thermal convection in a porous medium saturated by a fluid with depth-dependent viscosity, we faced such a complication. As shown in Sect. 2.5, viscosity \(\mu\) is such that

$$\begin{aligned} \mu =\mu _0 f(z) \quad \text {with}\ f(z)=e^{c\left( z-\frac{1}{2}\right) }. \end{aligned}$$
(141)

As consequence, we needed to find a matrix representation for f(z). The following routines are helpful to this aim.

The function 8 finds the matrix representation of a symbolic function f. The algorithm begins with the determination of the Taylor expansion of f (see line 8). The associated approximation error is determined in line 12. The code then extrapolates the coefficients in the Taylor polynomial at line 16 where those coefficients are collected as entries of the vector coeff by means of the function CoeffExtraction 9. The for loop in line 25 reproduces the recursive formula (72). The function ends with the call to Construction_Matrix_Representation 10 after building vettcoeff whose i-th entry is the coefficient before the i-th Chebyshev polynomial.

figure m

The routine 9 builds a vector whose entries are the coefficients in a polynomial.

figure n

Finally, the following routine 10 allows building the matrix representation of a function that is expanded with Chebyshev polynomials. It takes a vector in input where the i-th entry is the coefficient of the i-th Chebyshev polynomial in the expansion.

figure o

Results that one can obtain by following this method are in very good agreement with those obtained in [33, Table 3, pag. 67].

5 Further applications

5.1 Velocity and temperature eigenfunctions

Generally speaking, when we want to solve a generalized eigenvalue problem, we need to find eigenvalues and eigenvectors. In the fullmatrices codes we provided before, we used the MATLAB function \(\texttt{eig}\) (see [44]). Given a generalized eigenvalue problem (127), \(\mathtt {E = eig(A,B)}\) returns a column vector \(\texttt{E}\) containing the generalized eigenvalues of square matrices A and B, while \(\mathtt {[F,E] = eig(A,B)}\) returns diagonal matrix \(\texttt{E}\) of generalized eigenvalues and full matrix \(\texttt{F}\) whose columns are the corresponding right eigenvectors:

figure p

Let us consider the penetrative convection in porous media problem and its generalized eigenvalue problem (29). Recalling (75) in order to construct functions W(z) and \(\Theta (z),\) we need to have \(\{T_k(z)\}_{k=0}^{N-1}\) and the two sets of coefficients \({{\{w_k\}_{k=1}^N}}\) and \({{\{\theta _k\}_{k=1}^N}}\). The former set is kindly offered by MATLAB, as we mentioned in Sect. 4.1. Concerning the coefficients, if we look at (30), having in mind (89), we realize that:

figure q

In order to draw the velocity and temperature eigenfunctions, we first need to notice that when we use \(\texttt{eig}\) to find the critical Rayleigh numbers we always \(\texttt{sort}\) the eigenvalues vector. This means that we cannot directly find the eigenfunction column vector once \({\textsf{R}}_c\) and \(a^2_c\) are found. Nevertheless, what we can do is solve the generalized eigenvalue problem with given critical wavenumber \(a^2_c\) and search the position in \(\texttt{E}\) of the given critical Rayleigh number \({\textsf{R}}_c\) and, as a consequence, find the corresponding position of the column vector in \(\texttt{F}\). The second thing to notice is that the order of magnitude of the eigenfunctions decreases very rapidly with increasing upper boundary temperature. Therefore, in order to visualize the qualitative behaviour on a single graph, we need to \(\texttt{normalize}\) (see [45]) the eigenfunctions over the spatial layer. The last thing to notice is that the eigenfunctions are defined up to a scaling factor, i.e. if \(A{{\textbf {x}}}={\textsf{R}}B{{\textbf {x}}}\), then \(A(\gamma _i{{{\textbf {x}}}})={\textsf{R}} B(\gamma _i{{\textbf {x}}})\) with \(\gamma _i\in {\mathbb {R}}\). We will use a scaling factor \(\gamma _i=-1\) in the following. In view of the previous remarks, we may proceed as in code available at [46].

Fig. 9
figure 9

Velocity normalized eigenfunctions we were searching for

In Fig. 9, the reader may notice the change in sign of W(z) , which implies that a small secondary cell near the upper boundary is driven by viscous forces. In order to compute the temperature eigenfunctions, we essentially employ code [47]. Results are shown in Fig. 10. For a more detailed discussion about the phenomenology related to Figs. 9 and 10, see [2, pag. 384], [48, pag. 651] and [49, pag. 63].

Fig. 10
figure 10

Temperature normalized eigenfunctions we were searching for

5.2 Convective roll perturbation

Without going into details (for which see [1, pag. 23]), we report that in linear instability analysis at the criticality the perturbation is presumed to be of the following form:

$$\begin{aligned} w(x,y,z)=W(z)e^{i(a_xx+a_yy)}\qquad \text {and}\qquad \theta (x,y,z)=\Theta (z)e^{i(a_xx+a_yy)}, \end{aligned}$$
(142)

where w is the vertical component of the velocity field perturbation \({{\textbf {u}}}=(u,v,w)\) and \(\theta\) is the temperature perturbation. The analysis of roll perturbations can be formulated as a 2D problem in the (xz) -plane (see [50, pag. 146]), so we look for solution of form:

$$\begin{aligned} w(x,z)=W(z)\sin \left( a x\right) \qquad \text {and}\qquad \theta (x,z)=\Theta (z)\sin \left( a x\right) . \end{aligned}$$
(143)

Notice that, recalling \(a^2=a_x^2+a_y^2\), if a convective cell is a domain of form

$$\begin{aligned} \Omega =\left[ 0,\tfrac{2\pi }{a_x}\right] \times \left[ 0,\tfrac{2\pi }{a_y}\right] \times \left[ 0,1\right] , \end{aligned}$$

then a convective roll (we can think \(a_y\rightarrow 0\)) is a domain of the following form:

$$\begin{aligned} R=\left[ 0,\tfrac{2\pi }{a_x}\right] \times \left[ 0,+\infty \right] \times \left[ 0,1\right] . \end{aligned}$$

Now, if we look at (142), in view of what we obtained in Sect. 5.1, we have all the ingredients necessary to visualize the convective roll perturbation. Let us first consider the Bénard problem. In order to depict convective roll and (143)\(_1\), let us employ the critical Rayleigh and wave numbers (140) in code [51] to determine their corresponding eigenfunction (see the symbolic representation in Sect. 5.1, at page 41). The results are shown in Fig. 11a, b, where the symmetric behaviour of the streamlines with respect to \(z=1/2\) is evident (for a more detailed discussion about cell patterns, see [1, pag. 43]).

Fig. 11
figure 11

a: Plot of function \(w(x,z)=W(z)\sin (a_cx)\). b: (xz) -plane roll perturbation in Bénard problem

We can visualize the convective roll perturbation for the penetrative convection problem in Fig. 12a. Moreover, Fig. 12b shows how the change in sign of function W(z), shown in Fig. 9, generates a small secondary cell near the upper boundary.

Fig. 12
figure 12

a: Plot of function \(w(x,z)=W(z)\sin (a_cx)\). a: (xz) -plane roll perturbation in penetrative convection in porous media problem

As last example, in Fig. 13a, b we can visualize the convective roll perturbation when the fluid saturating a porous medium exhibits a viscosity which can be expressed as in (33) together with (36). The flow tends to concentrate in the region of low viscosity as shown by the movement of the vortex centre leading to a loss of symmetry of the streamlines with respect to half of the layer.

Fig. 13
figure 13

a: Plot of function \(w(x,z)=W(z)\sin (a_cx)\). a: (xz) -plane roll perturbation in convection in porous media with depth-dependent viscosity

5.3 Different boundary conditions

When in the Bénard problem we introduced the Y auxiliary variable (133) in order to assign the two additional boundary conditions, we had to choose between:

  1. (i)

    free–free, bottom and top surface free

    $$\begin{aligned} D^2W(0)=D^2W(1)=0, \end{aligned}$$
    (144)
  2. (ii)

    rigid–rigid, bottom and top surface fixed

    $$\begin{aligned} DW(0)=DW(1)=0, \end{aligned}$$
    (145)
  3. (iii)

    rigid-free, bottom surface fixed, top surface free

    $$\begin{aligned} DW(0)=D^2W(1)=0. \end{aligned}$$
    (146)

The first easier choice, free–free surfaces, allowed us to write:

$$\begin{aligned} Y(0)=Y(1)=0. \end{aligned}$$
(147)

As we anticipated in Sect. 3.6 (page 28), we want to take into account different boundary conditions. If we differentiate Eq. (135), we obtain:

$$\begin{aligned} \begin{aligned} DY(0)&=D^3W(0)-a^2DW(0),\\ DY(1)&=D^3W(1)-a^2DW(1), \end{aligned} \end{aligned}$$
(148)

and in particular assuming rigid–rigid conditions, i.e. \(DW(0)=DW(1)=0\), we have

$$\begin{aligned} DY(0)=D^3W(0)\qquad \text {and}\qquad DY(1)=D^3W(1); \end{aligned}$$
(149)

moreover, if we differentiate Eq. 135)\(_1\), we have

$$\begin{aligned} \begin{aligned} DY(0)&=D^3W(0)-a^2DW(0),\\ Y(1)&=D^2W(1)-a^2W(1), \end{aligned} \end{aligned}$$
(150)

and assuming rigid-free conditions, i.e. \(DW(0)=D^2W(1)=0\), we have

$$\begin{aligned} DY(0)=D^3W(0)\qquad \text {and}\qquad Y(1)=0. \end{aligned}$$
(151)

However, while the free–free boundary condition vector immediately follows from (80) and (81), i.e.:

$$\begin{aligned} \begin{aligned} {{\text {bc}_{_{Y(1)}}}}&=\left( \begin{array}{ccccccccccccc} 1&0&-1&0&1&0&-1&0&1&0&-1&0&\dots \end{array}\right) ,\\ \text {bc}_{_{Y(0)}}&=\left( \begin{array}{ccccccccccccc} 1&1&1&1&1&1&1&1&1&1&1&1&\dots \end{array}\right) , \end{aligned} \end{aligned}$$
(152)

the determination of rigid–rigid and rigid-free conditions, i.e. \(\text {bc}_{_{DY(0)}}\), \(\text {bc}_{_{DY(1)}}\), \(\text {bc}_{_{D^3W(0)}}\) and \(\text {bc}_{_{D^3W(0)}}\), is non-trivial. Fortunately, we can take advantage of the following formula:

$$\begin{aligned} D^{(p)}T_k(1)=\prod _{n=0}^{p-1}\dfrac{k^2-n^2}{2n+1}; \end{aligned}$$
(153)

hence, the non-triviality is essentially contained in the boundary conditions in \(z=0\), but we have to approach this one step at a time. Let us start with \(\text {bc}_{_{DY(1)}}\)

$$\begin{aligned} DY(1)=D\sum _{k=0}^{N+2} y_kT_k(1)=\sum _{k=0}^{N+2} y_kDT_k(1). \end{aligned}$$
(154)

Now, from (153) with \(p=1\) it follows that:

$$\begin{aligned} DT_k(1)=k^2, \end{aligned}$$
(155)

so:

$$\begin{aligned} {{\text {bc}_{_{DY(1)}}}}=\left( \begin{array}{ccccccccccccc} 0&1&4&9&16&25&36&49&64&81&100&121&\dots \end{array}\right) . \end{aligned}$$
(156)

We proceed with:

$$\begin{aligned} D^{(3)}W(1)=\sum _{k=0}^{N+2} w_kD^{(3)}T_k(1), \end{aligned}$$
(157)

and then, always from (153) it follows that:

$$\begin{aligned} D^{(3)}T_k(1)=\prod _{n=0}^{2}\dfrac{k^2-n^2}{2n+1}=k^2\,\dfrac{k^2-1}{3}\,\dfrac{k^2-4}{5}, \end{aligned}$$
(158)

so:

$$\begin{aligned} {{\text {bc}_{_{D^3W(1)}}}}=\left( \begin{array}{ccccccccc} 0&0&0&24&192&840&2688&7056&\ldots \end{array}\right) . \end{aligned}$$
(159)

Now comes the non-trivial part. We will start with \(\text {bc}_{_{DY(0)}}\), recalling (67):

$$DY(0) = \sum\limits_{{k = 0}}^{{N + 2}} {y_{k} } DT_{k} (0) = \sum\limits_{{k = 0}}^{{N + 2}} {\left( {2k\mathop {\sum ^{\prime } }\limits_{\begin{subarray}{l} r = 0 \\ k - r{\text{ odd}} \end{subarray} }^{{k - 1}} T_{r} (0)} \right)} y_{k} ;$$
(160)

therefore:

$$\begin{aligned} {{\text {bc}_{_{DY(0)}}}}=\left( \begin{array}{ccccccccccccc} 0&1&0&-3&0&5&0&-7&0&9&0&-11&\dots \end{array}\right) . \end{aligned}$$
(161)

Finally we can find \(\text {bc}_{_{D^3W(0)}}\), having in mind (69), so

$$D^{{(3)}} T_{k} (0) = \tfrac{1}{4}k\mathop {\sum ^{\prime } }\limits_{\begin{subarray}{l} r = 0 \\ k - 3 - r{\text{ even}} \end{subarray} }^{{k - 3}} \left( {(k + 1)^{2} - r^{2} } \right)\left( {(k - 1)^{2} - r^{2} } \right){\mkern 1mu} T_{r} (0),$$
(162)

then:

$$D^{{(3)}} W(0) = \sum\limits_{{k = 0}}^{{N + 2}} {\left( {\tfrac{1}{4}k\mathop {\sum ^{\prime } }\limits_{\begin{subarray}{l} r = 0 \\ k - r{\text{ odd}} \end{subarray} }^{{k - 3}} \left( {(k + 1)^{2} - r^{2} } \right)\left( {(k - 1)^{2} - r^{2} } \right){\mkern 1mu} T_{r} (0)} \right)} w_{k} .$$
(163)

so:

$$\begin{aligned} {{\text {bc}_{_{D^3W(0)}}}}=\left( \begin{array}{ccccccccccccc} 0&0&0&24&0&-120&0&336&0&-720&0&1320&\ldots \end{array}\right) . \end{aligned}$$
(164)

Now, notice that the rigid–rigid boundary conditions (149) are to be suitably arranged in matrix A, considering \({{\textbf {x}}}=({\varvec{w}},{\varvec{y}},{\varvec{\theta }})\), as follows:

figure r

while the rigid-free boundary conditions (151) as follows:

figure s

In order to determine \(\text {bc}_{_{DY(0)}}\) and \(\text {bc}_{_{DY(1)}},\) we can employ the code 11.

figure t

While in order to determine \(\text {bc}_{_{D^3W(0)}}\) and \(\text {bc}_{_{D^3W(1)}}\), we need code 12.

figure u

Function \(\texttt{chebybvalD}\) 11 can be substituted in lines 4 and 5 in the code [40] to get a different code that allows us to determine the critical Rayleigh number for onset of convection in the rigid–rigid Bénard problem. The neutral curve is depicted in Fig. 14, and the critical wave and Rayleigh numbers are:

$$\begin{aligned} a^2_{c,\text {Chebyshev-}\tau }=9.7100\qquad \quad \text {and}\qquad \quad {\textsf{R}}_{c,\text {Chebyshev-}\tau }^{\texttt {B}_{rigid-rigid }}=1707.8. \end{aligned}$$
(165)
Fig. 14
figure 14

Plot of the marginal stability curve for the rigid–rigid Bénard problem

Instead, function \(\texttt{chebybvalD3}\) 12 can be used in lines 4 and 5 in the code [40] to determine the critical Rayleigh number for onset of convection in the rigid-free Bénard problem. The neutral curve is depicted in Fig. 15, and the critical wave and Rayleigh numbers are:

$$\begin{aligned} a^2_{c,\text {Chebyshev-}\tau }=7.1900\qquad \quad \text {and}\qquad \quad {\textsf{R}}_{c,\text {Chebyshev-}\tau }^{\texttt {B}_{rigid-free }}=1100.6. \end{aligned}$$
(166)
Fig. 15
figure 15

Plot of the marginal stability curve for the rigid-free Bénard problem

Note that thresholds (165) and (166) are exactly the same as those reported by Chandrasekhar in [35, Table III, pag. 43].

We can now compare the marginal stability curves for the free–free, rigid-free and rigid–rigid Bénard problem in Fig. 16. The presence of a rigid boundary yields a greater critical Rayleigh number. Indeed, it is expected as the fluid sticks to the rigid boundaries that curtail the motion, whereas in the case of free boundaries they allow the fluid more freedom of movement at the boundaries. This freedom leads to an increased fluid velocity and therefore to an enhanced heat transfer situation [52].

Fig. 16
figure 16

Comparison between thresholds in Bénard problem

5.4 Coupling parameter in nonlinear stability analysis

In this last subsection, we want to examine how one may deal with generalized eigenvalue problems occurring in nonlinear stability analysis. It can be shown that the following equations govern the nonlinear stability of the conduction solution of penetrative convection in clear fluids (see [32, pag. 235]):

$$\begin{aligned} \!\! \left( \begin{array}{cc} (D^2 \!-\! a^2)^2 &{}0\\ 0 &{}D^2 \!-\! a^2 \end{array}\right) \left( \begin{array}{c} W\\ \Theta \end{array}\right) \!=\! {\textsf{R}}\left( \begin{array}{cc} 0&{} \!-\! a^2\left( \zeta \!+\! \tfrac{\mu }{2} \!-\! z\right) \\ \left( \zeta \!+\! \tfrac{\mu }{2} \!-\! z\right) \mu ^{-1} &{}0 \end{array}\right) \!\! \; \left( \begin{array}{c} W\\ \Theta \end{array}\right) \end{aligned}$$
(167)

\(\mu >0\) being a coupling parameter to be optimally selected (for details about coupling parameters, see [2, chap. 4]). It turns out that for the problem under examination we need to work, for fixed \(T_U\ge 4^\circ C\), on the optimization problem:

$$\begin{aligned} {\textsf{R}}_{c,N}=\max _{\mu >0}\min _{a^2\in {\mathbb {R}}^+}{\textsf{R}}^2(\mu ,a^2). \end{aligned}$$
(168)

To this end, first of all we need to choose two intervals \(I=[a,b]\) and \(J=[c,d]\) (with \(a,c>0\)) and then for every fixed \({\bar{\mu }}\in I\) find the minimum \({\textsf{R}}({\bar{\mu }})=\min _{a^2\in J}{\textsf{R}}({\bar{\mu }},a^2)\) and finally the optimal parameter \({\widehat{\mu }}\) will be the one such that \({\textsf{R}}({\widehat{\mu }})=\max _{\mu \in I}{\textsf{R}}(\mu )\) (see Fig. 17). This idea brought us to write code 13, where at line 11 and 35 a proper function \(\mathtt {fullmatrices\_PClear\_mu}\) (available at [53]) that takes into account the coupling parameter \(\mu\) has been employed.

figure v
Fig. 17
figure 17

Plot of \({\textsf{R}}(\mu )\) to be maximized in order to find the optimal coupling parameter

Numerically, results are the same as those we find in the table given by Straughan in [32, pag. 236]\(^4\).