This article describes how *Mathematica* can be used to develop an understanding of the basic steps involved in solving Navier–Stokes equations using a finite-volume approach for incompressible steady-state flow. The main aim is to let students follow from a mathematical description of a given problem through to the method of solution in a transparent way. The well-known “driven cavity” problem is used as the problem for testing the coding, and the Navier–Stokes equations are solved in vorticity-streamfunction form. Building on what the students were familiar with from a previous course, the solution algorithm for the vorticity-streamfunction equations chosen was a relaxation procedure. However, this approach converges very slowly, so another method using matrix and linear algebra concepts was also introduced to emphasize the need for efficient and optimized code.

*Mathematica* is used to help with an initial understanding of the process of solving Navier–Stokes equations. For 2D incompressible flows, it is possible to recast the Navier–Stokes equations in an alternative form in terms of the streamfunction and the vorticity. In many applications, the vorticity-streamfunction form of the Navier–Stokes equations provides better insight into the physical mechanisms driving the flow than the “primitive variable” formulation in terms of the mean velocities , , and pressure . The streamfunction and vorticity formulation is also useful for numerical work, since it avoids some problems resulting from the discretization of the continuity equation.

The streamfunction is defined as

(1) |

where the integral has to be evaluated along a curve from the arbitrary but fixed point to point , ** **is the velocity vector, and is the unit normal on the curve from to ; see Figure 1. We regard as a function of the location of point .

**Figure 1.** Sketch illustrating the definitions of a streamfunction.

Figure 1 shows that is equal to the component of the velocity that crosses . Therefore represents the volume flux (per unit depth in the direction) through . Evaluating along two different paths and invoking the integral form of the incompressibility constraint shows that is path independent; that is, its value only depends on the locations of the points and . Changing the position of point only changes by a constant. It turns out that for all applications such changes are irrelevant. It is therefore common to suppress the explicit reference to . Hence, we regard as a function of the spatial coordinates only; that is, . Streamlines are lines that are everywhere tangential to the velocity field, that is, , where is the unit normal to the streamline. Hence the streamfunction is constant along streamlines. Note that stationary impermeable boundaries are also characterized by , where is the unit normal on the boundary. Therefore, is also constant along such boundaries. Invoking the integral incompressibility constraint for an infinitesimally small triangle shows that is related to the two Cartesian velocity components and via

(2) |

Flows that are specified by a streamfunction automatically satisfy the continuity equation, since

(3) |

For 2D flows, the vorticity vector only has one nonzero component (in the direction); that is, , where

(4) |

Using the definition of the velocities in terms of the streamfunction shows that

(5) |

where is the 2D Laplace operator.

The understanding of the steps involved in solving the Navier–Stokes equations using the vorticity-streamfunction form is one of the topics used in a third-year undergraduate course on computational fluid mechanics, solely for students majoring in mechanical engineering. The use of *Mathematica* makes the assumption that the students are familiar with the package, as it generally takes a good deal of exposure to *Mathematica* to become comfortable using it at the level required here [1]. The students taking the computational fluid mechanics course are indeed very familiar with *Mathematica*, as the computer algebra system is used during year one in the modules Calculus and Applications and Vector Calculus, and during year two in the module Numerical Methods for Engineering. In addition, there are many notes, explanations, and examples on the in-house Moodle open-source learning platform. Similar work to this can be found in Fearn [2], while background reading on computational fluid dynamics and vorticity may be found in Ferziger and Perić [3] and Chorin [4], respectively.

The aim here is to give a continuous and comprehensive process involving the mathematics of one formulation of the Navier–Stokes equations and a solution using *Mathematica*. In this way, the students can actually see the development of the mathematical description linked to a programming environment solution process so often hidden in commercial code used for training CFD students.

The Navier–Stokes equations for incompressible steady-state flow in vorticity-streamfunction form are

*Advection-Diffusion Equation*

(6) |

*Elliptic Equation*

(7) |

where is the Reynolds number. For a given problem, boundary conditions need to be specified to solve equations (6) and (7). The problem chosen here introduces the student to a classical computational fluid dynamics (CFD) case, namely the lid-driven cavity flow [5]. This flow is commonly used to test, for example, a novel method of discretization of the equations or new computer programming, as the resulting flow is well known from experiments. Consider a rectangular box as shown in Figure 2, where a lid is allowed to move in the horizontal plane from left to right. When the lid is not moving, the fluid in the box is stationary, whereas when the lid is moving, the fluid circulates inside the box. Here the boundary conditions needed for solution are summarized in terms of vorticity and streamfunction. As all four walls of the cavity touch, the streamfuction must be equal for all four walls, as indicated by the in Figure 2. The streamfuction is constant at the walls, as its gradient is velocity, which is zero relative to a given wall (no-slip condition), as indicated in the outer boxes also shown in Figure 2. The vorticity boundary conditions for each wall are also shown in each of these outer boxes and were derived from the streamfunction.

**Figure 2.** Summary of boundary conditions in terms of vorticity and streamfunction for cavity with moving lid.

It is convenient from a numerical point of view to make equations (6) and (7) nondimensional. If and are the height and width of the cavity, respectively, and is a reference velocity, then

.

Equations (6) and (7) become

(8) |

(9) |

defined on the domain . The boundary equations are defined by

(10) |

Here is an iterative solution for solving the incompressible steady 2D Navier–Stokes equations. The method is based on Burggraf’s proposal [6]. So as to include the boundary nodes of the cavity, central differencing is used to discretize equations (8) and (9). The number of nodes in the and directions is set at and , respectively. The mesh is a regular Cartesian grid with the nodes equally spaced at a distance , as illustrated in Figure 3.

**Figure 3.** Typical Cartesian mesh used for the lid-driven cavity flow.

To discretize equations (8) and (9), the following general finite central-difference approximations were introduced for spatial dimensions, obtained by adding or subtracting one Taylor series from another and invoking the intermediate value theorem. As can be seen from equation (11), the order of accuracy for both the first and second derivatives is .

(11) |

Using the approximations from equation (11), the discretized advection-diffusion equation (equation (8)) at the node is

(12) |

The elliptic equation (equation (9)) at the node is

(13) |

The equations are applied to the internal nodes of the Cartesian mesh; that is, and .

The solution method uses residual functions; that is, if the values of and are exact on the nodes spanned by the residual functions and , then

(14) |

where

(15) |

(16) |

The following fixed-point iterative procedure, based on the Gauss–Seidel scheme, is then constructed:

(17) |

where is a relaxation parameter lying in the range , and and refer to the respective iterations. In this article, the actual value of depends on and can be obtained by numerical experimentation. The use of this relaxation parameter is to improve the stability of a computation, particularly in solving steady-state problems. It works by limiting, when necessary, the amount that a variable changes from one iteration to the next. The optimum choice of is one that is small enough to ensure stable computation but large enough to move the iterative process forward quickly.

The boundary conditions now need to be determined. For the streamfunction from equation (11),

(18) |

For vorticity, the following needs to be considered for, say, the left wall of the cavity with one node outside the computational domain:

(19) |

The value of can be accounted for using the no-slip boundary condition on the cavity wall; that is,

(20) |

Using central differences, this condition can be written as

(21) |

where again the order of accuracy is .

This finding, together with , gives

(22) |

Similarly, for the other walls of the cavity the boundary conditions for vorticity can be deduced from

(23) |

to give

(24) |

where and are defined in Figure 3. Note that the final boundary condition shown in equation (24) is for the moving lid, and the extra term is due to the tangential velocity being nonzero.

This section starts with the definition of mesh size and grid spacing; for this problem the mesh spacing is set equal in the and directions. The parameters `Nx` and `Ny` denote the mesh size. Initially, `ω` and `ψ` are set to zero for all nodes except at the top wall, where vorticity is not zero. The Reynolds number is set at 100, the relaxation parameter `p` is set to 1, and the aspect ratio `γ` is set at 1. A maximum allowable residual value `e` is set, and nested loops are used to execute the iterative algorithm. At every iteration step `k`, if the maximum value of the absolute value of is less than `e`, the calculations are halted. The iterative loops are wrapped with the function `Timing` to give an estimate of the time taken to do the calculations.

Extraction of the centerline velocities is also instructive. First of all, students are given more experience viewing velocity profiles, and second, there are ample calculations and measurements in the literature [7, 8, 9] for comparison with the results obtained here. The centerline velocities (in the direction) and (in the direction) were derived from the streamfunction values using the equations

(25) |

(26) |

The velocity distributions for and in the following figure are drawn along the vertical and horizontal centerlines, respectively.

Importantly, the students were made aware that the profiles they calculated must be compared, preferably with experimental measurements, to test the validity of the calculation technique. As can be seen from the preceding figure, the calculations for the horizontal centerline velocities compare very favorably with those reported in the literature [7, 9] for .

It can be clearly seen that the relaxation procedure, though reasonably easy for students to follow and therefore educationally productive, is indeed very slow to converge. However, students must be aware that code should be written efficiently and optimized, making use of all available concepts and procedures. Therefore, as part of their understanding of solving Navier–Stokes equations in the best way, they were also introduced to the following *Mathematica* code. The preceding exercise was a small-scale problem using a fairly primitive method of solution, and even for this simple problem, the convergence time is prohibitive. Therefore, for large numerical computations and those with more complex geometry, it is important to use a solution method that will run more efficiently. This can be achieved using linear algebra and matrices and highly optimized functionalities built into *Mathematica*, namely `NDSolve` and `LinearSolve`. The following program solves the same problem as that described in Figure 2, except the Reynolds number is set at 400 and the computational grid is slightly more dense. The time to solve this same problem was reduced by over an order of magnitude. It should be understood that what the code is solving is the unsteady 2D Navier–Stokes equations. Each iteration is a time step from impulse-starting conditions to steady state, and for the lid-driven cavity flow, the unsteady solution converges to the steady state. The animation shown is for the streamfunction with a Reynolds number of 400.

Having established the method of solution, the student would then experiment by varying the grid size and seeking a solution independent of the grid, which is very important in CFD calculations. Results would also be obtained for different aspect ratios of the container. Again, where possible, calculations must be compared with experimental measurements to establish validity. As can be seen, the calculated horizontal velocity along the vertical centerline for was in good agreement with experimental results [7, 9].

This article outlines a well-defined sequence of steps needed to solve the Navier–Stokes equations cast in the vorticity-streamfunction form. The sequence is integrated with the use of *Mathematica* at appropriate stages to take care of the tedious computations, and hence to allow the students to concentrate on the overall details of the solution process. In addition, it is now important to integrate computer technology so as to complete lectures and theory. This has the advantages of helping with the computations, aiding presentation for reports and analysis, and motivating students. Incorporating *Mathematica* also takes away the “black-box” approach so often being used by students with full CFD commercial codes, which give no real understanding of the numerics involved. The idea of efficient and optimized coding was also introduced.

[1] | S. Pomeranz, “Using a Computer Algebra System to Teach the Finite Element Method,” International Journal of Engineering Education, 16(4), 2000 pp. 362–368. www.ijee.ie/articles/Vol16-4/IJEE1162.pdf. |

[2] | R. L. Fearn, “Airfoil Aerodynamics Using Panel Methods,” The Mathematica Journal, 10(4), 2008 pp. 725–739.www.mathematica-journal.com/2008/11/airfoil-aerodynamics-using-panel-methods. |

[3] | J. H. Ferziger and M. Perić, Computational Methods for Fluid Dynamics, 3rd ed., Berlin: Springer, 2002. |

[4] | A. J. Chorin, Vorticity and Turbulence (Applied Mathematical Sciences, Vol. 103), New York: Springer-Verlag, 1994. |

[5] | J. D. Bozeman and C. Dalton, “Numerical Study of Viscous Flow in a Cavity,” Journal of Computational Physics, 12(3), 1973 pp. 348–363. doi:10.1016/0021-9991(73)90157-5. |

[6] | O. R. Burggraf, “Analytical and Numerical Studies of the Structure of Steady Separated Flows,” Journal of Fluid Mechanics, 24(1), 1966 pp. 113–151. doi:10.1017/S0022112066000545. |

[7] | U. Gia, K. N. Ghia, and C. T. Shin, “High-Re Solutions for Incompressible Flow Using the Navier–Stokes Equations and a Multigrid Method,” Journal of Computational Physics, 48(3), 1982 pp. 387–411. doi:10.1016/0021-9991(82)90058-4. |

[8] | W. F. Spotz, “Accuracy and Performance of Numerical Wall Boundary Conditions for Steady, 2D, Incompressible Streamfunction Vorticity,” International Journal for Numerical Methods in Fluids, 28(4), 1998 pp. 737–757.onlinelibrary.wiley.com/doi/10.1002/%28SICI %291097-0363%2819980930 %2928:4%3 C737::AID-FLD744 %3 E3 .0.CO;2-L/abstract. |

[9] | D. C. Wan, Y. C. Zhou, and G. W. Wei, “Numerical Solution of Incompressible Flows by Discrete Singular Convolution,” International Journal for Numerical Methods in Fluids, 38(8), 2002 pp. 789–810. doi:10.1002/fld.253. |

D. Adair and M. Jaeger, “Developing an Understanding of the Steps Involved in Solving Navier–Stokes Equations,” The Mathematica Journal, 2015.dx.doi.org/doi:10.3888/tmj.17-8. |

Desmond Adair is a professor of mechanical engineering in the School of Engineering, Nazarbayev University, Astana, Republic of Kazakhstan. His recent research interests include investigations of airborne pollution for both passive and reacting flows, and developing engineering mathematics by the incorporation of computer algebra systems.

Martin Jaeger is an associate professor of civil engineering and head of department in the School of Engineering, Australian College of Kuwait, Misref, Kuwait. His recent research interests include construction management and total quality, as well as developing strategies for engineering education.

**Desmond Adair**

*School of Engineering
Nazarbayev University
53 Kabanbay batyr Ave.
Astana, 010000, Republic of Kazakhstan*

**Martin Jaeger**

*School of Engineering*

*Australian College of Kuwait
Al Aqsa Mosque Street
Misref, Kuwait City, Kuwait*

We describe the use of classical and metric multidimensional scaling methods for graphical representation of the proximity between collections of data consisting of cases characterized by multidimensional attributes. These methods can preserve metric differences between cases, while allowing for dimensional reduction and projection to two or three dimensions ideal for data exploration. We demonstrate these methods with three datasets for: (i) the immunological similarity of influenza proteins measured by a multidimensional assay; (ii) influenza protein sequence similarity; and (iii) reconstruction of airport-relative locations from paired proximity measurements. These examples highlight the use of proximity matrices, eigenvalues, eigenvectors, and linear and nonlinear mappings using numerical minimization methods. Some considerations and caveats for each method are also discussed, and compact *Mathematica* programs are provided.

One “curse” of high- and multidimensional data is the difficulty in graphically displaying how the data points are related to each other. Each data point (in some fields referred to as a case) is characterized by a vector of attributes (e.g. shape, color, temperature, etc.) with numerical values that form a set of coordinates. These coordinates specify a location in an -dimensional space, with being the number of variables used to describe each case. Visualization of such -dimensional data is problematic as, for example, we do not think in 17 dimensions! For human comprehension, we are limited to two- or three-dimensional graphics, sometimes referred to as visualizable dimensions, in which each case is represented by a data point. The distances between points and their relative locations reflect their proximity (similarity or dissimilarity), as measured by a metric function of their attributes, such as Euclidean distance. Larger distances between cases indicate that they are less related. Fortunately, multidimensional scaling (MDS) methods can be used to visualize the degree of proximity for high-dimensional datasets [1, 2, 3]. MDS methods can be used to project the -dimensional coordinates of each case to two or three dimensions, while preserving the relative distances between cases [4, 5]. These methods are increasingly employed in such diverse fields as immunology, molecular biology, marketing, perceptual mapping, and ecology to visualize relative “distances” between viruses, molecules, species, and customers’ behavior. In this article, we discuss some mathematical details of classical and metric MDS methods and build generalizable *Mathematica* programs that can be used for each. We incorporate use cases from geography, molecular virology, and immunology.

Before covering the analytical details, it is worth briefly discussing the variety of MDS methods. The simplest method is referred to as classical multidimensional scaling, also known as principal *coordinate* analysis (PCoA) [1]. PCoA is not to be confused with principal *component* analysis (PCA). The difference between PCA and classical MDS/PCoA is primarily based on the input data. PCA starts with a set of cases or data points , each described by a set of attributes , and uses a Euclidean distance to project the data to a lower-dimensional space oriented to maximize the variance observed between data points. In contrast, classical MDS begins with an input matrix that specifies proximities between pairs of items, often referred to as dissimilarities. It outputs a coordinate matrix in a lower dimension than the starting data (e.g. 120 dimensions projected to two) that preserves the relative distances between all data points. Classical MDS was originally developed by Gower [1] and others and is often demonstrated with a simple problem: given only the distances between entities (e.g. cities), is it possible to calculate the map showing their relative distances? We use this example in Section 4. In the specific case where the dissimilarity is measured by a Euclidean distance, PCA and classical MDS/PCoA are mathematically identical to another dimensional reduction method, singular value decomposition (SVD). In that case, there may be computational advantages to using SVD, which are discussed in this article.

While classical MDS relies on linear transformation of data using matrix operations, metric MDS methods depend on computational optimization. Metric MDS takes a proximity matrix and calculates a two- or three-dimensional coordinate matrix whose configuration minimizes the difference between the -dimensional and the calculated distances in the reduced dimensions for each case or data point [2, 3]. Thus, similar cases are located next to each other in a reduced-dimensional plot, while disparate cases are farther away, and the final coordinates can be projected to a planar or three-dimensional space. Other varieties of MDS, not discussed here, include nonmetric MDS, which uses isotonic regression methods, and generalized MDS, which projects the coordinates to an arbitrary smooth target space [3–7]. Metric MDS is more flexible than classical MDS for certain problems, including when the proximity matrix contains missing data or reflects a distance function that is not Euclidean. In addition, it can accommodate nonlinear mappings from the -dimensional data space to the visualization. However, because metric MDS uses numerical optimization, it is computationally expensive. These tradeoffs are explored in Section 7.

A byproduct of both MDS methods is the proximity matrix, which can also be used for other high-dimensional visualizations, such as heat mapping and multidimensional clustering methods. Combining MDS with these methods often reveals different facets of the data and aids investigators in gaining understanding of the underlying data structure and exploratory data analysis.

In the following sections, we discuss construction of proximity matrices, classical MDS, and metric MDS. Several examples illustrate the strengths and pitfalls of these methods; the full datasets are included in the article. The tradeoff between computational efficiency and accuracy is touched on as well. Each section briefly covers the mathematical underpinning of the method, a step-by-step example, a self-contained function using compact code, considerations for the method and alternate approaches, and a synopsis of the most salient points. A separate section discusses accuracy and computational efficiency and compares these methods.

This article was created using Wolfram *Mathematica* Version 10.0.2, running Macintosh OS X 10.9.5 on a MacBook Pro with a 2.8 GHz Intel Core i7 processor with 16 GB RAM. It contains the entire code and all the data needed for execution of all examples. Internet connectivity is required to retrieve the airport distances and perform the mapping of the airport locations within *Mathematica*.

For the sake of aesthetics and clarity, we have collapsed cells containing code related to the display of tables and figures, which appear in their final form.

Execution of the last section of the article may take 4–8 minutes, given the number of minimization problems that are calculated. Also, earlier versions of *Mathematica* may not execute the `GeoListPlot` commands properly (or at all for Version 9.0 or lower), given that this functionality was added in Version 10.0 and several options were added between Versions 10.0 and 10.0.2.

For the sake of brevity, the datasets are placed here in collapsed cells, along with several house-keeping functions for displaying tables and figures. Some of the data for intra-airport distances is retrieved by using the `AirportData` function and requires internet access if executing the

notebook again.

[collapsed cells]

Classical and metric MDS methods rely on a symmetric input matrix (referred to as a proximity matrix) that specifies the -dimensional distance between pairs of objects and , denoted . Proximity may be defined as a distance or dissimilarity.

In some applications, is composed of distances that are specified directly, for example, the flying distances between airport pairs in the United States, as shown in Table 1. The proximity matrix is a symmetric distance matrix with the airport names in the first column and the corresponding airport abbreviations for the column labels.

Often, is not the primary data but must be calculated from a set of cases, each of which is described by a vector of attributes, with the primary data specified in an cases by attributes data matrix. The attributes can be binary membership in a category or group, physical properties, or string sequences. The methods used to calculate vary by the data and the application. The most commonly used metric is the Euclidean distance for continuous variables, but other distance functions may also be used, such as the Hamming and Manhattan distances, Boolean distances for Boolean data, Smith–Waterman string sequence similarity, or color distance functions for images.

Table 2 is an example of such a cases by attributes matrix. The cases (rows) represent the influenza virus surface hemagglutinin proteins from various influenza strains (H1, H3, H5) and substrains (e.g. A/California/04/2009). The data is taken from an antibody binding assay, with the values reflecting the amount of antibody binding to each influenza hemagglutinin protein. The antibodies were isolated from the serum of ferrets infected with an influenza virus strain, shown in the columns. Each case (row) is characterized by a 15-dimensional attribute vector, with each attribute corresponding to the serum antibody binding values against that particular influenza strain hemagglutinin from a biological assay. Higher values indicate more antibody binding. Such assays are used to select vaccines each year against strains predicted to circulate in the fall. Note that there are 15 different cases characterized by 14 sera.

Before performing the MDS calculations, it is important to rescale each attribute to span the same range across all the cases, especially if the attributes have different units or variable ranges. This rescaling does not assume any specific statistical distribution. It is designed so that each attribute has equal weight in the proximity calculation, although weighted proximity matrices can also be used if the application requires this. Here we rescale the results for the above attributes so that the range of each attribute column (antibody binding test result for a single hemagglutinin) has a minimum of 0 and a maximum of 1000.

For multidimensional scaling, this data is transformed into a proximity matrix using a `EuclideanDistance` calculation. The larger the proximity measurement, the greater the difference between the hemagglutinin proteins from the two viral infection strains, as specified by the reactivity of immune sera against the probe hemagglutinin proteins. Table 4 uses the `DistanceMatrix` function to create a proximity matrix for the influenza. There are many ways to calculate distance matrices, and custom functions are often used. One convenient option is to use the `DistanceMatrix` function, which allows access to a number of standardized distance metrics (e.g. `EuclideanDistance`, `ManhattanDistance`, `CorrelationDistance`, etc.), which can be directly set by the option `DistanceFunction`. The `DistanceMatrix` function is contained in the `HierarchicalClustering` package.

It is often helpful to visualize a proximity matrix as a heat map using the `ArrayPlot` function. In Figure 1 the most similar hemagglutinin protein pairs are blue and the most different are red. As can be seen, this representation of the data suggests a similarity of influenza virus hemagglutinin proteins from similar strains (H1, H3, H5) and the occurrence of year-to-year differences, especially for the

H1 strains.

**Figure 1.** Heat map of proximity matrix data.

Another common application of multidimensional scaling is to compare protein or DNA sequences. Such sequences are essentially linear lists of strings that specify the protein or nucleic acid composition. Sequence differences are used to estimate molecular evolution, how the immune system may respond to a new virus after immunization, and cross-species comparison of molecules.

To construct a protein sequence proximity matrix, we begin with the amino acid sequences of the hemagglutinin proteins from influenza strains specified in the proximity matrix of the previous section. These were retrieved from the UniProt database (www.uniprot.org). Each letter in the sequence represents an amino acid, and each sequence is approximately 566 amino acids long.

To calculate the proximity matrix, we use a rescaled inverse of the Smith–Waterman similarity calculation, with the PAM70 similarity rules for amino acid comparison. Sequence similarity calculations have larger values with greater similarity, and the minimum score is generally the length of the sequence. Because MDS methods use proximity measures that increase monotonically with dissimilarity, the inverse of the sequence similarity function is used. Thus, for clarity in this example, we have transformed the result by subtracting a constant (528), which is one less than the minimum sequence length, and multiplying the inverse by a scale factor of . Note that nonzero values do

not occur.

The first step in multidimensional scaling is to create a proximity matrix. The value of each matrix element is a distance measure; the greater the difference between the two elements being compared, the greater the value of the metric. We have demonstrated three different cases of proximity matrix construction, including: (i) the airport distance case, where the proximities are known *a priori* and do not need to be calculated; (ii) the influenza protein antibody reactivity case, with proximity calculation from a cases by attributes matrix; and (iii) the influenza protein sequence example, with calculation from a sequence similarity measure. Heat maps are useful for displaying proximity matrices, giving a visual view of similarities. All the resulting proximity matrices can be used for MDS calculations, as will be discussed next.

Here we briefly describe the mathematics of classical multidimensional scaling, which uses a linear coordinate transformation calculation to reduce case coordinates from dimensions down to two or three dimensions. The approach begins with calculating a proximity matrix. The orientation of the new coordinate system is such that it accounts for the greatest amount of variance between cases, as defined by attributes, in the reduced number of dimensions. The new coordinates can be used to plot the relative locations of the data points and help visualize differences between data points and clusters of similar cases. The proximity matrix can also be used for data clustering and heat mapping, which provide alternate visualizations of case relationships.

Let be a matrix, where is the number of individual cases (e.g. data points) and is the number of measured variables or attributes (e.g. financial variables, consumer product attributes, antibody binding measurements, etc.), which are used to discriminate between each case , .

If the data attributes are of different scales and units, they are generally rescaled with a range of . This assures that each attribute contributes equally to the proximity measure.

Alternatively, may remain in the original units if each attribute has the same range and units, or if a weighted proximity matrix is desired. Next, let the proximity matrix of or rescaled be a matrix of dimensions with elements

(1) |

One can use a variety of applicable proximity measures (e.g. Euclidean, Mahalanobis, etc.) to create the proximity matrix. If the proximity measure is a Euclidean distance, then classical MDS is equivalent to principal component analysis (PCA). If any other distance function is used, then classical MDS will result in a different transformation that is not equivalent to PCA.

Let be the identity matrix of dimensions and be the constant matrix of dimensions , where . Let be the matrix of the squared proximities:

(2) |

The kernel matrix is derived by first calculating the matrix from the identity matrix and the number of variables :

(3) |

is the matrix that double-centers the input matrix by subtracting the row and column means from every element of the matrix. Introducing the constant creates an equivalence to PCA if is a Euclidean distance function:

(4) |

The eigenvalues and eigenvectors of are calculated. To reduce to dimension with , only the first of a ranked list of the and are selected (e.g. for a two-dimensional mapping).

The diagonal matrix of the square roots of the eigenvalues is

(5) |

The matrix of relative coordinates in dimensions is then calculated by the product of the matrix of eigenvectors and the diagonal matrix of the square roots of the eigenvalues :

(6) |

We begin with one of the original motivating problems related to MDS, reconstructing the relative locations between cities in two dimensions, knowing only the relative distances between each one. We use the United States airport distance data from Section 3 and reconstruct the cities’ relative geographic positions. We begin by squaring the distance functions and calculating the scale of the dataset.

Next, we create an identity matrix, with all elements being 0 except the diagonal elements, which are 1, and a constant matrix with all elements equal to 1. Both matrices are of the same dimensions and are used in subsequent calculations to transform data from 28 down to two dimensions.

We then calculate the kernel matrix and double-center the new -dimensional coordinates.

With the number of dimensions set to 2, the matrix eigenvectors and eigenvalues are calculated. The sign of the first eigenvector is adjusted to lay out the cities from west to east. (*Mathematica* does not guarantee the direction of an eigenvector.)

The transformation matrix `dMTX` is calculated from a diagonal matrix formed by the eigenvalues `Ev`, and the coordinate matrix `EmM` is calculated from the eigenvectors `Em`.

The graph coordinates `cMDScoord` are calculated and projected to two dimensions.

Finally, we plot the two-dimensional airport locations in `cMDScoord`, which shows the airports in the new coordinate system.

**Figure 2.** Classical MDS display of relative airport locations.

Classical multidimensional scaling gives a solution that has an excellent projection of the cases in a lower dimension, preserving the between-cases distances from dimensions. It is important to note, however, that the solution is not unique with respect to the rotation and reflection of the visualization. It is often the case when one knows the “true” orientation of the case locations (e.g. the previous map example), that classical (and metric) MDS methods yield a visualization that is reflected or rotated. In these cases, use of other boundary conditions (fixing known coordinates) helps constrain the orientation of the solution. Often, however, such boundary conditions are not available.

Given the above solution, how well does classical MDS reproduce the airport coordinates? Because we have a gold standard, the actual airport locations, comparison of the coordinate estimates is possible. However, the airport locations are represented in a geographic coordinate system, making a comparison of calculated versus actual airport locations a bit more complicated. One approximate way to approach this issue is by first examining the correlation between the actual airport locations, in longitude and latitude coordinates, and the derived coordinates from the classical MDS calculation, using the `PearsonCorrelationTest`. The units are different, which we will address in a moment, but this does not affect the Pearson correlation test.

**Figure 3.** Comparison of actual and estimated coordinates.

While the correlations are high, they are not perfect, as we can see by the off-diagonal locations of some of the points. To better visualize these differences, we transform the classical MDS coordinates into longitude and latitude units. This is a transformation that uses the pseudoinverse matrix to translate and rotate to find a good alignment between the two coordinate sets.

This type of transformation preserves the relative distances between the classical MDS derived city locations and thus provides a relatively accurate estimate of how close the estimates are to the actual city locations. A more accurate solution would involve mapping of the coordinates to an appropriate spherical projection system; however, this is outside the focus of this article.

The transformation coefficients can now be used to transform the classical MDS derived coordinates into `GeoPosition` values. To compare the actual (●) with the cMDS calculated (◆) airport locations, we use the `GeoListPlot` function, which plots both sets of points on a map of North America.

**Figure 4.** Comparison of airport geo locations.

The accuracy of the classical MDS estimates is fairly good, but not perfect. Part of this error is due to the approximate transformation from arbitrary MDS coordinates to geographic coordinates, and the complex projection to a flat map.

The preceding code can be summarized in a succinct *Mathematica* function for classical MDS calculation. This function takes a proximity matrix as input and returns coordinates mapped to a space of the specified number of dimensions. The default number of dimensions is two, but the function also works with three or more dimensions.

It is important to note that if the proximity matrix used for classical MDS is formed from a cases by attributes matrix using a Euclidean distance, then classical MDS is equivalent to principal component analysis. Principal component analysis is a specific case of the more general singular value decomposition method (SVD). Details of the SVD mathematics and computational method is not discussed in detail here, but rather we will outline the computational steps necessary to use the method with the function `SingularValueDecomposition`.

As with classical MDS, a transformation matrix is calculated, and the data is centered to a mean of zero.

The SVD function is then applied to the normalized data and yields three matrices. Here `ww` is the diagonal matrix of eigenvalues and `vv` is the coordinate matrix.

Next, the two-dimensional projection of the coordinates is calculated.

When the dataset to be analyzed is very large, then the computational efficiency degrades quickly if the proximity matrix must be directly calculated. In this case, a matrix transformation can be applied to avoid a cell-by-cell proximity matrix calculation; this greatly increases computational efficiency. The computational efficiency for both classical and metric MDS is discussed, with a direct comparison, in Section 7.

Classical MDS is a data mining and data exploration method allowing dimensional reduction to be used to highlight possible clusters, similarities, or differences between cases described by high-dimensional attribute vectors. It is a starting point for more rigorous statistical analysis and hypothesis testing. When the input proximity matrix is composed of Euclidean distances, classical MDS is equivalent to both principal coordinate analysis and singular value decomposition. Computational efficiency and possible limitations of classical MDS methods are discussed in Section 7.

Metric multidimensional scaling is a second type of MDS. While classical MDS relies on matrix algebra, metric MDS involves computational minimization of the difference between -dimensional and two-dimensional proximity measures (e.g. Euclidean distance) of the case coordinates in each dimensional system. In essence, the method attempts to minimize the total error between actual and reduced intercase distances for the group of cases as a whole. Metric MDS is also flexible, accommodating different types of proximity metrics (e.g. not Euclidean), as well as different stress functions (nonlinear transformation and distance metrics other than Euclidean) for minimization. This permits nonlinear dimensional reduction, where the projection of data from an -dimensional space to lower dimensions can be done using a nonlinear transformation. The end result is a dimensional reduction that allows for data visualization.

As in the previous section, we first describe the mathematics with some references to implementation, then demonstrate a practical example.

Metric MDS also begins with a proximity matrix , which represents the original -dimensional proximity measure for the cases , where . This proximity matrix can be given *de novo*, as in distances between airports, or can be calculated from a cases by attributes matrix as described previously,

(7) |

Initial values for the case coordinates, used to seed the minimization algorithm, can be generated at random or calculated using values from the classical MDS algorithm. So we next set up the initial coordinate matrix for a two-dimensional projection, for the minimization algorithm,

(8) |

where . Next, we create a matrix of variables representing the coordinates that the minimization algorithm estimates:

(9) |

We then calculate a matrix of distance functions for using Euclidean distance between any two elements and ,

(10) |

The distance matrix is now given by

(11) |

For the minimization, several different types of stress functions may be used. Here we select the stress function to be the sum of the squares of the errors (SSE):

(12) |

We use the efficient and robust `"DifferentialEvolution"` method, with sufficient search points to avoid local minima. Some aspects of the choice of minimization methods are discussed later.

This example is motivated by the need to determine if an influenza strain is sufficiently different, as determined by the immune system, so that even if a person has prior immunity from vaccination against other similar strains, it will be insufficient to protect against the new strain. Influenza vaccination relies on the immune system’s ability to generate protective antibodies, which are proteins that bind to the virus and block its ability to infect cells in the respiratory system. The major protection comes from antibodies that bind the viral surface protein hemagglutinin, the protein responsible for attaching the virus to the target cells. Variations in the hemagglutinin protein structure between influenza strains allow the viruses to evade the immune system and cause an infection. This is why the influenza vaccine composition is changed every year. Figuring out which strains to include in the influenza vaccine is an annual problem for the international organizations that recommend changes in the seasonal influenza vaccine.

Metric MDS provides a graphical way of visualizing influenza strain similarity, derived from experiments measuring the ability of serum from animals infected with influenza to bind to the target virus hemagglutinin. There has been extensive literature over the last decade on the use of metric MDS for this purpose, referred to as antigenic cartography [8–11]. Metric MDS was chosen for dimensional reduction and visualization by several groups, as classical MDS methods could not be easily adapted to solve several issues [8, 9]. These included the need for complete datasets [10, 11], where in some cases data was missing due to experimental considerations. Metric MDS methods could be adapted to impute relationships [10]. In addition, metric MDS was viewed as a more accurate estimator of influenza strain antigenic distance due to correlations with the binary logarithm of the hemagglutinin inhibition assay serum titers [8, 9]. Use of metric MDS continues in the influenza literature [10, 11], although newer methods of measuring antibody reactivity do not have the same issues as older assays, and classical MDS could be used to the same end. To illustrate the method of metric MDS, however, we will use it in this example. We discuss method selection in Section 7, as well as considerations of computational efficiency.

We begin with the proximity matrix derived in the previous section from the antibody reactivity to influenza hemagglutinin data. We next calculate the relative positions of each influenza strain with respect to the entire set by minimizing a stress function. The `Array` function is used to create an array of variables that specify the coordinates for each case as a 2D set of points.

Each `sr` variable pair will hold a pair of coordinates in two-dimensional space. Finally, we flatten the list of variable pairs to input into the function `NMinimize`.

The next section of code creates a series of Euclidean distance calculations for the distances between all combinations of case locations, using the estimated coordinates for each point. For succinctness, only one function within the full matrix is displayed.

The stress function is a very large least-squares expression.

The first nonzero element of the stress function is shown here. The reader may expand the formula to see the entire function, if desired.

Finally, we must choose the method for minimizing the stress function. We discuss two options, `FindMinimum` and `NMinimize`. A known issue with metric MDS is the existence of local minima, and thus identifying a global minimum cannot be guaranteed [7]. While `FindMinimum` may be computationally more efficient, it also lacks the ability to specify the number of search points and is prone to finding local minima instead of global minima. These issues are discussed in some detail in Section 7. In contrast, the `NMinimize` function allows specification of `"SearchPoints"` to address this issue and may be substantially more robust. For these reasons, we chose `NMinimize` to optimize the stress function.

The viral strains are then plotted in the two-dimensional space and are color-coded for clarity (H1, H3, and H5). Note that the coordinate system is arbitrary, in the sense that what is preserved and important are the relative distances between the data points. Thus, we have omitted the axes, which have the same scale in each dimension.

**Figure 5.** Relative antigenic distances for influenza strains.

Examining the plot, it is immediately apparent that the influenza strains fall into four distinct clusters. Two of these correspond to major hemagglutinin protein strains (H3, H5). In addition, we can see differences between temporally distinct strains in the H1 influenza strains, giving perhaps two clusters. For example, note the antigenic distance between the pandemic A/California/07/2009 (CAL709), A/Utah/20/2009 (UT2009), and A/Mexico/41/2009 (MEX4109) strains and the other H1 influenza strains. This likely reflects molecular mutations in the hemagglutinin proteins for the 2009 strains. These mutations resulted in decreased binding of antibodies from ferrets infected with earlier influenza strains. This finding was consistent with the decreased population immunity observed in humans to A/California/07/2009 and demonstrates the pandemic nature of that particular influenza strain.

Given that the influenza strains seem to cluster together, what is the relationship between MDS and methods of unsupervised data clustering used in data mining? The answer lies in the use of the proximity matrix, which is used by both hierarchical and agglomerative clustering methods to determine relatedness. This relationship was noted by the developers of the MDS methods [1, 2, 8]. To briefly demonstrate, we apply hierarchical clustering to the same proximity matrix `Dm`, using the `DirectAgglomerate` function. Ward’s minimum variance method is used for determining cluster linkage.

The resulting dendrogram is displayed in Figure 6. Note the grouping of the different virus types (H1, H3, and H5) based on the reactivity of ferret serum after infection with a single virus and the resulting antibodies against the hemagglutinin proteins.

**Figure 6.** Dendrogram of influenza virus relationships.

To explore which viruses are antigenically closer to each other, a heat map of the relative distances from the calculated coordinates (or the original proximity matrix) can then be created with `DistanceMatrix` and `ArrayPlot`. Note that more antigenically similar influenza strains have smaller distances between each other.

**Figure 7.** Heat map of proximity matrix data.

As in the previous section, we end with a general function for the metric MDS calculation. The function requires several input variables, including precision, accuracy, the minimization method, and the maximum number of iterations. This function uses the classical MDS routine for the initial coordinate estimates. Some suggested defaults are given in the function definition to be passed to `NMinimize`. The metric MDS function is written for two-dimensional mapping that could easily be generalized for three dimensions.

One of the advantages of metric MDS methods is the ability to use nonlinear mappings from -dimensional to visualizable space. We now use this function to create an MDS map comparing the influenza hemagglutinin proteins by sequence similarity. Recall that the proximity measure for sequence comparison is the Smith–Waterman sequence distance, which is not a Euclidean distance function. Thus, this violates the assumptions of classical MDS and makes metric MDS the appropriate method to use, albeit at computational cost. Taking the hemagglutinin protein proximity matrix, `fluPm`, we apply the `metricMDS` function and obtain the coordinates. We also apply hierarchical clustering to the proximity matrix `fluPm`.

One of the advantages of metric MDS methods is that one can use nonlinear stress functions to emphasize particular regions of data relationships. One of the first nonlinear metric MDS methods was that of Sammon’s mapping [12, 13]. Sammon’s mapping can be useful in revealing underlying data structure or differences with nonlinear relationships. This mapping minimizes the following general nonlinear form of stress functions:

(13) |

where is a weighting function and is a constant. In the case of Sammon’s mapping, the stress function is defined by , , with specified as [12]:

(14) |

Many related nonlinear mappings exist of the same form [12, 14]. For the purposes of this example, we explore applying a nonlinear exponential MDS mapping with a stress function defined by , , , , and :

(15) |

Note that is an empirically specified tuning factor. This nonlinear mapping function decreases the contribution to the overall stress function of larger and has the effect of expanding the mapped distances between data points with smaller . The advantage of this mapping is that the weight of any point in the minimization is inversely proportional to its magnitude. Thus, smaller differences between data elements are spread out. The coding of the exponential MDS function lets you specify .

To demonstrate, we apply the metric nonlinear MDS method to the above `fluPm` dataset of protein sequence comparisons. First, we apply the standard metric MDS function defined in the previous section, `metricMDS`, and generate a dendrogram to highlight the sequence differences.

**Figure 8.** Influenza virus relationships from protein sequences.

While the major influenza viral subtypes (H1, H3, and H5) all cluster together, minimal differences can be observed with respect to sequences differences within each subtype. Using the nonlinear mapping, as shown in Figure 9, accentuates the small differences between the hemagglutinin protein sequences. Note the negative exponential weighting function, with the large distances between hemagglutinins being given less weight in the minimization. We are now able to visualize the division of the H1 influenza hemagglutinins into two major clusters and the split between clusters of the H3 substrains within the visualization. It is worth noting that the hierarchical clustering may capture these differences.

**Figure 9.** Weighting function and nonlinear mapping of protein sequences.

Metric multidimensional scaling is a more flexible method compared to classical MDS. While computationally less efficient, it allows nonlinear dimensional reduction that is not possible with the SVD or PCA method of classical MDS. This functionality can be used to highlight possible clusters, similarities, or differences between cases described by high-dimensional attribute vectors and to weight or penalize the stress function based on data attributes. As with classical MDS, complementary visualization methods allow for a fuller picture of case differences but must be carefully interpreted when nonlinear stress functions are used.

From a computational perspective, several features of classical and metric MDS methods should be considered when selecting which method to use for a specific analysis.

Classical MDS is computationally straightforward but has some subtle mathematical constraints. For a solution to exist in Euclidean space, the distance matrix must follow a set of necessary and sufficient conditions [1, 15]. In practice, this is rarely an issue. When it is an issue, it often manifests by a computational result expressed in imaginary numbers. If, however, the proximity matrix is composed of Euclidean distances, classical MDS becomes principal component analysis, and the support vector machine (SVM) function can be used. This is much more computationally efficient, as we demonstrate in Section 7.3, and is the preferred method of MDS for visualization of most data.

Metric MDS has somewhat more relaxed constraints than classical MDS. For very high numbers of initial dimensions , metric MDS is computationally and memory intensive. This is primarily due to the need to use iterative optimization to minimize the stress function, whereas classical MDS uses more efficient matrix algebra operations. In addition, one needs to pay attention to the algorithms used to perform metric MDS to ensure that minimization finds global rather than local minima.

We next examine the selection of minimization algorithms for metric MDS, compare the computational efficiency of classical and metric MDS methods, and discuss the particular circumstances where metric MDS may be the method of choice.

With metric MDS, selecting a minimization algorithm with an appropriate `Method` setting for *Mathematica*’s built-in function `NMinimize` may require some investigation. In addition, a known issue with metric MDS is the existence of local minima, so that a global minimum cannot be guaranteed [7]. Using a large number of starting points or selecting the appropriate minimization function and method may help. In this article we have used `NMinimize` with `Method` set to the `"RandomSearch"` option. We also specified sufficient search points to avoid local minima. This can be an important issue when no other external data is available to constrain the solution and when it is not known if other minimization methods will routinely converge to a solution.

It is worth exploring this tradeoff between convergence, accuracy, and computational efficiency. For example, the execution time of `NMinimize` increases with the number of initial search points. The next example uses `NMinimize` on the influenza antibody dataset distance matrix `Dm` and the method `"RandomSearch"`. In this case, however, the number of search points appears to make little difference in the residual after optimizing the stress function.

**Figure 10.** Efficiency of `NMinimize` (`RandomSearch`).

In the case of `RandomSearch`, there appears to be no tradeoff with this particular dataset. In contrast, the theoretically more robust setting finds a small number of varying minima, which improves after specifying a larger number of search points. Also note the improved execution times, which are an order of magnitude less than with `RandomSearch`.

**Figure 11.** Efficiency of `NMinimize` (`DifferentialEvolution`).

Another consideration is the speed of computation. The `FindMinimum` function is often much faster than `NMinimize`, but the tradeoff is the risk that the algorithm will not converge or that it will find local instead of global minima. For the influenza data, `FindMinimum` can suffer from both nonconvergence and local minima, although the former issue may be sporadic. The sporadic nature of convergence can be frustrating and problematic. The issue of finding local minima is potentially more serious. To explore this further, we minimized 300 times with `FindMinimum`.

The results are displayed as a histogram in Figure 13. We found that a number did not converge with the influenza antibody-reactivity dataset. Of even more concern is that `FindMinimum` was not consistent, and often appeared to provide local rather than global minima. This may in some cases be dataset specific. The starting points selected, here a `RandomReal` number between and for each coordinate, are also critical for `FindMinimum`.

**Figure 12.** Residuals and convergence using `FindMinimum`.

The convergence can be improved by minimizing the sum of the squares rather than the Euclidean distance. Note that the minimum residual is higher than when minimizing the sum of the differences between distances rather than the square of the difference between distances. This may be due to computational considerations, in that there is differentiability at the optima when minimizing the sum of the squares of the distances, while this is lacking if minimizing the difference between the distances. Still, a moderate number (2% to 15% from 300 attempts) of the solution attempts did not converge or find global minima. Whether this is an issue for your particular application depends on both the level of precision required and the computational efficiency required.

**Figure 13.** `FindMinimum` and minimizing the sum of the squares.

Given the low percentage of nonconvergence and the presence of local minima, one could execute `FindMinimum` several times and take the results that converge with the lowest minimum. This does increase the time for execution. An alternative is to use the function `NMinimize`. The tradeoff is an increased computational time for consistent convergence on global minima, as shown here. This demonstration takes several minutes to perform on this dataset, even with parallelization.

**Figure 14.** Residuals and convergence using `NMinimize`.

A single minimum residual is obtained for all 300 separate runs of `NMinimize`. Thus, unless local minima are known not to be an issue, `NMinimize` may be a more consistent minimization method for metric MDS routines.

The issues of optimization and computational efficiency make it useful to benchmark classical and metric MDS methods with respect to execution time. Therefore, we compared SVD with classical and metric MDS across the three example datasets. For metric MDS, we include both `FindMinimum` and `NMinimize`. The measured execution times encompass all the steps from the input of the proximity matrix through final coordinate output, but not plotting. The previously created `classicalMDS` and `metricMDS` functions defined previously were used, along with new functions created for singular value decomposition (`mdsSVD`) and metric MDS using `FindMinimum` (`findMinMDS`).

Note that `FindMinimum` failed to converge for the airport dataset but did converge for both the flu antibody and sequence datasets, a behavior that may vary between executions. Timings are shown here.

Overall, there is a speed advantage to using classical MDS and SVD, which are several orders of magnitude faster than metric MDS using either `FindMinimum` or `NMinimize`. This advantage assumes that the proximity matrix can be formulated using a Euclidean distance, and thus other measurements (e.g. Manhattan distance, etc.) may require other methods. It also assumes that you require a linear mapping from the -dimensional space to the visualizable space. SVD has the advantage that, for many applications, the proximity matrix may not have to be directly calculated, saving additional memory and computational time [8]. With respect to metric MDS, there are also tradeoffs. For moderately large datasets, if one can optimize the conditions to avoid nonconvergence and local minima, `FindMinimum` is a good choice. Note that the execution time for `FindMinimum` in the airport and influenza antibody dataset examples occurred in the setting of failure to converge. Although slower, metric MDS using `NMinimize` had no issues with nonconvergence or finding local instead of global minima.

Given the computational advantages of classical MDS in its various forms (principal component analysis, singular value decomposition, etc.), why would you choose metric MDS, which requires numerical optimization? For those wishing an in-depth and lucid explanation, we refer you to the initial work of Gower [15] and the outstanding article by Shiens [16]. In short, classical MDS methods are usually preferable to and always computationally more efficient than metric MDS methods. The method is computationally efficient and robust; there are very few cases where classical MDS methods fail to provide a visualization. For some datasets, classical MDS methods may not provide optimal visualization, and metric MDS should be considered. Some examples include datasets whose variables have a non-Gaussian distribution, those where the distance metric is not Euclidean, those requiring imputation of missing data [10, 11], or cases with a parametrization in a nonorthogonal coordinate system [16]. For nonlinear dimensional reduction, which is often used in graph layout algorithms, metric MDS with stress function minimization is the method of choice [14].

Thus, selection of an MDS method for visualization should consider several factors. If the distance function is Euclidean, and especially if the dataset is large, SVD or classical MDS are the most appropriate and computationally efficient methods. In the less common case where metric MDS is used, careful consideration should be given to the choice of stress function minimization method (in this example `NMinimize` versus `FindMinimum`) to avoid local minima.

We have demonstrated the application of two methods of multidimensional scaling, classical and metric, for the visualization of similarity/proximity of high-dimensional data, with reduction to two or three dimensions. We have shown how these methods can be used to visualize the relatedness of influenza virus strains with respect to antibody-mediated immunity, as well as their utility in reconstructing relative spatial-geographic locations using only interlocation distances. These MDS methods are, however, quite generalizable. Both classical and metric MDS rely on a proximity matrix. While the examples in this article use continuous variables and sequences or case attributes, a variety of data types with appropriate proximity metrics can be visualized with MDS methods, such as molecular DNA or protein sequence data (Smith–Waterman similarity, Needleman–Wunsch similarity, or Damerau–Levenshtein distance), Boolean data (Hamming distance), and images (image distance, color distance). For cases with a single data attribute (e.g. sequence similarity, distance), no data scaling is necessary. For cases with multiple attributes having disparate units, standardization (e.g. -score) and rescaling are needed to equally weight each attribute.

In our examples, we used reduction down to two dimensions for multidimensional data visualization. Reduction to three dimensions is easily accomplished with both classical and metric MDS, although the computational cost may increase with the added dimension, depending on the method used. While we have emphasized data visualization, the classical MDS method can also be used for reduction to four or more dimensions as a method of identifying the weighted combinations of components that contribute the most to the data variance. In these cases, the goal is to select a small set of variables that explain the most variance in the dataset, such that this minimum set of variables can be further used for statistical or other modeling.

We have also shown how MDS methods are related to clustering algorithms, which also use proximity matrices to compare and classify cases by their attributes. This relationship also allows creative graphical display of multidimensional data from several vantage points. For example, one can use the MDS plot to display the relative proximity of cases to each other and plot marker coloring or other methods to add information regarding other case attributes. Some caution is in order, however, as different proximity measures and data transformations may give different clustering and classification. Parallel display of dendrograms and heat maps may also enhance understanding of the relationship of data clusters to each other. Similarly, heat maps, combined with MDS displays, are particularly helpful for data exploration, in that they enhance visual identification of those data attributes (dimensions) that contribute the most to differentiating between case clusters.

Care should be taken when selecting the MDS method. In most cases, classical MDS will be the most computationally efficient method, especially for very large datasets. In the cases where metric MDS is optimal, such as the use of nonlinear mapping, care should be taken to choose a minimization method that is robust and avoids local minima. Performing some testing on a subset of the data can be very informative regarding convergence, accuracy, and computational efficiency. While we did not discuss in detail how constraining optimization problems can improve computational efficiency and accuracy, this should also be considered whenever boundary conditions or other information is available.

Finally, one must remain aware that these methods reveal only associative patterns. Further analysis with rigorous statistical inference methods is needed to test the validity and specify the error boundaries of these associations. Mechanistic studies should be performed, if possible, to confirm suspected causal relationships. Overall, however, MDS methods are excellent for dimensional reduction and data exploration with the goal of creating comprehensible and informative quantitative graphical representations of multidimensional data.

We would like to thank Ollivier Hyrien, Alex Rosenberg, Chris Fucile, and Melissa Trayhan for their suggestions and critical reading of the manuscript. We would also like to acknowledge the reviewer at the *Mathematica Journal*, who suggested several improvements and additions, including the evaluation of execution time and accuracy for the MDS methods, and the discussion regarding the relative merits of `SingularValueDecomposition`, `NMinimize`, and `FindMinimum`. This work was supported by grants to the authors from the Philip Templeton Foundation, as well as the National Institute of Allergy and Infectious Diseases and the National Institute of Immunology, grant and contract numbers HHSN272201000055C, AI087135, AI098112, AI069351.

[1] | J. C. Gower, “Some Distance Properties of Latent Root and Vector Methods Used in Multivariate Analysis,” Biometrika 53(3–4), 1966 pp. 325–338.doi:10.1093/biomet/53.3-4.325. |

[2] | W. S. Torgerson, “Multidimensional Scaling: I. Theory and Method,” Psychometrika, 17(4), 1952 pp. 401–419. doi:10.1007/BF02288916. |

[3] | W. S. Torgerson, Theory and Methods of Scaling, New York: Wiley, 1958. |

[4] | T. F. Cox and M. A. A. Cox, Multidimensional Scaling, Boca Raton: Chapman and Hall, 2001. |

[5] | I. Borg, P. Groenen, Modern Multidimensional Scaling: Theory and Applications, 2nd ed., New York: Springer, 2005 pp. 207–212. |

[6] | M. Wish and J. D. Carroll, “Multidimensional Scaling and Its Applications,” Handbook of Statistics, Vol. 2: Classification, Pattern Recognition and Reduction of Dimensionality (P. R. Krishnaiah and L. N. Kanal, eds.), Amsterdam: North-Holland, 1982 pp. 317–345. |

[7] | V. Saltenis, “Constrained Optimization of the Stress Function for Multidimensional Scaling,” in Computational Science–ICCS 2006 (V. Alexandrov, G. van Albada, P. A. Sloot, and J. Dongarra, eds.), Berlin: Springer, 2006 pp. 704–711.link.springer.com/chapter/10.1007/11758501_ 94. |

[8] | D. J. Smith, A. S. Lapedes, J. C. de Jong, T. M. Bestebroer, G. F. Rimmelzwaan, A. D. M. E. Osterhaus, and R. A. M. Fouchier, “Mapping the Antigenic and Genetic Evolution of Influenza Virus,” Science, 305(5682), 2004 pp. 371–376. doi:10.1126/science.1097211. |

[9] | T. Bedford, M. A. Suchard, P. Lemey, G. Dudas, V. Gregory, A. J. Hay, J. W. McCauley, C. A. Russell, D. J. Smith, and A. Rambaut, “Integrating Influenza Antigenic Dynamics with Molecular Evolution,” eLife, 3:e01914, 2014. doi:10.7554/eLife.01914. |

[10] | Z. Cai, T. Zhang, and X.-F. Wan, “Concepts and Applications for Influenza Antigenic Cartography,” Influenza and Other Respiratory Viruses, 5(Suppl. s1), 2011 pp. 204–207. www.ncbi.nlm.nih.gov/pmc/articles/PMC3208348. |

[11] | D. W. Fanning, J. A. Smith, and G. D. Rose, “Molecular Cartography of Globular Proteins with Application to Antigenic Sites,” Biopolymers, 25(5), 1986 pp. 863–883. doi:10.1002/bip.360250509. |

[12] | S. Lespinats and M. Aupetit, “False Neighbourhoods and Tears are the Main Mapping Defaults. How to Avoid It? How to Exhibit Remaining Ones?,” QIMIE/PAKDD 2009 (PAKDD Workshops, Thailand), Bangkok, 2009 pp. 55–64.conferences.telecom-bretagne.eu/data/qimie09/lespinats_aupetit_QIMIE _ 2009.pdf. |

[13] | J. W. Sammon, “A Nonlinear Mapping for Data Structure Analysis,” IEEE Transactions on Computers, C-18(5), 1969 pp. 401–409. doi:10.1109/T-C .1969.222678. |

[14] | L. Chen and A. Buja, “Stress Functions for Nonlinear Dimension Reduction, Proximity Analysis, and Graph Drawing,” Journal of Machine Learning Research, 14(1), 2013pp. 1145–1173. dl.acm.org/citation.cfm?id=2502616. |

[15] | J. C. Gower, “A Comparison of Some Methods of Cluster Analysis,” Biometrics, 23(4), 1967 pp. 623–637. doi:10.2307/2528417. |

[16] | J. Shiens, “A Tutorial on Principal Component Analysis.” arxiv.org/pdf/1404.1100.pdf. |

M. S. Zand, J. Wang, and S. Hilchey, “Graphical Representation of Proximity Measures for Multidimensional Data,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-7. |

Martin S. Zand is a professor of medicine and director of the Rochester Center for Health Informatics at the University of Rochester. His research includes the application of informatics, graph theory, and computational modeling to vaccine immunology, gene regulatory networks, and health care delivery.

Jiong Wang is a molecular virologist and research assistant professor at the University of Rochester. She works on influenza vaccination responses and developing high-dimensional measurements of vaccine immune responses.

Shannon Hilchey is a cellular immunologist and research associate professor at the University of Rochester. He studies human immune responses to vaccination, hematologic cancers, and organ transplants in human subjects.

**Martin S. Zand, MD, PhD**

University of Rochester Medical Center

601 Elmwood Avenue – Box 675

Rochester, NY 14618

*martin_zand@urmc.rochester.edu*

**Jiong Wang, PhD**

University of Rochester Medical Center

601 Elmwood Avenue – Box 675

Rochester, NY 14618

*jiong_wang@urmc.rochester.edu*

**Shannon Hilchey, PhD**

University of Rochester Medical Center

601 Elmwood Avenue – Box 675

Rochester, NY 14618

*shannon_hilchey@urmc.rochester.edu*

We propose and implement an algorithm to compute the exact cumulative density function (CDF) of the distance from an arbitrary reference point to a randomly located node within an arbitrarily shaped (convex or concave) simple polygon. Using this result, we also obtain the closed-form probability density function (PDF) of the Euclidean distance between an arbitrary reference point and its neighbor node when nodes are uniformly and independently distributed inside the arbitrarily shaped polygon. The implementation is based on the recursive approach proposed by Ahmadi and Pan [1] in order to obtain the distance distributions associated with arbitrary triangles. The algorithm in [1] is extended for arbitrarily shaped polygons by using a modified form of the shoelace formula. This modification allows tractable computation of the overlap area between a disk of radius centered at the arbitrary reference point and the arbitrarily shaped polygon, which is a key part of the implementation. The obtained distance distributions can be used in the modeling of wireless networks, especially in the context of emerging ultra-dense small cell deployment scenarios, where network regions can be arbitrarily shaped. They can also be applied in other branches of science, such as forestry, mathematics, operations research, and material sciences.

Wireless networks are generally modeled as a finite region in Euclidean space (this article considers those regions that are simple polygons in two-dimensional Euclidean space ) with nodes independently and uniformly distributed throughout the region. The random distances between nodes or users, therefore, significantly affect the modeling of the wireless network, since the received signal power and interference depend critically on the distances between the transmitter and the receiver nodes [2]. As shown recently in [3], when nodes are independently and uniformly distributed within the network, the important distance distribution is the cumulative density function (CDF) of the distance from an arbitrary reference point to a randomly located node within the polygon (in this article, we use the phrase *distance distribution* to denote this CDF distribution). It can be obtained by finding the ratio of the overlap area between a disk of radius centered at the arbitrary reference point and the area of the polygon. This CDF can then be used to obtain the probability density function (PDF) of the Euclidean distance between an arbitrary reference point and its neighbor node when nodes are uniformly and independently distributed inside the polygon.

Recently, there has been increasing interest in wireless communications to model the distance distributions in polygonal regions. In traditional cellular networks, the network region is often modeled as an equilateral triangle, a square, a hexagon, or a disk. For regular -sided polygons, the distance distributions were obtained for the special case when the arbitrary reference point is located at the center of the polygon in [4] and for the general case when the arbitrary reference point is located anywhere inside the polygon in [3]. Note that a *Mathematica* implementation of the algorithm in [4] is available [5]. In emerging wireless network paradigms, such as ultra-dense small cell deployments, the network regions can be arbitrarily shaped. For arbitrarily shaped convex polygons, when the arbitrary reference point is located anywhere inside the polygon, an algorithm to obtain the distance distributions was proposed in [6]. For triangular regions, when the arbitrary reference point is located anywhere, an algorithm to obtain the distance distributions was proposed in [1]. The authors in [1] argued that since any polygon can be triangulated (i.e., broken up into non-overlapping triangles), their approach in principle could be applied to determine the distance distributions for the general case of arbitrary reference point location and arbitrarily shaped (convex or concave) polygons.

In this article, we extend the algorithm in [1] for arbitrarily shaped polygons by using a modified form of the shoelace formula. The shoelace formula, also known as Gauss’s area formula, is a well-known mathematical method to determine the area of a polygon whose vertices are described by ordered pairs in [7]. Our modification of the shoelace formula allows tractable computation of the overlap area between a disk of radius centered at the arbitrary reference point and the arbitrarily shaped polygon, allowing the algorithm in [1] to be generalized and implemented.

This article is organized as follows. In the remainder of Section 1, we briefly summarize the algorithm in [1] and define the commonly used notation. In Section 2, we discuss the shoelace formula and its proposed modification. In Section 3, we present the proposed algorithm and its *Mathematica* implementation. The simulation results, which are used to verify the analytical results, are discussed in Section 4. An example illustrating the proposed *Mathematica* implementation is discussed in Section 5. Finally, conclusions are presented in Section 6.

Calculating the distance distribution (i.e. the CDF) evaluated at is equivalent to finding the ratio of the area within the polygon that is less than a distance from the reference point to the area of the polygon. The latter area is readily calculated if the polygon vertices are known. (Generally the polygon defining the network area has known coordinates, so the area may be calculated.) Hence, the challenge is calculating the former area.

It is clear that the CDF has an obvious geometric interpretation; if we let be a polygon and be the disc of radius centered at some reference point , then the CDF is the area of divided by the area of the polygon. Ahmadi and Pan [1] perform this calculation for an arbitrary triangle and arbitrary reference point by first establishing the case for which the reference point is one of the triangle vertices, as illustrated in Figure 1.

**Figure 1.** Depiction of the two characteristic cases considered by Ahmadi and Pan [1]. (a) shows the case that the altitude from to the side is inside the triangle. (b) shows the case that the altitude from to the side is outside the triangle.

They assume, without loss of generality, that the side length of is less than or equal to the side length of . The possible cases are then characterized by whether the altitude from to the side is inside or outside the triangle, and considered separately (see Figure 1). For a disc centered at , the area of intersection of the triangle and the disc as a function of the radius is derived for each case. The result for the former case is

(1) |

and for the latter case the result is

(2) |

All the symbols in (1) and (2) are defined in Figure 1. The equations (1) and (2) are extended to an arbitrary triangle with an arbitrary reference point using triangle decomposition and adding and subtracting the areas appropriately [1]. The three possible cases are that the reference point is inside the triangle, the reference point is outside the triangle and in the area formed by the extension of two edges from a vertex, or otherwise (see Figure 2). For these three cases, the area is given by

respectively, where the individual intersection areas can be found using (1) and (2) appropriately.

**Figure 2.** Possible cases for triangle decompositions given an arbitrary triangle and reference point. (a) is the case of an interior reference point. (b) and (c) show the case for an exterior reference point. (c) is the case that the reference point is in the area formed by the extension of the edges from one vertex.

Using this result, an algorithm to compute the CDF for the general case of an arbitrary polygon and arbitrary reference point is proposed and implemented. This is achieved by first establishing a modification of the shoelace formula, which is described and proved in Section 2.

In this subsection, we define some functions and notation that are used throughout this article.

**Definition 1**

The area of a region is denoted by . In the case of a triangle with vertices , the area can be calculated as in [8].

(3) |

**Definition 2**

(4) |

(The subscript stands for “signed”.) We note that from the above definition, has the same magnitude as the area of the triangle, , but is positive if the vertices are given in counterclockwise order, and negative if the vertices are given in clockwise order.

**Definition 3**

The signed area of the region defined by the intersection of a triangle and a region , that is, , is denoted and is given by

(5) |

Essentially, this says that , where is positive if the signed area of is positive and negative if the signed area of is negative.

The shoelace formula is a useful formula for calculating the area of a polygon (see the illustration in [6] for an explanation of the name). It is stated in the theorem below [9].

**Theorem 1**

The shoelace formula: Let be an ordered set of vertices in the plane that define an -sided polygon. Define the triangles as the triangles formed from two adjacent points from and the origin. That is,

(6) |

The shoelace formula holds if instead of using the origin to define each , we used an arbitrary point in .

Notice that

Hence, the shoelace formula can alternatively be stated as

(7) |

A visual illustration of (7) is shown in Figure 3. The triangles with positively signed area are shaded in green and shown in (a), and the triangles with negatively signed area are shaded in orange and shown in (b). In both cases, the darker regions indicate where triangles overlap. We can thus think of the shoelace formula as stating that if we add the green regions and subtract the orange regions, we obtain the region defined by the polygon (shown in (c)). In the given example in Figure 3 we can see this visually because the green regions outside the polygon “cancel” with the orange regions outside the polygon, and the dark green regions inside the polygon are “canceled” by orange regions inside the polygon.

**Figure 3. **Visual illustration of the shoelace formula for calculating the area of a polygon.

We now build upon the shoelace formula in (7) to obtain a useful modification.

**Theorem 2**

The modified shoelace formula: Let be an ordered set of vertices in the plane that define an -sided polygon. Let be a disc of radius centered at the point . Define the triangles as the triangles formed from two adjacent points from and the reference point . That is,

(8) |

Thus, just as the area of the polygon was equal to the sum of the signed areas of the triangles in the original shoelace formula, we have that the area of intersection of the polygon and a disc is given by the sum of the signed areas of intersection of each and the disc in the modified shoelace formula. A visual illustration of this modified formula is shown in Figure 4. If we consider the same example as in Figure 3 but with the addition of a disc, as depicted in Figure 4, then the orange regions (areas with negative signed area, shown in (b)) “cancel” the green regions (areas with positive signed area, shown in (a)) that are outside the polygon and “cancel” the darker regions inside the polygon, giving the desired area of intersection, shown in (c). We prove theorem 2 using induction.

**Figure 4. **Visual illustration of the modified shoelace formula for calculating overlap areas.

**Proof of Theorem 2**

We use strong induction on (the number of sides of the polygon). The base case is immediate, as Ahmadi and Pan [1] show exhaustively in their paper. We now assume that the result is true for all for some , and let be an arbitrary -sided polygon. We may choose two vertices , of the polygon such that the straight line joining and is contained within the polygon (for a proof of this fact, see [10]).

To complete the induction step, let and pick any diagonal contained within , where appears before in the list. Then let , where and are the two polygons formed by adding the diagonal. We can thus write and . These two polygons correspond to (a) and (b), respectively, in the example given in Figure 5.

**Figure 5.** Example polygon decomposition given the diagonal . The arrows denote the order of the vertices.

Since both and have at most sides (say and sides, respectively), then for any and any , we know that for the disc of radius centered on (denoted ), we have

where and are the triangles defined in the same way as in the statement of the theorem for the polygons and , respectively. From their construction, the vertices in and are either both in clockwise order, or both in counterclockwise order. So and are either both positive or both negative. Hence

(9) |

Using (7) we deduce that

But all of the triangles are precisely the analogous triangles for the polygon , and also include the triangles added by the diagonal, namely and . Thus

In this section, we extend the algorithm in [1] for arbitrarily shaped polygons by using the modified form of the shoelace formula in theorem 2. Since any polygon can be triangulated, the area of intersection of a disc of radius centered at a reference point and the polygon can be found by summing the areas of the intersections of the disc and each triangle of the triangulation. Since the latter areas can be found using theorem 2, the generalization follows.

We know that given a polygon and a reference point , the CDF is

(10) |

Using the modified shoelace formula, we may write (10) as

(11) |

where and

In (11), we can calculate using the shoelace formula in theorem 1. The method to calculate each was given in [1] and is summarized in Section 1.1. Once the CDF is found, the corresponding PDF can be found by differentiation.

In this section, we describe the implementation of the algorithm. The functions in (1) and (2) are implemented as the functions `InsideAltitudeArea` and `OutsideAltitudeArea`, respectively. These functions return the piecewise functions (1) and (2) as a function of the argument . Each function returns a list of sublists; here each sublist is of the form , where is the piece of the function that corresponds to the range . The function (1) has four pieces and so `InsideAltitudeArea` returns a array. Similarly, `OutsideAltitudeArea` returns a array, as it corresponds to (2), which has three pieces.

The function `PolygonArea`, given the vertices, calculates the area of a polygon with the shoelace formula.

`CombinePieces` is responsible for simplifying a “pseudo-piecewise” function by determining the distinct ranges of the equivalent piecewise function, sorting these ranges, and finding the corresponding function for each range. This piecewise function is then converted to either the CDF or the PDF, depending on the argument `case`. The function takes four arguments: is a “pseudo-piecewise” function of the form that is returned by `InsideAltitudeArea` and `OutsideAltitudeArea`, namely, a list of sublists, where each sublist is of the form where is the piece of the function that corresponds to the range . The argument `area` is set equal to the area of the polygon. The returned CDF is a function of the argument . Finally, `case` is a Boolean argument that determines whether the CDF or PDF is returned; when it is true the function returns the CDF, and when it is false the function returns the PDF.

This gives the sign of a triangle’s area.

`AltitudeInsideQ` returns `True` if the altitude of the triangle intersects the opposite edge inside the triangle.

`PolygonCDF` is the main function used to compute the CDF; it uses the method outlined in Subsection 3.1.

This section discusses how to generate the simulation results, which are used to verify the analytical results. In general, we need uniformly distributed points inside arbitrarily shaped polygons.

Generating uniformly distributed points inside a triangle is straightforward and can be accomplished in a number of ways [11, 12]. The method used here selects two numbers at random from to measure off lengths on two sides of the triangle to use as weights on the vertices. `RandomPointsTriangle` has two arguments: `T` is a list of three vertices describing a triangle and `n` is the number of points to generate.

The method for triangles is extended to arbitrary polygons by triangulating the polygon , uniformly picking a triangle, and then generating a point in that triangle. Uniformly picking a triangle means choosing each triangle with probability such that the points generated are uniform for the whole polygon; this means that the probability of picking a triangle must be proportional to its area. Precisely, the probability is . This is done efficiently using `TriangulateMesh`.

For convenience, here is a list of the different special examples that have been considered in the literature that can be verified using our implementation. The polygon vertices must be specified in clockwise order.

**1.** Example 1 in [1]: equilateral triangle with interior reference point

**2.** Example 2 in [1]: equilateral triangle with exterior reference point.

**3.** Section 2.5.1, p. 263 in [13]: triangle with reference point at a vertex.

**4.** Example in [3]: square with reference point on the boundary.

**5.** Example in [4]: hexagon with reference point at the center.

**6.** Example in [6], [14], and [15]: arbitrarily shaped convex polygon.

**7.** Example in [18]: arbitrarily shaped convex polygon.

**8.** Example in this report: arbitrarily shaped polygon shaped like the letter N.

**9.** Example in this report: star-shaped (concave) polygon region with reference point at the center.

**10.** Example in this report: arbitrarily shaped concave polygon with exterior reference point.

We illustrate using Example 10.

The simulation data is calculated. The code checks to see if the polygon is convex. If it is, the points are simulated using `RandomPointsConcave`, which is faster than `RandomPointsPolygon`. Otherwise, the code uses `RandomPointsPolygon`.

This shows the simulated uniformly distributed points for the given polygon.

A function that converts the simulated points to the CDF is defined. The number of simulation trials

is .

The closed form of the CDF is displayed as calculated by the algorithm.

Also find the corresponding closed form of the PDF, which is needed for the neighbor PDF.

The analytical result for the CDF (red) is compared with the result obtained from simulations (blue).

Using the CDF, the PDF of the Euclidean distance between an arbitrary reference point and its neighbor node can be found.

Define the neighbor PDF: equation (12) in [4].

The result can be plotted as follows.

In this article, we have reported on the use of *Mathematica* for distance distribution modeling in wireless networks. We have proposed and implemented an algorithm to compute the exact cumulative density function (CDF) of the distance from an arbitrary reference point to a randomly located node within an arbitrarily shaped (convex or concave) polygon. Examples of how the obtained distance distributions can be used in the modeling of finite-area wireless networks are provided in [6], [15–19]. The distance distribution results can also be applied in other branches of science, such as forestry, mathematics, operations research, and material sciences [13], [20].

We would like to thank the anonymous reviewer for his comments, especially for suggesting an efficient method of uniformly distributing points in a triangle. We would also like to thank Ms. Maryam Ahmadi (University of Victoria, Canada) and Prof. Jianping Pan (University of Victoria, Canada) for their constructive feedback, which helped us to further improve the implementation.

[1] | M. Ahmadi and J. Pan, “Random Distances Associated with Arbitrary Triangles: A Recursive Approach with an Arbitrary Reference Point,” UVic-PanLab-TR-14-01, 2014. dspace.library.uvic.ca//handle/1828/5134. |

[2] | J. G. Andrews, R. K. Ganti, M. Haenggi, N. Jindal, and S. Weber, “A Primer on Spatial Modeling and Analysis in Wireless Networks,” IEEE Communications Magazine, 48(11), 2010 pp. 156–163. doi:10.1109/MCOM.2010.5621983. |

[3] | Z. Khalid and S. Durrani, “Distance Distributions in Regular Polygons,” IEEE Transactions on Vehicular Technology, 62(5), 2013 pp. 2363–2368. doi:10.1109/TVT.2013.2241092. |

[4] | S. Srinivasa and M. Haenggi, “Distance Distributions in Finite Uniformly Random Networks: Theory and Applications,” IEEE Transactions on Vehicular Technology, 59(2), 2010pp. 940–949. doi:10.1109/TVT.2009.2035044. |

[5] | S. Durrani, J. Guo, and Z. Khalid, “Mathematica and Matlab Software for Computing Distance Distributions,” (May 12, 2015). users.cecs.anu.edu.au/~Salman.Durrani/software.html. |

[6] | J. Guo, S. Durrani, and X. Zhou, “Outage Probability in Arbitrarily-Shaped Finite Wireless Networks,” IEEE Transactions on Communications, 62(2), 2014 pp. 699–712. doi:10.1109/TCOMM.2013.122913.130298. |

[7] | Wikipedia. “Shoelace Formula.” (Jun 18, 2015) en.wikipedia.org/wiki/Shoelace_formula. |

[8] | E. W. Weisstein. “Triangle Area” from Wolfram MathWorld—A Wolfram Web Resource. mathworld.wolfram.com/TriangleArea.html. |

[9] | E. W. Weisstein. “Polygon Area” from Wolfram MathWorld—A Wolfram Web Resource. mathworld.wolfram.com/PolygonArea.html. |

[10] | J. O’Rourke, Art Gallery Theorems and Algorithms, New York: Oxford University Press, 1987. |

[11] | E. W. Weisstein. “Triangle Point Picking” from Wolfram MathWorld—A Wolfram Web Resource. mathworld.wolfram.com/TrianglePointPicking.html. |

[12] | G. Turk, “Generating Random Points in Triangles,” in Graphics Gems (A. S. Glassner, ed.), Boston: Academic Press, 1990 pp. 24–28. inis.jinr.ru/sl/vol1/CMC/Graphics_Gems_1,ed_A.Glassner.pdf. |

[13] | A. M. Mathai, An Introduction to Geometrical Probability: Distributional Aspects with Applications, Amsterdam: Gordon and Breach Science Publishers, 1999. |

[14] | J. Guo, S. Durrani, and X. Zhou, “Performance Analysis of Arbitrarily-Shaped Underlay Cognitive Networks: Effect of Secondary User Activity Protocols,” IEEE Transactions on Communications, 63(2), 2015 pp. 376–389. doi:10.1109/TCOMM.2014.2385065. |

[15] | J. Guo, S. Durrani, and X. Zhou, “Characterization of Aggregate Interference in Arbitrarily-Shaped Underlay Cognitive Networks,” Proceedings of IEEE Global Communications Conference (GLOBECOM), Austin, TX: IEEE, 2014. pp. 961–966. doi:10.1109/GLOCOM.2014.7036933. |

[16] | M. C. Valenti, D. Torrieri, and S. Talarico, “A Direct Approach to Computing Spatially Averaged Outage Probability,” IEEE Communications Letters, 18(7), 2014 pp. 1103–1106. doi:10.1109/LCOMM.2014.2317740. |

[17] | Z. Khalid, S. Durrani, and J. Guo, “A Tractable Framework for Exact Probability of Node Isolation and Minimum Node Degree Distribution in Finite Multi-hop Networks,” IEEE Transactions on Vehicular Technology, 63(6), 2014 pp. 2836–2847. doi:10.1109/TVT.2013.2293580. |

[18] | K. B. Baltzis, “Distance Distribution in Convex -Gons: Mathematical Framework and Wireless Networking Applications,” Wireless Personal Communications, 71(2), 2012pp. 1487–1503. doi:10.1007/s11277-012-0887-9. |

[19] | D. Moltchanov, “Distance Distribution in Random Networks,” Ad Hoc Networks, 10(6), 2012 pp. 1146–1166. doi:10.1016/j.adhoc.2012.02.005. |

[20] | U. Basel, “Random Chords and Point Distances in Regular Polygons,” Acta Mathematica Universitatis Comenianae, LXXXIII(1), 2014 pp. 1–18.www.emis.de/journals/AMUC/_vol-83/_no_1/_baesel/baesel.html. |

R. Pure and S. Durrani, “Computing Exact Closed-Form Distance Distributions in Arbitrarily Shaped Polygons with Arbitrary Reference Point,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-6. |

Ross Pure is a second-year Bachelor of Engineering (Research & Development)/Bachelor of Science student in the Research School of Engineering, the Australian National University (ANU), Canberra, Australia.

Salman Durrani (SMIEEE, SFHEA, MIEAust) is a Senior Lecturer in the Research School of Engineering, ANU. He has coauthored more than 80 publications to date in refereed international journals and conferences. He currently serves as an editor of *IEEE Transactions on Communications*. His research interests include wireless and mobile communications, wireless energy harvesting, and synchronization and signal processing on the unit sphere.

**Ross Pure**

*Research School of Engineering
The Australian National University
Canberra, Australia*

**Salman Durrani**

*Research School of Engineering
The Australian National University
Canberra, Australia*

This article presents new symbolic solutions for the problem of pore elasticity and pore pressure. These techniques are based on the classic theoretical approach proposed by M. A. Biot [1]. The new symbolic solutions differ from the well-known approximations of the functions proposed for the 2D pore elasticity problem. Both new symbolic and numerical solutions are then applied to solve problems arising in offshore design technology, specifically dealing with the penetration of a gravity-based rig installed in the Arctic region of the North Sea of Russia. All symbolic approaches are based on solutions of the linear problem of the pore elasticity for homogeneous soil. The new symbolic solutions are compared with Biot’s solutions.

The main purpose of this article is to derive new symbolic solutions for the classic problem of pore elasticity set up in [1]. Approximate solutions proposed by Biot have been widely used to solve various linear initial-boundary problems involving pore elasticity. But more accurate solutions of the problem are still of interest.

In offshore technology, a practical example deals with the penetration of huge oil rigs into the soil of the sea bed. Such cases are usually based on solutions given by the linear theory of pore elasticity.

First, consider Biot’s problem for a rectangular load on homogeneous soil [1].

In the three-dimensional case, the depth of penetration of a rigid body into soil may be found by solving the equations

(1) |

where , , are the components of the displacements of the saturated soil in the , , directions and

(2) |

is the divergence of the displacements of the soil. The initial and boundary conditions will be given later.

The other variables are:

- , the pore pressure
- , the shear modulus of the rigid skeleton of the saturated soil
- , the Poisson coefficient of the rigid skeleton of the soil
- , the coefficient of consolidation
- , the coefficient of permeability
- , the final compressibility

As usual, define the Laplace operator:

(3) |

Consider an infinite half-space (e.g. clay) bounded by the horizontal - plane, and let the axis be directed vertically downward.

The vertical deflection of the horizontal plane is to be found when a vertical load acts on the rectangular plane at time ; the rectangular load is distributed in the strip on the surface.

Assume that water saturates the clay and may be freely filtered by the neighboring half-area, and that the water pressure on the - surface equals atmospheric pressure.

Then the original problem becomes two dimensional, with . The equations in (1) become

(4) |

Taking the Laplace transform and noting that changes the third equation, giving the system

(5) |

where is a Laplace-transformed parameter.

The boundary conditions for the 2D case (reduced for the full symmetric geometry of the body) of the pore elasticity are:

1. The displacements and pore pressure are 0 as :

(6) |

2. The pore pressure at the surface is

(7) |

3. The skeleton stress at the surface is equal to the external load given by

(8) |

4. The shear stress at the surface is 0:

(9) |

First, clear any old values of and .

Define three operators and three equations.

Consider general solutions of the system of equations (5) in the form of functions with separated variables.

Then (5) is transformed into the following system of ODEs.

(10) |

This determines the general solutions of (10).

This allows us to define the three previously unknown functions.

New forms of the symbolic solutions are presented in section 3.3.

The symbolic solutions derived in section 3.2 may be combined in the function .

(11) |

To satisfy the boundary condition (6), the coefficients and in (11) must be zero.

Here is a linear system for the unknown coefficients in .

This finds solutions for three of the coefficients.

We can express the functions in a different form using .

The other three unknown constants are found from the boundary conditions (7), (8), and (9). These conditions lead to three linear equations.

Finally, here is the system of linear equations.

It leads to the general solutions for all the coefficients of the problem of pore elasticity.

Following [1], we introduce a transformed solution for the vertical deflection of the plane.

This gives the time dependence of the vertical displacement of the saturated soil.

This is the formula for the initial distribution at the surface.

Based on [1], here is the general vertical deflection for the horizontal level of the soil.

Finally, a new symbolic solution for a rectangular load acting on the plane (with zero Poisson coefficient) is derived by integrating.

The result is a new symbolic form for problem [1].

(12) |

Originally in [1] the approximate symbolic solution was given by:

(13) |

This is the new function for practical solutions based on the exact solution derived above.

Here is the displacement of the horizontal level of the porous space under a rectangular load.

Let us consider an application of the new symbolic solution of the pore elasticity problem obtained above to the study of the penetration of the gravity rig into the sea bed. The platform Prirazlomnaya has a mass of 250,000 tons and its bottom measures (see [2]). We also define the parameters of the clay soil and sediment.

This is the average pressure of the rig on the surface of the sediment.

(14) |

Here is a plot of the rectangular load.

This plots the family of vertical displacements of the rig penetrated into clay and sediment.

For a complex load acting on the rig, the general penetration is the sum of each of the component penetrations.

(15) |

where and are the sizes of the mechanical components and living quarters of the platform.

Here is a plot of the loads on the platform from the housing and mechanical blocks.

Let the production unit have length 30 meters and suppose the distributed load is .

This shows the penetration of the platform on the sediment due to the production unit over a two-week period.

This shows the penetration of the platform, taking into account the nonuniform load distribution on the sediment, where is the side length of the square of the bottom of the rig in (15).

**Figure 1.** Here is a photo of the rig Prirazlomnaya.

Since [1] does not take account of porous pressure, here is a new symbolic solution for this case, substituting 0 for .

Following [1], here is an approximate symbolic solution for the pressure.

The explicit form of the pore pressure function is computed by taking the inverse Laplace transform.

So this is a new symbolic solution for the porous pressure for a rectangular load at the surface.

This section shows how the pore pressure changes with time and depth of the soil layer near the horizon.

This determines the distribution function of pore pressure 1.5 meters below the bottom of the gravity platform.

This shows the family of porous pressure distributions at the bottom of the gravity platform.

Obviously, the pore pressure is the load-bearing frame factor, which restrains the platform to the surface of the ground.

In this article, new symbolic solutions for the penetration of a gravity platform into soil and a determination of the porous pressure in the saturated soil are found by computer algebra techniques. These solutions improve upon earlier solutions obtained by M. Biot and give us new possibilities to apply symbolic computer applications to diverse problems in pore elasticity theory.

Both symbolic solutions are applicable to the design of offshore gravity structures installed in shallow water.

[1] | M. A. Biot, “General Theory of Three-Dimensional Consolidation,” Journal of Applied Physics, 12(2), 1941 pp. 155–164. doi:10.1063/1.1712886. |

[2] | Wikipedia. “Prirazlomnoye Field.” (Jan 12, 2015) en.wikipedia.org/wiki/Prirazlomnoye_field. |

A. N. Papusha and D. P. Gontarev, “New Symbolic Solutions of Biot’s 2D Pore Elasticity Problem,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-5. |

Professor Alexander N. Papusha is the head of the Continuum Mechanics and Offshore Exploration Department at Murmansk State Technical University (MSTU). He received an M.S. in mechanics from Kiev State University in 1972 and a Ph.D. in theoretical mechanics in 1979 from the Institute of Mechanics, Ukrainian Academy of Sciences, as well as a Doctor of Sciences from the Institute of Machinery (St. Petersburg), Russian Academy of Sciences in 1999. Since 1983, he has been a full professor at MSTU.

Denis P. Gontarev is a postgraduate student in the Continuum Mechanics and Offshore Exploration Department at MSTU.

**Alexander N. Papusha**

*Continuum Mechanics and Offshore Exploration Department
Murmansk State Technical University
13, Sportyvnay
183010 Murmansk, Russia
*

**Denis P. Gontarev**

*Continuum Mechanics and Offshore Exploration Department
Murmansk State Technical University
13, Sportyvnay
183010 Murmansk, Russia
*

This article is divided into five sections: the orbit transfer problem, equations of motion, the optimal control problem, necessary conditions for the Mayer problem, and a dynamic approach to the maximal orbit transfer problem using *Mathematica*’s built-in `Manipulate` function.

The Earth-Mars orbit transfer problem is timely, given the successful flight and smooth landing of the American *Curiosity* rover on Mars.

For the orbit transfer problem, assume that:

- There is a unique center of attraction.
- Initially the spacecraft moves in a circular trajectory around the center of attraction.
- The spacecraft moves with a constant thrust from a rocket engine operating in the time interval .
- The spacecraft moves to the largest possible circular orbit around the center of attraction.
- The orbit transfer trajectory is coplanar with the two circular orbits and the center of attraction.

All these assumptions are stated in [1, p. 66]. Here is a sketch of a solution to the problem with some notation. The blue curve is the orbital transfer trajectory, while the red and green curves are the initial lower circular orbit and the final upper circular orbit.

The notation from [1, pp. 66–68], [2], or [3] is:

- is time in the given interval , which is called the horizon.
- is the radial distance from the center of attraction to the spacecraft; increases as fuel is burned; is the initial distance; is the final and maximal distance.
- is the polar angle, measured counterclockwise from the straight line connecting the center of attraction with the position of the spacecraft at .
- is the radial velocity component.
- is the tangential velocity component.
- is the thrust-direction angle; it is the control variable.
- is the initial mass of the spacecraft with propellant included; is the time-dependent mass, which decreases due to the constant fuel consumption rate .
- is the thrust, also assumed to be constant.
- is the gravitational constant.

The equations of motion of the spacecraft consistent with the above assumptions, according to [1,

p. 67] and [2], are

(1) |

(2) |

(3) |

(4) |

The associated boundary conditions are

(5) |

(6) |

(7) |

(8) |

(9) |

(10) |

The system of nonlinear differential equations (1) to (4) with the boundary value conditions (5) to (10), the control function , and the maximizing condition

(11) |

form the optimal control problem to be solved, assuming that the state functions , , , and and the control function are sufficiently smooth. Conditions (6), (7), (9), and (10) guarantee that the trajectory of the spacecraft is tangent to the two circular orbits.

The goal is to maximize , the radius of the orbit transfer at the endpoint in time, so the cost functional is determined by

(12) |

Thus the horizon is with . This is a Mayer optimal control problem (see Ch. 4 in [4]).

Since the differential equations (1) to (4) with conditions (5) to (10) and the cost functional (12) are not time dependent, the optimal control problem is equivalent to either of the following two problems:

- differential equations (1) to (4) with conditions (5) to (10), a given , and finite and arbitrary, with optimality condition to minimize
- differential equations (1) to (4) with conditions (5) to (10), a given , with the optimality condition to minimize the fuel consumption

**Theorem 1**

Under the hypotheses of Filippov’s theorem (theorem 9.2.i of [4]), the optimal control problem (1) to (4) with conditions (5) to (10) and the maximizing functional (11) and (12) has an absolute maximum in the nonempty set of admissible pairs.

For brevity, here is an abbreviated version of theorem 4.2.i in [4]: Let the Mayer problem be expressed as

(13) |

(14) |

A pair , , is said to be *admissible* (or *feasible)* provided that is absolutely continuous [5], is measurable, and and satisfy (14) a.e. Let be the class of admissible pairs . The goal is to find the minimum of the cost functional (13) over , that is, to find an element so that for all . Introduce the variables , called *multipliers*, and an auxiliary function , called the *Hamiltonian*, defined on by

(15) |

Define

Further necessary assumptions:

- There exists an element such that for all .
- is closed in .
- The set is closed in .
- .
- Notation:
- The graph of the optimal trajectory belongs to the interior of .
- does not depend on time and is a closed set.
- The endpoint of the optimal trajectory is a point of , where has a tangent variety (of some dimension , ) whose vectors are denoted by

**Theorem 2**

Assume the above eight hypotheses and let be an optimal pair for the Mayer problem (13) and (14). Then the optimal pair necessarily has the following properties:

(b) For almost any fixed (a.e.), the Hamiltonian, as a function depending only on , takes its minimum value in at the optimal strategy . This implies , (a.e).

(16) |

for every vector .

From (15) and (a) of theorem 2, the Hamiltonian and the equations for the multipliers for (1) to (4) are

(17) |

(18) |

(19) |

(20) |

(21) |

From (21) and (18), and thus (17) to (20) become

(22) |

(23) |

(24) |

Furthermore, from (b) in theorem 2,

Thus the control function is determined by the multipliers and

Based on (4), note that the polar angle is determined by and .

From the transversality relation (d) in theorem 2 (i.e. equation (16)),

(25) |

This yields a system of six nonlinear differential equations (1), (2), (3), (22), (23), and (24) in the variables , , , , , and with six bilocal conditions (5), (6), (7), (9), (10), and (25).

As mentioned earlier, the variables and follow.

The next section implements a dynamical approach to the maximal orbit transfer problem.

The function `MaximalRadiusOrbitTransfer` dynamically shows the maximal radius orbit transfer between two coplanar circular orbits so that their centers are located at a single center of attraction. Here `thrust` is the constant thrust of the engine, `dmr` is the decreasing mass rate due to the constant propellant flow rate, `b` is the final time, `m0` is the initial mass of the spacecraft including the propellant, `μ` is the gravitational constant, `r0` is the initial radius, `u0` is the initial radial velocity, `ub` is the final radial velocity, `v0` is the initial tangential velocity, and `k` is the number of thrust vectors.

Clearly the problem is nonlinear and, to the author’s knowledge, no closed-form solution has been found. The possibility of obtaining a solution through a numerical method remains, as implied by theorem 1. The accuracy of the results depends sensitively on the initial values. The `Method` option is needed for *Mathematica* 9 or lower; for faster processing, remove it in *Mathematica* 10 or higher.

A similar picture can be found on the front cover and on pages 1–2 of [6].

The author expresses his deep gratitude to Prof. Dr., Dr. H. C., Heiner H. Gonska of the University of Duisburg-Essen, Faculty of Mathematics, located in Duisburg, Germany, for his kind invitation and warm hospitality. The invitation was funded by a grant from the Center of Excellence for Applications of Mathematics supported by DAAD. The author also thanks Aida Viziru for her rapid and professional help.

[1] | A. E. Bryson and Y.-C. Ho, Applied Optimal Control: Optimization, Estimation, and Control, New York: Halsted Press, 1975. |

[2] | S. Alfano and J. D. Thorne, Constant-Thrust Orbit-Raising Transfer Charts, Report PL-TR-93-1010, July 1993. www.dtic.mil/dtic/tr/fulltext/u2/a269088.pdf. |

[3] | S. Alfano and J. D. Thorne, “Circle-to-Circle Constant-Thrust Orbit Raising,” The Journal of the Astronautical Sciences, 42(1), 1994 pp. 35–45. www.centerforspace.com/downloads/files/pubs/JAS.V42.N01.pdf. |

[4] | L. Cesari, Optimization—Theory and Applications, Problems with Ordinary Differential Equations, Applications of Mathematics, Vol. 17, New York: Springer, 1983. |

[5] | M. Mureşan, A Concrete Approach to Classical Analysis, New York: Springer, 2009. |

[6] | R. Vinter, Optimal Control, Systems & Control: Foundations & Applications, Boston: Birkhäuser, 2000. |

M. Mureşan, “On the Maximal Orbit Transfer Problem,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-4. |

Marian Mureşan is affiliated with Babeş-Bolyai University, Faculty of Mathematics and Computer Science, in Cluj-Napoca, Romania. He is interested in analysis, calculus of variations, optimal control, and nonsmooth analysis.

**Marian ****Mureşan**

*Babe*ş*-Bolyai University
Faculty of Mathematics and Computer Science
1, M. Kog*

Romania

A formal, axiomatic conceptualization of buffering action—generally applicable to any physical, chemical, or biological process—was first presented by B. M. Schmitt in 2005 [1, 2]. This article provides a series of tools designed to aid in the application of these concepts to both classical and non-classical buffering phenomena. To illustrate the utility of the approach in the biological sciences, an abstract measure of the magnitude of “genetic” buffering associated with an allele of the gene encoding the heat shock protein Hsp90 is determined.

Buffering is observed when a parameter changes less than expected in response to a given disturbance. For example, if a strong acid is added to an aqueous solution, and not all of the added ions remain free (unbound), then the solution is said to act as a buffer. While such phenomena have been observed in the physical, chemical, and biological sciences for centuries, a formal and general approach for their quantitation across distinct disciplines was not presented until recently

[1, 2].

In [1, 2], B. M. Schmitt presents a comprehensive mathematical framework for evaluating buffering action—a framework that is applicable to any scenario in which a quantity partitions between two compartments or states. While suitable for the analysis of “classical” buffering phenomena (e.g. acid-base chemistry), the formalism also provides a simple means with which to quantitate and characterize phenomena that, at first glance, seem to be outside the buffering paradigm—at least when the term is used in its traditional sense with respect to the homeostasis of physiological parameters (see [2] for several in-depth examples of the formal and general approach applied to phenomena spanning diverse disciplines).

This article provides a series of mathematical tools designed to facilitate the application of Schmitt’s paradigm to both “classical” and “non-classical” buffering phenomena. By inputting the transfer function and the buffering function , the provided code: (1) defines the four buffering parameters , , , and ; (2) provides a series of graphical outputs describing the system; and (3) calculates the buffering angle , thereby classifying the system as being moderating/amplifying/

inverting/non-inverting. Thus, the burden of computation associated with the approach is seamlessly transferred from the user to the *Mathematica* kernel.

Lastly, in order to illustrate the utility of the approach outside traditional disciplines, I use these same tools to calculate the magnitude of “genetic” buffering associated with an allele of the gene encoding the heat shock protein Hsp90. In this way, the capacity of an allele to buffer phenotypic variation is formally and quantitatively determined for the first time.

To illustrate Schmitt’s “formal and general approach,” consider a system comprised of a pair of communicating vessels (i.e. cylindrical flasks connected by a small tube). As described in [1], the total volume of liquid in the vessels, , is the sum of the two partial volumes contained in each vessel. In the specific example described below, the rightmost of the two cylindrical vessels (the “buffering” vessel) has a radius exactly two times that of the first. Thus, any fluid added to the leftmost vessel (the “transfer” vessel) will partition in a ratio of 1:4 between the transfer and buffering vessels. The partial volume present in the transfer vessel is thus one-fifth the total volume of fluid added to the system. Likewise, the partial volume present in the buffering vessel is four-fifths the total volume of fluid added to the system.

It is possible to formalize the system below by defining three functions: the transfer function , the buffering function , and the sigma function .

The transfer function defines the amount of fluid present in the transfer vessel.

Likewise, the buffering function defines the amount of fluid present in the buffering vessel.

The sigma function defines the sum of the individual functions comprising the system.

Once the functions are defined, it is possible to visualize the system by plotting the lines.

It is also possible to visualize the system (in a more intuitive manner) by creating an area plot in which the two partial volumes are indicated by the heights of the transfer and buffering areas at any given value of .

The definition of the respective functions also provides a convenient means with which to quantitate buffering action. This is accomplished in any one of four ways, using the three available differentials. The buffering coefficient measures the change in the buffering compartment relative to the total change.

The buffering ratio measures the change in the buffering compartment relative to the change in the transfer compartment.

Conversely, the transfer coefficient measures the change in the transfer compartment relative to the total change.

The transfer ratio measures the change in the transfer compartment relative to the buffering compartment.

In this simple linear example—where the cross-sectional area of the buffering vessel is constant (i.e. does not vary with fluid level)—the dimensionless values of total volumes , , , and are invariant, equal to 0.8, 4, 0.20, and .0.25, respectively.

While of great utility, the parameters and are undefined in the case of perfect buffering or perfect transfer, respectively. To address this issue, it is possible to define an alternative measure, the buffering angle , which is capable of representing any type of buffering without the introduction of discontinuities.

As described in [1], the buffering angle can be defined by first creating a three-dimensional space curve of the system.

A projection of this curve onto the - plane corresponds to the transfer function.

A projection onto the - plane corresponds to the buffering function.

A projection onto the - plane, however, generates a third curve that can be used to determine the proportions between the individual changes in the transfer and buffering functions. This is accomplished by simply measuring the angle between the axis and the line formed by joining the origin to any given point on the curve.

This calculates the buffering angle in degrees ([1], Supplement 5).

Similar to the buffering parameters, is invariant in cases of linear buffering.

It is evident from the above analysis that this methodology creates a system in which perfect buffering corresponds to an angle of 90° and perfect transfer to an angle of 0°. In fact, any type of buffering behavior (moderating/amplifying/inverting/non-inverting) can be represented continuously by a finite angle between and 135° ([1], Supplement 7).

Importantly, it is also possible—using the same logic in the reverse direction—to use this single value to unambiguously define all of the buffering parameters describing the system. This can be demonstrated by defining a variable `littleb`1 (corresponding to the buffering coefficient ) that is calculated using only the buffering angle.

This checks that and `littleb` are the same.

Similarly, the values of the remaining three buffering parameters can be calculated using only the buffering angle and shown to be equal to the corresponding parameters calculated using the relevant differentials.

Thus, the buffering angle provides a simple, powerful, single-value measure that is capable of capturing and communicating the underlying nature of the buffering relationships comprising

the system.

While the simple linear scenario described above made it possible to lay the foundation for Schmitt’s “formal and general approach,” the computational effort associated with its application was minimal. Thus, the utility of applying these methods within *Mathematica* was not fully exploited. For this reason, I next consider a more complex, nonlinear example (i.e. where the cross-sectional area of the buffering vessel is not constant). This serves the purpose of highlighting the advantages of exploiting *Mathematica*’s computational engine.

Consider a nonlinear system defined by the functions listed below.

As previously described, the buffering parameters can be determined using the relevant differentials. However, in contrast to the previous example, the computational burden associated with their calculation is no longer trivial (at least in the absence of *Mathematica)*.

Once the functions are defined and the system visualized through the creation of the corresponding line and area plots, one can clearly see that the magnitude of buffering action in this nonlinear scenario varies with fluid level (imagine a buffering vessel in the shape of an hourglass as opposed

to a cylinder).

Furthermore, unlike the linear case, it is also clear that the buffering parameters vary as a function

of .

As previously described, it is also possible to calculate the buffering angle by first creating a three-dimensional space curve of the system and then projecting this curve onto the - plane.

In this instance the buffering angle varies as a function of , with near-perfect buffering being observed at both high and low fluid levels, and minimal buffering being observed when attains a value of approximately 4.38.

As described previously, the buffering parameters can be determined using the buffering angle and are equivalent to the values calculated using the originally defined functions (compare the plots below to the plots for , , , and above).

Thus, just as in the case of a linear system, plotting over the range of the disturbance (i.e. the addition of fluid) provides a simple, single-value measure with which to grasp the inherent buffering properties of the system under consideration.

At this point it is important to note that, up to now, only the overall changes in the buffering and transfer compartments have been considered (by comparing differentials). However, in the case of nonlinear systems, it is also informative to consider the *rate* at which these values change relative to one another (by comparing derivatives). For example, in the same way that it would be important for an investor to be aware of the current price of gold, and how it has changed in previous years, months, or weeks, it would also be important for that same investor to be cognizant of the rate at which the price is changing at any given instant in time (i.e. increasing, decreasing, or stable). This is to say, the choice to sell at a given price at a given moment would be greatly influenced by knowing if the price was stable or on either an upward or a downward trend. In other words, it is not only of interest to know how a quantity *has* *changed*, but how that quantity *is changing*.

To determine the instantaneous rates of change in a buffered system, simply calculate and plot the first derivatives of the functions describing the system.

Once the functions are defined, the instantaneous buffering parameters (denoted by adding an “i” to the respective variable names) can also be calculated.

As is evident from viewing the respective plots of these functions, this analysis allows one to clearly identify the points of maximum and minimum buffering/transfer rate, as well as the points at which the buffering/transfer rates are zero.

In this way, the most critical junctures in the development of the system (over the range of the disturbance) can be quickly and easily identified.

The analysis presented in the previous sections concludes my efforts to establish the theoretical foundation of the formal and general approach, as well as its application within *Mathematica*. Next, in order to illustrate how these abstractions can be directly applied to the real world, I consider an example of non-classical buffering—namely, that of the “genetic buffering” of phenotypic variation.

In this way, the ability to exactly and formally quantitate phenomena that at first glance might be thought of as being outside the buffering paradigm is practically demonstrated.

The axiomatic foundation and abstract nature of the “formal and general approach” allows it to be readily applied to any scenario in which an arbitrary quantity partitions itself between two compartments or states. While suitable for the analysis of “classical” buffering phenomena (the homeostasis of physiological parameters), the approach is also germane to a variety of “non-classical” buffering phenomena. One such phenomenon, which up to now has been considered in only a qualitative manner, is that of “genetic” buffering. While many instances of genetic buffering have been described and characterized, a well-known and classic example of the phenomenon—revolving around the gene encoding the heat shock protein Hsp90—will be used to illustrate the real-world application of Schmitt’s paradigm.

The Hsp90 protein is an ATP-dependent molecular “chaperone” that is extensively expressed in organisms ranging from bacteria to humans. It functions to promote the proper folding of a specific subset of molecular targets referred to as its “client” proteins. Interestingly, many of Hsp90’s client proteins are involved in the process of signal transduction and modulate developmental processes [3]. For example, in the fruit fly, *Drosophila melanogaster*, mutations in the gene encoding Hsp90 result in morphological abnormalities affecting the development of the eye, legs, wings, thorax, and bristles [4].

Interestingly, the proportion of Hsp90 mutant flies exhibiting eye defects (in a line prone to such abnormalities) increases dramatically as the temperature rises. In contrast, the proportion of control flies (expressing the normal or “wild-type” version of the Hsp90 protein) also increases in response to increased temperature, but not nearly to the same degree as in the mutant flies [4]. The gene encoding the wild-type version of the Hsp90 protein is thus said to “buffer” the appearance of the defective eye trait.

It is possible to analyze these experimental results in more detail by importing the raw data (see Figure 8 in [4]) from the original publication in the form of two arrays. These two arrays, corresponding to the wild-type and mutant fly lines, relate temperature to the penetrance of the mutant phenotype (i.e. the percentage of flies in the line displaying the eye defect).

Plotting the data illustrates that the mutant line is indeed more sensitive to increasing temperature than the wild-type line.

To proceed with the application of the formal and general approach, we now create two curves that fit the data using the `FindFit` function.

With the above constants, the curves describing the behavior of the wild-type and mutant lines can be generated.

The appropriateness of the fit can then be inspected by plotting the curves together with the raw data.

With these results in hand, it is now possible to define both the buffering and transfer functions and then to visualize the system using an area plot.

As is evident from inspecting this plot, an increase in temperature translates into only a small increase in the proportion of flies with eye defects in the wild-type line. However, in the mutant line, a much more pronounced increase is observed. We can thus infer that the expression of the wild-type Hsp90 protein buffers the effect of temperature on the penetrance of the eye defect. In other words, since the “transfer” of the eye defect phenotype is greater in the mutant line, the wild-type Hsp90 protein must possess the abstract capacity of diverting or “soaking up” this disturbance (into an equally abstract buffering compartment) so that the “transfer” of the eye defect is diminished. Importantly, using the formal and general approach, we can now provide an exact quantitative measure of the buffering capacity of the wild-type allele by calculating and plotting the four buffering parameters together with the buffering angle (below).

As shown above, the buffering coefficient can be calculated to range from ~0.935 at 18 °C to ~0.822 at 32 °C. While these calculations are now trivial, the critical biological question of how to interpret these calculations is more challenging. As discussed by Schmitt ([1], Supplements 6 and 7), one way to proceed is to consider the conceptual overlap between the formal and general approach and probability theory. In essence, the buffering coefficient is analogous to a probability. In the same way that a probability measures the proportion of a part to a whole (i.e. the number of successful events to the total number of events), so does the buffering coefficient (by measuring the fractional change in the buffering compartment relative to the whole compartment). The critical realization is that both quantities are measured on a relative scale that is normalized to 1. Interpreting the graph in this way, one can say that the “probability” of buffering decreases from ~0.935 to ~0.822 from 18 °C to 32 °C.

Using similar logic, one can say that, in essence, the buffering ratio is analogous to the “odds” of buffering. In the same way that odds measure the proportion between two parts of a whole (by comparing events to non-events), so does (by comparing the fractional change in the buffering compartment to the fractional change in the transfer compartment). Again the critical realization is that both quantities are measured on a scale with equal intervals and an absolute zero. Interpreting the data in this way, one can say that the “odds” of buffering decrease from ~14.4 to ~4.6 from 18 °C to 32 °C. Similarly, one can consider and to be analogous to the “probability” of transfer and the “odds” of transfer, respectively.

Lastly, the buffering angle provides information regarding not only the magnitude of buffering but also the class of buffering behavior. As discussed by Schmitt ([1], Supplement 7), angles between 90° and 0° correspond to non-inverting moderation, with angles of 90° corresponding to perfect buffering and 0° to zero buffering. Thus, the simple inspection of the plot of reveals that the buffering capacity of wild-type Hsp90 is very strong (near perfect at ~86°) but decreases slightly with increasing temperature (to a value of ~78°). In any event—and however the data is interpreted—the analysis presented above clearly demonstrates the ease with which the buffering capacity of a genetic determinant can be formally and exactly quantified.

A formal conceptualization of genetic buffering was first put forward by famed geneticist and Nobel laureate Leland Hartwell [5, 6]. In these publications, Hartwell highlights the importance of buffering relationships in determining phenotype in outbred organisms. Subsequent research both in yeast and in the roundworm, *Caenorhabditis elegans*, has strongly supported his assumptions [7, 8]. Thus, in addition to increasing our basic understanding of genetic networks, these results also raised the theoretical question of whether or not it might be possible to provide an exact quantitative measure of a genetic determinant’s buffering activity.

As described for the first time above, Schmitt’s “formal and general approach” provides a powerful means with which to accomplish this goal. Through the calculation of the four buffering parameters , , , and and the buffering angle , it is indeed possible to provide an exact quantitative measure of the buffering activity or “power” of any genetic determinant in response to an environmental disturbance. Furthermore, the activity can be measured using either a relative scale normalized to one ( and ) or an absolute scale with equal intervals ( and ), or distilled to a single value measure , capable of describing the system in its entirety.

In conclusion, it must be noted that the application of the formal and general approach becomes practical only when used in conjunction with a sophisticated computational engine that is capable of readily analyzing the relevant data. As demonstrated in this article, *Mathematica* provides such an engine. The application of the formal and general approach using the Wolfram Language thus provides a powerful tool with which to quantitatively analyze both classical and non-classical buffering phenomena, irrespective of discipline.

[1] | B. M. Schmitt, “The Quantitation of Buffering Action I. A Formal & General Approach,” Theoretical Biology and Medical Modelling, 2(8), 2005. doi:10.1186/1742-4682-2-8. |

[2] | B. M. Schmitt, “The Quantitation of Buffering Action II. Applications of the Formal & General Approach,” Theoretical Biology and Medical Modelling, 2(9), 2005.doi:10.1186/1742-4682-2-9. |

[3] | M. Taipale, D. F. Jarosz, and S. Lindquist, “HSP90 at the Hub of Protein Homeostasis: Emerging Mechanistic Insights,” Nature Reviews Molecular Cell Biology, 11(7), 2010 pp. 515-528. doi:10.1038/nrm2918. |

[4] | S. L. Rutherford and S. Lindquist, “Hsp90 as a Capacitor for Morphological Evolution,” Nature, 396, 1998 pp. 336-342. doi:10.1038/24550. |

[5] | J. L. Hartman, B. Garvik, and L. Hartwell, “Principles for the Buffering of Genetic Variation,” Science, 291(5506), 2001 pp. 1001-1004. www.sciencemag.org/content/291/5506/1001.abstract. |

[6] | L. Hartwell, “Robust Interactions,” Science, 303(5659), 2004 pp. 774-775. doi:10.1126/science.1094731. |

[7] | A. H. Tong, G. Lesage, G. D. Bader, H. Ding, H. Xu, X. Xin, J. Young, G. F. Berriz, R. L. Brost, M. Chang, Y. Chen, X. Cheng, G. Chua, H. Friesen, D. S. Goldberg, J. Haynes, C. Humphries, G. He, S. Hussein, L. Ke, N. Krogan, Z. Li, J. N. Levinson, H. Lu, P. Ménard, C. Munyana, A. B. Parsons, O. Ryan, R. Tonikian, T. Roberts, A. M. Sdicu, J. Shapiro, B. Sheikh, B. Suter, S. L. Wong, L. V. Zhang, H. Zhu, C. G. Burd, S. Munro, C. Sander, J. Rine, J. Greenblatt, M. Peter, A. Bretscher, G. Bell, F. P. Roth, G. W. Brown, B. Andrews, H. Bussey, and C. Boone, “Global Mapping of the Yeast Genetic Interaction Network,” Science, 303(5659), 2004 pp. 808-813. doi:10.1126/science.1091317. |

[8] | B. Lehner, C. Crombie, J. Tischler, A. Fortunato, and A. G. Fraser, “Systematic Mapping of Genetic Interactions in Caenorhabditis Elegans Identifies Common Modifiers of Diverse Signaling Pathways,” Nature Genetics, 38(8), 2006 pp. 896-903. doi:10.1038/ng1844. |

J. Karagiannis, “The Quantitation of Non-classical Buffering,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-3. |

Dr. Jim Karagiannis is an associate professor at the University of Western Ontario in London, Ontario, Canada. His research makes use of the model eukaryote *Schizosaccharomyces pombe* and explores the complex post-translational modifications that take place on the carboxy-terminal domain (CTD) of the largest subunit of RNA polymerase II. Through an empirical examination of the informational properties and regulatory potential of the CTD, Dr. Karagiannis hopes to decipher the “programming language” used by eukaryotes to control aspects of gene expression.

**Jim Karagiannis**

*Department of Biology
The University of Western Ontario
London, ON
Canada, N6A-5B7*

This article describes the implementation of RIFA, a computational biology algorithm designed to identify the genes most directly responsible for creating differences in phenotype between two biological states, for example, tumorous liver tissue versus cirrhotic liver tissue.

With the invention of microarray technology, scientists finally had a means to measure global changes in gene expression between two biological states [1]. This has led to thousands of scientific publications describing long lists of differentially expressed genes in each scientist’s favorite experimental system. What has gradually become apparent to biologists is that having a list of differentially expressed genes, while an important first step in understanding the differences between two phenotypes (where phenotype represents the physical manifestation of one or more traits), is often not enough to identify the genes most directly responsible for driving changes in phenotype. While it is true that genes that are differentially expressed between two biological states may be important in explaining those differences, it is also possible that genes whose expression is *not* changed can also be pivotal in driving phenotypic differences.

For those unfamiliar with biology, a rough analogy may prove useful. Consider a manufacturing setting where there is a supervisor (a “boss” gene) and employees (“slave” genes) under the supervisor’s responsibility charged with manufacturing widgets (a particular phenotype, such as healthy liver tissue). A change in phenotype, such as transitioning from healthy liver tissue (manufacturing blue widgets) to cancerous liver tissue (manufacturing red widgets) can be accomplished by: (1) changing the rate that employees work (such as might happen if a supervisor shouts at the employees; this is analogous to differential expression); and/or (2) changing the instructions the supervisor is giving to employees (keeping the volume of instructions constant, but changing the information contained in the instructions; this is analogous to a mutation in the “boss” gene); and/or (3) a combination of scenarios (1) and (2). In scenario (1), there is a transition in phenotype because the employees (“slave” genes) begin working faster or slower than they have previously, which produces too many or too few gene products at the wrong time, creating a rippling effect throughout all of the manufacturing, which ends up in a different product (the red widget phenotype) being made. In this situation, the supervisor’s instructions to the employees remain constant (manufacture blue widgets) but are spoken with more (“shouting”) or less (“whispering”) volume. Scenario (1) reflects the kind of information that can be measured in microarray studies, whose sole purpose is to identify genes whose expression changes between two biological states. In scenario (2), the rate at which employees work remains constant, but they still manufacture a different-colored widget (phenotype), because the instructions they are receiving from their supervisor have changed. Differences in phenotype due to scenario (2) are rarely discovered by producing long lists of differentially expressed genes, because the primary driving force creating a change in phenotype is a change in instruction from the supervisor (such as a mutation in the “boss” gene) to the employees (“slave” genes), not a difference in the manufacturing rate of employees.

For these reasons, computational biologists have begun to develop algorithms that are better at highlighting those genes primarily responsible for driving changes in phenotype, regardless of whether those genes are differentially expressed or not. This is the purpose of the regulatory impact factor analysis (RIFA) algorithm presented here; that is, to highlight those genes most directly responsible for driving changes in phenotype. RIFA provides a computationally tractable way to detect differences in connectivity between genes in two biological states. Figure 1 illustrates the basic premise of connectivity and differences in connectivity between two biological states.

**Figure 1.** Two gene networks comprised of the same five genes (a through e) in two different biological states (phenotypes). Each vertex represents a gene, and each edge represents a connection between genes. In standard differential expression studies, each gene’s expression level

is compared to itself between the two biological states but ignores potential relationships between different genes. When even a casual observer compares the two networks above, it is immediately noticeable that the shape of each network is different, a difference driven by a change in connectedness between genes within each biological state.

Regulatory impact factor analysis (RIFA) is based on seminal work by Hudson, Reverter, and Dalrymple [2], which introduced three higher-order metrics all computed from basic information obtained in differential gene expression studies. The purpose of these metrics is to use the information present in gene expression studies to quantify the connectedness between differentially expressed genes (“slave” genes, using the analogy above) and a group of gene expression regulator genes, known as transcription factors (“boss” genes, using the analogy above). The three metrics are:

(1) |

(2) |

(3) |

Equation (1) (PIF) computes the average expression of the gene between two biological states (A and B) and multiplies that result by the differential expression of the gene between states A and B. In doing so, the magnitude of the differential expression of a gene is weighted by the overall expression level of the gene. PIF is then used to compute equation (2) (RIF4), which multiples the PIF value for each differentially expressed gene by the differential co-expression (calculated using the Spearman correlation coefficient) between each differentially expressed gene (the “slave” genes in our analogy above) and each transcriptional regulator (the “boss” genes in our analogy above) between states A and B. By summing these calculations over each differentially expressed gene, a prioritized list of the most important regulators driving changes in phenotype between states A and B can be obtained. Equation (2) is designed to provide an answer to the question, which regulator is consistently highly differentially co-expressed with the most abundant differentially expressed genes? Equation (3) (RIF5) is an alternative metric to equation (2) (RIF4), which also seeks to produce a prioritized list of the most important regulators driving phenotypic change. By multiplying the expression of each differentially expressed gene by the correlation between itself and each transcription regulator twice, once in state A and once in state B, the difference in state values can be computed and then summed over each differentially expressed gene to yield an alternative prioritized list of the most important regulators. Equation (3) is designed to answer the question, which regulator has the most altered ability to predict the abundance of differentially expressed genes? Further details of these equations are presented in [3-4], but the basic idea behind the use of these metrics in RIFA is straightforward. When gene expression data (from a well-thought-out experiment) is presented to RIFA, the algorithm can use the “echoes of sound off structures” (differential gene expression data) to triangulate the location of the “rifle shot creating the sound” (identify the master gene(s) driving the changes in phenotype).

RIFA is template driven, meaning the algorithm expects several pieces of user-defined information to be provided in a notebook cell that is used as a template for entering information. As RIFA was designed to process output from AffyDGED [5], it will be assumed the reader is familiar with AffyDGED as well. The features of RIFA are illustrated using data from a microarray study comparing gene expression profiles of tumorous liver tissue to cirrhotic liver tissue [6]. All microarray data used in this study and presented here is publicly available at NCBI’s Gene Expression Omnibus portal (www.ncbi.nlm.nih.gov/geo), using the access number GSE17548.

The template cell begins with a command to purposefully reinstall Java, for the express purpose of expanding the memory available to import large datasets into *Mathematica*.

The remainder of the template cell defines several variables requiring user input.

**1.** `timecoursedata`: This variable points to the directory containing the microarray gene expression data, in spreadsheet format, to be processed by RIFA. While this variable uses the term “timecourse” as part of its name, it is not necessary for the microarray data to be part of a time course experiment. The spreadsheet format of the data is non-negotiable and requires strict organization. To aid in instruction, a screen shot of the `timecoursedata` that will be described throughout this paper is included here (Figure 2).

**Figure 2.** Formatting of gene expression data for variable <`timecoursedata`>.

Column A contains unique transcript identification information from the microarray chip used in the study. Columns B through X contain gene expression measurement from samples (or time points) under the *same experimental condition* of the study. The columns after X contain gene expression measurements from samples (or time points) under the *same control condition* of the study. For example, in the liver study referenced above, tumor samples from multiple patients were randomly placed into six groups and compared to six groups of cirrhotic liver tissue by AffyDGED. Column B contains the gene expression measurements (transcript abundance, not differential expression) for the first group of tumor samples processed with AffyDGED, column C contains the gene expression measurements from the second group of tumor samples, and so on. In this example, the last column containing tumor (experimental condition) data is column G. Column H is the first column containing gene expression measurements from the first group of cirrhotic (control condition) tissue, column I from the second group of cirrhotic tissue, and so on. Notice how columns B and H contain output from AffyDGED’s processing of the first groups of tumor and cirrhotic tissues, respectively.

**2.** `conditiononecol`: This contains a short list defining the first and last column positions within `timecoursedata` to contain experimental condition data.

**3.** `conditiontwocol`: This contains a short list defining the first and last column positions within `timecoursedata` to contain control condition data.

**4.** `rawtranscriptionreg`: This variable points to the location of a spreadsheet file containing a list (organized into a single column) of known or suspected transcription factor genes present on the microarray chip being used. The file used here was created by parsing the biological process column of the annotation file for Affymetrix’s Human Genome U133 Plus 2.0 chip (available at www.affymetrix.com) for genes linked to the transcription process. The probeset identifiers referring to this group of genes were used to build a list of transcription factor genes.

**5.** `rawdegenes`: This link points to the spreadsheet file containing lists of differentially expressed genes (referenced by their probeset IDs, organized into columns) created by processing the experimental and control groups referenced in `timecoursedata` (above) with AffyDGED. In the liver example here, there are six columns of differentially expressed genes created by using AffyDGED to compare the six groups of tumorous livers with the six groups of cirrhotic livers.

**6.** `affyginlocation`: This variable holds the directory location for finding the Affymetrix .gin (gene information) file that provides the necessary information to annotate output from RIFA.

**7.** `savelocationroot`: This variable holds the location where the user would like the final results of the analysis to be saved.

**8.** `studyname`: This variable allows the user to name the output files generated by RIFA with study-specific information.

The first tasks completed by RIFA include the loading, parsing, and organization of raw data to facilitate downstream computation.

Upon completion of this first section of code, the transcription factor genes (the “boss” genes from the analogy above) are grouped with the differentially expressed genes (the “slave” genes from above) to facilitate calculation of each pairings’ Spearman rank correlation coefficient.

RIFA proceeds by calculating the Spearman rank correlation coefficients, which requires that each vector of gene expression measurements be tested for the presence of duplicate entries, which requires special handling to calculate Spearman rho. This is the purpose of the `tieCheck` module below. Based on the results of `tieCheck`, the code calls the `spearmanControl` module to optimize calculation of Spearman rho, taking advantage of function listability and the use of compilable expressions, where appropriate, to maximize speed.

**Caution:** Due to the sheer volume of computation that needs to be completed using the data described in this paper, the next segment of code will likely take 20-40 minutes to complete (depending on the speed of your computer) and consume roughly 28 Gb of RAM. Computations on machines with less RAM will finish but will require significant use of the hard drive, slowing computation considerably.

By pairing (and taking a sampling of) the correlations of the “boss” and “slave” genes between the tumor and cirrhotic livers, a satisfying (but not biologically surprising) pattern reveals itself (Figure 3). It is clear that there are many more strongly positive correlations between the “boss” and “slave” genes in the cirrhotic liver than the tumorous liver. This supports what biologists have known for a long time; that is, gene regulation in tumorous tissue is significantly uncoordinated.

**Figure 3.** A histogram of the Spearman rank correlation coefficients between regulator and differentially expressed genes in tumorous and cirrhotic liver biopsies.

Following the correlation calculations, RIFA calculates several important metrics, including PIF, RIF4, and RIF5 of equations (1), (2), and (3) described above.

The resulting plots (Figure 4) of PIF (equation (1)), RIF4 (equation (2)), and RIF5 (equation (3)) reveal the bidirectional nature of each of the three metrics. In other words, regardless of the metric used, and are equally influential to the underlying biology. This makes sense when one remembers that gene expression measurements, used in the calculations of the metrics above, are represented on a scale.

**Figure 4.** Histograms for each of the three primary metrics used in the RIFA algorithm. Positive and negative values should be interpreted as equally important (i.e., a gene that is fourfold down in expression is equally as likely to be important as a gene that is fourfold up in expression.)

After the metric calculations are completed, four files are exported containing all the results in file formats directly usable by *Mathematica* and Microsoft Excel. One set of files is appended with the phrase “RifSortByAvg” and contains the following information in table form, sorted by the average of RIF4 and RIF5 values.

Column 1: unique transcript (gene) IDs

Column 2: the average of RIF4 and RIF5 values

Column 3: RIF4 values

Column 4: RIF5 values

Column 5: genbank accession numbers

Column 6: gene names

Column 7: gene product information

A second set of files is appended with the phrase “sortedPIF” and contains the following information in table form, sorted by PIF values.

Column 1: unique transcript (gene) IDs

Column 2: PIF values

Column 3: genbank accession numbers

Column 4: gene names

Column 5: gene product information

As described above, the RIF4 and RIF5 results are most useful for identifying the “boss” genes and the PIF results are most useful for identifying the “slave” genes. Both the “boss” and “slave” genes can be influential in creating differences in phenotypes between two states.

The final output of RIFA is a network graph that associates the most strongly correlated, highest impact PIF scores with the highest impact RIF scores. In this graph, the top 10 most positive and negative average RIF entries, the top 10 most positive and negative RIF4 entries, and the top 10 most positive and negative RIF5 entries are linked to the phenotype of interest with red edges. In other words, the red edges highlight the “boss” genes most responsible for driving changes in phenotype. The nodes of the graph use tooltips to identify the gene represented by the node. The phenotype of interest node is abbreviated “POI.” Blue edges are used to highlight the “slave” genes most responsible and most correlated to the “boss” genes for driving changes in phenotype. In this way, the graph highlights the “slave” genes responding to the “boss” genes’ orders to change phenotype. Here, the highest 0.5% of positive and the lowest 0.5% of negative PIF scores are connected to transcription regulators (represented by RIF nodes) if they share a Spearman rho value of with the transcription regulator.

Three primary lines of evidence show that RIFA is performing to design specifications. Evidence line 1: RIFA was created to provide a *Mathematica* implementation of the regulatory impact factor algorithm originally described by Hudson et al. to highlight those genes most directly responsible for driving changes in phenotype. During development, RIFA was vetted with the original data used by these authors, to highlight the genes most responsible for driving phenotypic differences between Wagyu and Piedmontese cattle. The most prominent (and well-characterized) phenotypic difference between these breeds of cattle is the increased musculature of Piedmontese animals, which is known to be due to a mutation in the breed’s myostatin (GDF8) gene [7]. Using the author’s own data, RIFA correctly identifies GDF8 at the bottom (most negative value of ) of its RIF5 output.

Evidence line 2: The Piedmontese/Wagyu data represents the only dataset that is completely and publicly available to validate RIFA. For this reason, evidence line 1 represents the strongest line of evidence that RIFA is functioning properly, as RIFA is able to duplicate the results of Hudson et al. Even so, other gene expression datasets have been analyzed and discussed in the literature that allow for comparison to RIFA output. Please keep in mind that RIFA’s results cannot be identical to these other examples, as the full list of normalized gene expression data and the full list of transcription regulators, both necessary input to RIFA, are not publicly available. Reverter and colleagues discuss their analysis of porcine gene expression data from [8] and attempt to explain why their results do not prioritize SRY, a gene that is arguably one of the most important sex-determining genes known to science [9]. Reanalysis of this same data using normalized gene expression from AffyDGED and an alternative list of gene regulators shows that RIFA does highlight SRY as the fourth most negatively prioritized gene. While being a satisfying result, it also serves to highlight the fact that all algorithms (RIFA included) are sensitive to the quality of the input data provided to them.

Evidence line 3: Keeping in mind the discussion above, a similar reanalysis of data referenced in [10-11] shows that RIFA highlights CDK8 [12] as the 33rd most negatively prioritized gene. Hudson’s analysis of this data highlights CDK8 as the fourth most positive regulator of colon cancer. Why does RIFA rank CDK8 at position 33, while Hudson’s analysis ranks it at 4? The most reasonable explanation is that RIFA processed a transcription regulator list that included 6,685 regulators, while Hudson’s work employed a smaller regulator list of 1,292 entries. Fourth out of 1292 (4 divided by 1292) is 0.0031, while 33rd out of 6685 is 0.0049. On a percentage basis of the transcription regulator list size, RIFA’s output is nearly identical to that obtained by the original authors who developed the algorithm.

From the evidence presented, we know that RIFA is performing as expected and can begin to ask if results from other studies make biological sense. If RIFA is working correctly, it should highlight genes that have been linked to cirrhosis and/or cancer in the scientific literature. Keep in mind that not every gene likely to be linked to cirrhosis or cancer has been discovered or characterized yet—which is the value in using a program like RIFA, that is, to find new connections between genes and phenotype. A small sample of output will be reprinted for easier referencing here. Additionally, the output will be reformatted to fit within printable margins by forcing the data in each entry to occupy two or more rows of the table below.

What information is revealed in this list? First, let us obtain a list of the unique entries present in this list (a handful of entries may be prioritized by RIF4 and RIF5 metrics simultaneously, thus showing up more than once).

Do any of the results contain entries that have been linked to cirrhotic or tumorous livers in the scientific literature? Any entry that has a gene name associated with it may have information that can be investigated further.

RIFA produces a list of 29 unique gene names that can be searched for in PubMed (www.ncbi.nlm.nih.gov/pubmed). Performing a literature search for these genes in association with liver disease search terms produces the results described in Table 1.

Twenty-one of the 29 RIFA output entries with a gene name associated with them yield compelling connections between each gene and the disease phenotype search terms “liver cirrhosis,” “liver cancer,” and “cancer,” suggesting that RIFA is enriching for genes driving the phenotypic changes observed between cirrhotic and tumorous liver tissue.

The remaining eight out of 29 genes do not show evidence in the scientific literature linking them to these disease phenotypes. Explanations for this abound, but it is impossible to rule out the possibility that these genes are, in fact, linked to the disease phenotypes but have not yet been characterized by the scientific community. It is simply impossible to conclude if those eight genes are or are not linked to the disease phenotypes at this time. The same conclusion must also be admitted for the other 25 RIFA output entries that have no gene name associated with them. In other words, RIFA has identified 25 potential new “boss” genes associated with the cirrhotic to tumor transition in liver tissue. These may represent valuable new avenues of research.

To gauge the performance of RIFA, several publicly available datasets of different sizes and complexity were analyzed. The first column of Table 2 shows the series accession number for each dataset available at NCBI’s Gene Expression Omnibus. Timings were acquired running *Mathematica* 9.0.1 under Windows 7 (64 bit) using an Intel Core i5-2500K processor overclocked to 4.48Ghz. Total system memory is 32GB. All reported timings use a fresh kernel.

Table 2 reveals that small datasets can easily be processed in under one minute, while very large datasets, involving thousands of transcription regulators, differentially expressed genes, and multiple time points can take upwards of 30 minutes. RIFA’s code base utilizes functions with the `Listable` attribute whenever possible to increase speed, which places demands on the computer’s memory infrastructure, as evidenced by the sizeable memory consumption measured with large datasets.

Changes in gene expression are at the core of what distinguishes healthy tissue from diseased tissue. Part of unraveling the mystery behind disease centers on identifying those genes most directly responsible for controlling the differences in gene expression that link those differences to disease traits. RIFA’s implementation brings to the *Mathematica* user community a compelling algorithm used by biomedical researchers to intelligently prioritize the thousands of genes present in an organism and tie their behavior to specific traits of interest.

[1] | M. Schena, D. Shalon, R. W. Davis, and P. O. Brown, “Quantitative Monitoring of Gene Expression Patterns with a Complementary DNA Microarray,” Science, 270(5235), 1995pp. 467-470. doi:10.1126/science.270.5235.467. |

[2] | N. J. Hudson, A. Reverter, and B. P. Dalrymple, “A Differential Wiring Analysis of Expression Data Correctly Identifies the Gene Containing the Causal Mutation,” PLOS Computational Biology, 5(5): e1000382, 2009. doi:10.1371/journal.pcbi.1000382. |

[3] | A. Reverter, N. J. Hudson, S. H. Nagaraj, M. Pérez-Enciso, and B. P. Dalrymple, “Regulatory Impact Factors: Unraveling the Transcriptional Regulation of Complex Traits from Expression Data,” Bioinformatics, 26(7), 2010 pp. 896-904. doi:10.1093/bioinformatics/btq051. |

[4] | N. J. Hudson, B. P. Dalrymple, and A. Reverter, “Beyond Differential Expression: The Quest for Causal Mutations and Effector Molecules,” BMC Genomics, 13(356), 2012. doi:10.1186/1471-2164-13-356. |

[5] | T. Allen, “Detecting Differential Gene Expression Using Affymetrix Microarrays,” The Mathematica Journal, 15, 2013. doi:10.3888/tmj.15-11. |

[6] | G. Yildiz, A. Arslan-Ergul, S. Bagislar, O. Konu, H. Yuzugullu, O. Gursoy-Yuzugullu, N. Ozturk, C. Ozen, H. Ozdag, E. Erdal, S. Karademir, O. Sagol, D. Mizrak, H. Bozkaya, H. Gokhan Ilk, O. Ilk, B. Bilen, R. Cetin-Atalay, N. Akar, and M. Ozturk, “Genome-Wide Transcriptional Reorganization Associated with Senescence-to-Immortality Switch during Human Hepatocellular Carcinogenesis,” PLOS One, May 15, 2013. doi:10.1371/journal.pone.0064016. |

[7] | C. Berry, M. Thomas, B. Langley, M. Sharma, and R. Kambadur, “Single Cysteine to Tyrosine Transition Inactivates the Growth Inhibitory Function of Piedmontese Myostatin,” American Journal of Physiology: Cell Physiology, 283(1), 2002. doi:10.1152/ajpcell.00458.2001. |

[8] | M. Pérez-Enciso, A. L. J. Ferraz, A. Ojeda, and M. López-Béjar, “Impact of Breed and Sex on Porcine Endocrine Transcriptome: A Bayesian Biometrical Analysis,” BMC Genomics, 10(89), 2009. doi:10.1186/1471-2164-10-89. |

[9] | D. Wilhelm, S. Palmer, and P. Koopman, “Sex Determination and Gonadal Development in Mammals,” Physiological Reviews, 87(1), 2007 pp. 1-28. doi:10.1152/physrev.00009.2006. |

[10] | S. H. Nagaraj and A. Reverter, “A Boolean-Based Systems Biology Approach to Predict Novel Genes Associated with Cancer: Application to Colorectal Cancer,” BMC Systems Biology, 5(35), 2011. doi:10.1186/1752-0509-5-35. |

[11] | O. Galamb, S. Spisák, F. Sipos, K. Tóth, N. Solymosi, B. Wichmann, T. Krenács, G. Valcz, Z. Tulassay, and B. Molnár, “Reversal of Gene Expression Changes in the Colorectal Normal-Adenoma Pathway by NS398 Selective COX2 Inhibitor,” British Journal of Cancer, 102, 2010 pp. 765-773. doi:10.1038/sj.bjc.6605515. |

[12] | A. S. Adler, M. L. McCleland, T. Truong, S. Lau, Z. Modrusan, T. M. Soukup, M. Roose-Girma, E. M. Blackwood, and R. Firestein, “CDK8 Maintains Tumor Dedifferentiation and Embryonic Stem Cell Pluripotency,” Cancer Research, 72(8), 2012 pp. 2129-2139.doi:10.1158/0008-5472.CAN-11-3886. |

[13] | G. Li, Y. Zhu, O. Tawfik, B. Kong, J. A. Williams, L. Zhan, K. M. Kassel, J. P. Luyendyk, L. Wang, and G. L. Guo, “Mechanisms of STAT3 Activation in the Liver of FXR Knockout Mice,” American Journal of Physiology: Gastrointestinal and Liver Physiology, 305(11), 2013 pp. G829-837.doi:10.1152/ajpgi.00155.2013. |

[14] | G. Li, B. Kong, Y. Zhu, L. Zhan, J. A Williams, O. Tawfik, K. M Kassel, J. P Luyendyk, L. Wang, and G. L Guo, “Small Heterodimer Partner Overexpression Partially Protects against Liver Tumor Development in Farnesoid X Receptor Knockout Mice,” Toxicology and Applied Pharmacology, 272(2), 2013 pp. 299-305. doi:10.1016/j.taap.2013.06.016. |

[15] | K. J. Archer, V. R. Mas, K. David, D. G. Maluf, K. Bornstein, and R. A. Fisher, “Identifying Genes for Establishing a Multigenic Test for Hepatocellular Carcinoma Surveillance in Hepatitis C Virus-Positive Cirrhotic Patients,” Cancer Epidemiology, Biomarkers & Prevention, 18(11), 2009 pp. 2929-2932. doi:10.1158/1055-9965.EPI-09-0767. |

[16] | M. Mareel, M. Bracke, and F. Van Roy, “Cancer Metastasis: Negative Regulation by an Invasion-Suppressor Complex,” Cancer Detection and Prevention, 19(5), 1995 pp. 451-464. www.ncbi.nlm.nih.gov/pubmed/7585733. |

[17] | N. Wong, W. Yeo, W.-L. Wong, N. L.-Y. Wong, K. Y.-Y. Chan, F. K.-F. Mo, J. Koh, S. L. Chan, A. T.-C. Chan, P. B.-S. Lai, A. K.-K. Ching, J. H.-M. Tong, H.-K. Ng, P. J. Johnson, and K.-F. To, “TOP2A Overexpression in Hepatocellular Carcinoma Correlates with Early Age Onset, Shorter Patients Survival and Chemoresistance,” International Journal of Cancer, 124(3), 2009 pp. 644-652. doi:10.1002/ijc.23968. |

[18] | N. B. Dawany, W. N. Dampier, and A. Tozeren, “Large-Scale Integration of Microarray Data Reveals Genes and Pathways Common to Multiple Cancer Types,” International Journal of Cancer, 128(12), 2011 pp. 2881-2891. doi:10.1002/ijc.25854. |

[19] | J. M. Llovet, Y. Chen, E. Wurmbach, S. Roayaie, M. I. Fiel, M. Schwartz, S. N. Thung, G. Khitrov, W. Zhang, A. Villanueva, C. Battiston, V. Mazzaferro, J. Bruix, S. Waxman, and S. L. Friedman, “A Molecular Signature to Discriminate Dysplastic Nodules from Early Hepatocellular Carcinoma in HCV Cirrhosis,” Gastroenterology, 131(6), 2006 pp. 1758-1767. doi:10.1053/j.gastro.2006.09.014. |

[20] | S. C. Hasenfuss, L. Bakiri, M. K. Thomsen, E. G. Williams, J. Auwerx, and E. F. Wagner, “Regulation of Steatohepatitis and PPAR Signaling by Distinct AP-1 Dimers,” Cell Metabolism, 19(1), 2014 pp. 84-95. doi:10.1016/j.cmet.2013.11.018. |

[21] | M. R. Ebrahimkhani, F. Oakley, L. B. Murphy, J. Mann, A. Moles, M. J. Perugorria, E. Ellis, A. F. Lakey, A. D. Burt, A. Douglass, M. C. Wright, S. A. White, F. Jaffré, L. Maroteaux, and D. A. Mann, “Stimulating Healthy Tissue Regeneration by Targeting the 5-HT2B Receptor in Chronic Liver Disease,” Nature Medicine, 17(12), 2011 pp. 1668-1673. doi:10.1038/nm.2490. |

[22] | Z.-Q. Pan, Z.-Q. Fang, and W.-L. Lu, “Characteristics of Gene Expression of Adrenal Cortical Steroid Synthetase and Its Regulatory Factor in Mice with H22 Liver Cancer of Different Patterns,” Zhongguo Zhong Xi Yi Jie He Za Zhi, 31(1), 2011 pp. 85-89. www.unboundmedicine.com/medline/citation/21434351. |

[23] | J. Dzieran, J. Fabian, T. Feng, C. Coulouarn, I. Ilkavets, A. Kyselova, K. Breuhahn, S. Dooley, and N. M. Meindl-Beinker, “Comparative Analysis of TGF-/Smad Signaling Dependent Cytostasis in Human Hepatocellular Carcinoma Cell Lines,” PLOS One, Aug 22, 2013. doi:10.1371/journal.pone.0072252. |

[24] | J. W. Prokop, F. J. Rauscher 3rd, H. Peng, Y. Liu, F. C. Araujo, I. Watanabe, F. M. Reis, and A. Milsted, “MAS Promoter Regulation: A Role for Sry and Tyrosine Nitration of the KRAB Domain of ZNF274 as a Feedback Mechanism,” Clinical Science, 126(10), 2014 pp. 727-738. doi:10.1042/CS20130385. |

[25] | A. Martínez-Hernández, H. Gutierrez-Malacatt, K. Carrillo-Sánchez, Y. Saldaña-Alvarez, A. Rojas-Ochoa, E. Crespo-Solis, A. Aguayo-González, A. Rosas-López, J. M. Ayala-Sanchez, X. Aquino-Ortega, L. Orozco, and E. J Cordova, “Small MAF Genes Variants and Chronic Myeloid Leukemia,” European Journal of Haematology, 92(1), 2014 pp. 35-41. doi:10.1111/ejh.12211. |

[26] | J. Shen, S. Wang, Y.-J. Zhang, M. A. Kappil, H. C. Wu, M. G. Kibriya, Q. Wang, F. Jasmine, H. Ahsan, P.-H. Lee, M.-W. Yu, C.-J. Chen, and R. M. Santella, “Genome-wide Aberrant DNA Methylation of MicroRNA Host Genes in Hepatocellular Carcinoma,” Epigenetics, 7(11), 2012 pp. 1230-1237. doi:10.4161/epi.22140. |

[27] | C. Paulin and Y. Chamay, “Demonstration of Delta Sleep Inducing Peptide in a Strain of Human Small Cell Lung Cancer by Immunocytology,” Comptes Rendus de L’Academie des Sciences. Serie III, Sciences de la vie, 314(6), 1992 pp. 259-262. www.ncbi.nlm.nih.gov/pubmed/1318772. |

[28] | U. Flucke, B. B. J. Tops, M. A. J. Verdijk, P. J. H. van Cleef, P. H. van Zwam, P. J. Slootweg, J. V. M. G. Bovée, R. G. Riedl, D. H. Creytens, A. J. H. Suurmeijer, and T. Mentzel, “NR4A3 Rearrangement Reliably Distinguishes between the Clinicopathologically Overlapping Entities Myoepithelial Carcinoma of Soft Tissue and Cellular Extraskeletal Myxoid Chondrosarcoma,” Virchows Archiv, 460(6), 2012 pp. 621-628. doi:10.1007/s00428-012-1240-0. |

[29] | G. Ramakrishna, A. Rastogi, N. Trehanpati, B. Sen, R. Khosla, and S. K. Sarin, “From Cirrhosis to Hepatocellular Carcinoma: New Molecular Insights on Inflammation and Cellular Senescence,” Liver Cancer, 2(3-4), 2013 pp. 367-383. doi:10.1159/000343852. |

[30] | M. Slyper, A. Shahar, A. Bar-Ziv, R. Z. Granit, T. Hamburger, B. Maly, T. Peretz, and I. Ben-Porath, “Control of Breast Cancer Growth and Initiation by the Stem Cell-Associated Transcription Factor TCF3,” Cancer Research, 72(21), 2012 pp. 5613-5624. doi:10.1158/0008-5472.CAN-12-0119. |

[31] | Q. Wang, W. Chen, L. Bai, W. Chen, M. T. Padilla, A. S. Lin, S. Shi, X. Wang, and Y. Lin, “Receptor-Interacting Protein 1 Increases Chemoresistance by Maintaining Inhibitor of Apoptosis Protein Levels and Reducing Reactive Oxygen Species through a MicroRNA-146a-Mediated Catalase Pathway,” Journal of Biological Chemistry, 289(9), 2014 pp. 5654-5663. doi:10.1074/jbc.M113.526152. |

[32] | C. Simone and A. Giordano, “Abrogation of Signal-Dependent Activation of the cdk9/cyclin T2a Complex in Human RD Rhabdomyosarcoma Cells,” Cell Death & Differentiation, 14(1), 2007 pp. 192-195. doi:10.1038/sj.cdd.4402008. |

[33] | P. Nahon, A. Sutton, P. Rufat, M. Ziol, H. Akouche, C. Laguillier, N. Charnaux, N. Ganne-Carrié, V. Grando-Lemaire, G. N’Kontchou, J.-C. Trinchet, L. Gattegno, D. Pessayre, and M. Beaugrand, “Myeloperoxidase and Superoxide Dismutase 2 Polymorphisms Comodulate the Risk of Hepatocellular Carcinoma and Death in Alcoholic Cirrhosis,” Hepatology, 50(5), 2009 pp. 1484-1493. doi:10.1002/hep.23187. |

[34] | Y. Han, H. Cai, L. Ma, Y. Ding, X. Tan, Y. Liu, T. Su, Y. Yu, W. Chang, H. Zhang, C. Fu, and G. Cao, “Nuclear Orphan Receptor NR4A2 Confers Chemoresistance and Predicts Unfavorable Prognosis of Colorectal Carcinoma Patients Who Received Postoperative Chemotherapy,” European Journal of Cancer, 49(16), 2013 pp. 3420-3430. doi:10.1016/j.ejca.2013.06.001. |

[35] | B. Wang, S.-H. Hsu, W. Frankel, K. Ghoshal, and S. T. Jacob, “Stat3-Mediated Activation of MicroRNA-23a Suppresses Gluconeogenesis in Hepatocellular Carcinoma by Down-Regulating Glucose-6-Phosphatase and Peroxisome Proliferator-Activated Receptor Gamma, Coactivator 1 Alpha,” Hepatology, 56(1), 2012 pp. 186-197. doi:10.1002/hep.25632. |

[36] | H. Shimada, K. Nakashima, T. Ochiai, Y. Nabeya, M. Takiguchi, F. Nomura, and T. Hiwasa, “Serological Identification of Tumor Antigens of Esophageal Squamous Cell Carcinoma,” International Journal of Oncology, 26(1), 2005 pp. 77-86. doi:10.3892/ijo.26.1.77. |

[37] | X. You, F. Liu, T. Zhang, Y. Li, L. Ye, and X. Zhang, “Hepatitis B Virus X Protein Upregulates Oncogene Rab18 to Result in the Dysregulation of Lipogenesis and Proliferation of Hepatoma Cells,” Carcinogenesis, 34(7), 2013 pp. 1644-1652. doi:10.1093/carcin/bgt089. |

T. D. Allen, “RIFA: A Differential Gene Connectivity Algorithm,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-2. |

Additional electronic files:

- Archive created by free jZip.url
- HG-U133 Plus_2.gin
- hgplus2_trfactors.xls
- liver all expression data for rifa.xls
- liver de genes for rifa.xls

Available at: www.mathematica-journal.com/data/uploads/2015/02/Allen.zip

Todd Allen is an associate professor of biology at HACC, Lancaster. His interest in computational biology using *Mathematica* took shape during his postdoctoral research years at the University of Maryland, where he developed a custom cDNA microarray chip to study gene expression changes in the chestnut blight pathogen, *Cryphonectria parasitica*.

**Todd D. Allen, Ph.D.**

*Harrisburg Area Community College (Lancaster Campus)
East 206R
1641 Old Philadelphia Pike
Lancaster, PA 17602
*

There exists a range of explicit and approximate solutions to the cubic polynomial Rayleigh equation for the speed of surface waves across an elastic half-space. This article presents an alternative approach that uses Padé approximants to estimate the Rayleigh wave speed with five different approximations derived for two expansions about different points. Maximum relative absolute errors of between 0.34% and 0.00011% occur for the full range of the Poisson ratio from to 0.5. Even smaller errors occur when the Poisson ratio is restricted within a range of 0 to 0.5. For higher-order approximants, the derived expressions for the Rayleigh wave speed are more accurate than previously published solutions, but incur a slight cost in extra arithmetic operations, depending on the desired accuracy.

In 1885 Lord Rayleigh published his paper “On Waves Propagated along the Plane Surface of an Elastic Solid” [1] and observed that:

It is proposed to investigate the behavior of waves upon the plane surface of an infinite homogeneous isotropic elastic solid, their character being such that the disturbance is confined to a superficial region, of thickness comparable with the wave-length. …

It is not improbable that the surface waves here investigated play an important part in earthquakes, and in the collision of elastic solids.Diverging in two dimensions only, they must acquire at a great distance from the source a continually increasing preponderance.

The italicized phrase above is a supreme understatement, given the ensuing history of seismology. In any case, Rayleigh proved the theoretical existence of surface waves on an elastic half-space and showed that the speed of such waves may be calculated from the real roots of a cubic polynomial whose coefficients are all real and depend on the ratio of the S-wave velocity to the P-wave velocity, or alternatively on the Poisson ratio of the elastic half-space. He provides the solutions for harmonic waves for both incompressible and compressible half-spaces, shows the elliptic orbit of points on the surface as the wave travels across the surface, demonstrates that the motion is restricted to within approximately one wavelength of the surface, and states that the Poisson ratio may lie between 0.5 and for an elastic material. However, he does not provide explicit expressions for the Rayleigh wave speed.

It appears that the first paper that published explicit expressions for the Rayleigh wave speed for the full range of elastic material properties was by Rahman and Barber [2]. Since that time, a number of authors have sought to develop alternative analytical expressions for the Rayleigh wave speed [3-11]. It is noted that the solutions provided cannot be used indiscriminately, as care is required on occasions to choose the correct root to ensure a smooth and continuous estimate of the Rayleigh wave speed [3, 5, 7]. A parallel effort has attempted to derive approximate expressions for the Rayleigh wave speed [3, 12-18].

Complete analytical derivations were provided by [2, 4, 7, 9, 11]. Others have used computer algebra to assist in their derivations [3, 5, 6]. The original approach given in [4] contains unspecified typographical errors [5, 9]. Indeed, the recent solution given in [9] appears to have been derived earlier and independently but with typographical errors [6]. It has also been shown to be identical to the solution provided in [5]. Cardano’s formula for the roots of a cubic polynomial with real coefficients [19, 20] is used by [2, 5, 7, 9, 11], although the starting point in [9] appears to be different from the other solutions. A more recent solution appears to use Cardano’s formula (but referred to as Shengjin’s formula) [11]. As an aside, an interesting history of Cardano’s formula appears in [21].

Cardano’s formula was published in 1545, and it is perhaps surprising that no explicit solution for the Rayleigh speed was available until the Rahman and Barber publication [2]. It would appear unreasonable to expect that Rayleigh was not aware of the Cardano formula. In any case, and as just one example of prior publication of the Rayleigh wave speed, we may refer to the work in J. E. White’s book, *Underground Sound* [22]. Given without derivation, and in somewhat standard notation often associated with the use of Cardano’s formula, we find by simple algebra that White’s solution is identical to that of Rahman and Barber. It may be speculated that similar solutions were found even earlier.

The approximate expressions for the Rayleigh wave speed of surface waves have been derived by various methods, including Taylor series expansion of the Rayleigh equation [3], approximation of the Rayleigh equation to lower-degree polynomials using the Lanczos method [13], minimization of the integral of the Rayleigh equation with arbitrary coefficients using a least-squares approach [14], least-squares minimization [15, 18] given a known exact solution [5, 7], use of a bilinear function for the root and applying least squares to determine the coefficients of the bilinear function [16], and an iterative method with asymptotic quadratic convergence [17].

In this article, we follow the approach given by Liner [3], but rather than using a Taylor series expansion of the Rayleigh equation, we use Padé approximants. Padé approximants of various orders are described and their accuracy compared to the exact solution given in [7]. The complexity of the various derived solutions is assessed in terms of the number of numerical operations required to calculate the Rayleigh wave speed.

Functions may be approximated in various ways. Perhaps the best known is the Taylor series expansion, whereby a function can be expressed as an infinite series expanded around the

point as

(1) |

where is the derivative of the function evaluated at the point . It is usual to truncate the series to use the lower-order terms as an approximation to the function.

An alternative method to approximate a function is to use Padé approximants. Here the function is approximated as a rational function of two truncated polynomials expanded around the point :

(2) |

where the numerator and denominator are polynomials of degree at most and at most , respectively. The approximant is referred to as a Padé approximant of type . The approximation given in equation (2) has parameters.

The Rayleigh equation [1] for an elastic half-space is given by

(3) |

where , , is the Rayleigh wave speed, and and are the P-wave and S-wave velocities of the medium, respectively. Real roots of equation (3) represent the normalized Rayleigh wave speed, and in the case of several real roots, the smallest is taken. The Poisson ratio may be calculated to give .

The Padé approximant is found for the left-hand side of equation (3), using computer algebra to calculate the necessary coefficients [23]. Equating the numerator polynomial in equation (2) to zero yields the estimate of the normalized Rayleigh speed. Multiple solutions are possible, and these depend on the Padé approximant type, . Given that the Rayleigh equation is a cubic polynomial, the approximations are restricted to and . In particular, the following Padé approximant types are examined: , , , , and .

The five sets of Padé approximants obtained yield solutions for the value of in equation (2) with the following forms: for types , , and , the solutions are ratios of polynomials in of degree 2, 3, and 4, respectively. In each case, both the numerator and denominator polynomials have identical degree, and a general expression for them is

(4) |

for the type . For the types , and , the general expression is

(5) |

where for type and for type . The coefficient for all cases considered here, except in the single case of type for expansion about , in which case .

Like the Taylor series expansion, the Padé approximants are expansions about a given value. In the first instance, expansions were obtained around unity, following previous work [3], but after some trial and error, expansions around were found to be superior in terms of minimizing the absolute relative error across the full range of values for . It is worth repeating that the expansions are done for the ratio of the Rayleigh wave speed to the S-wave velocity squared , unlike the Taylor expansion in Liner [3] that is done about the square root of . Clearly, it is possible to seek the value around which expansions are minimized using a least-squares approach, some aspects of which are discussed below. Below are shown the results obtained for the coefficients in (4) and (5) for expansions about (suitable for the full range of Poisson’s ratio) and (suitable for non-negative Poisson’s ratio), respectively. The coefficient values were obtained using *Mathematica* 9 and are exact.

The relative absolute errors in percentages for the range of are shown below for some of the cases considered. The errors are defined as

(6) |

where and denote numerical and analytical solutions for the Rayleigh wave speed, respectively, and the analytical solution refers to that in [7].

Figure 1 shows a comparison of the exact analytical solution [7], the solution obtained using the Padé approximant , and the solution for a Taylor expansion of the Rayleigh equation given in equation (3). The solution based on the Padé approximant was for an expansion with , while the Taylor series solution was for an expansion with . The relative absolute errors for these two approximate solutions and the one provided by Liner [3] are shown in Figure 2. The Liner solution was a Taylor series expansion in the normalized Rayleigh wave speed, whereas the expansion in its square is shown in Figure 1 and labeled as “Taylor.” It is clear that both Taylor series expansions have increasing errors as increases. The solution based on the Padé approximant has larger errors than either of the Taylor expansion solutions for smaller values of but performs better for larger values of .

Figures 3 and 4 show the relative absolute errors for solutions based on the Padé approximants , and , expanded around the point . As expected, the errors are smaller for the solutions based on higher-order Padé approximants.

The following function gives an exact analytical expression for the Rayleigh wave speed [7, 10].

The function `taylorR` gives the Taylor series expansion in the square of the ratio of Rayleigh wave velocity to the S-wave velocity. (The expansion is not in the ratio alone as in the Liner Taylor series expansion given below.)

The function `padeR` calculates the Rayleigh wave speed based on using Padé approximants. Here `mdegree` is the numerator degree, `ndegree` is the denominator degree, `avalue` is the expansion point, and `root1or2` is 1 or 2, so as to ensure the smallest root is chosen. (Normally `root1or2` is 1, and an incorrect choice is obvious when overlaying the Rayleigh velocity estimate and the exact analytical Rayleigh wave velocity.)

The function `legName` is for the labels in the legend of some of the plots. `rspeed` is used to switch to one of the functions defined for the Rayleigh wave speed; they are defined in the body of the article or in the Appendix.

`plotRayleighSpeedEstimate` is a plotting function that enables comparison of the Rayleigh wave speed obtained by using two functions given in either the body of the report or in the Appendix, and also one derived from a Padé approximant (see the function `legName`). The input parameters are `rspeed1`, `rspeed2` (for the two different functions), and the Padé approximant parameters. `max` is for the full range of Poisson’s ratio and for positive Poisson’s ratio. Note that when , ; , ; , .

**Figure 1.** The normalized Rayleigh wave speed using the Padé approximant expanded around and the Taylor series expanded around . The solid curve is the analytical solution given in Vinh and Ogden [7].

We define a function for the approximation to the Rayleigh wave speed given by Liner [3]. The approximation is based on a Taylor series expansion in the ratio of the Rayleigh wave speed to the shear wave speed.

`plot3RayleighWaveSpeedRelativeError` is a plotting function for comparing the relative absolute errors for the Rayleigh speed estimates from two functions and an estimate obtained from a Padé approximant with similar inputs, described above. `ymax` is the maximum range for the relative error and is adjusted to scale the plot.

**Figure 2.** Relative absolute error for Rayleigh wave speed using the Padé approximant expanded around compared to the two Taylor series expansions, both expanded around .

`plot2RayleighWaveSpeedRelativeError` is a plotting function for comparing the relative absolute errors for the Rayleigh speed estimates obtained using two Padé approximants. The function has similar inputs described above, and here the suffix 1 or 2 refers to the given Padé approximant.

**Figure 3.** Relative absolute error for Rayleigh wave speed using the Padé approximants and expanded around .

**Figure 4.** Relative absolute error for Rayleigh wave speed using the Padé approximants and expanded around .

It is possible to generate the expressions for equations (4) and (5) based on a Padé approximant simply by squaring the Rayleigh wave speed estimate. The square roots of the full set of results given below are good estimates of the Rayleigh wave speed for different ranges of the Poisson ratio. Simple arithmetic yields the results in the forms given in equations (4) and (5).

Here are some useful and accurate expressions for the Rayleigh wave speed squared over the full range of the Poisson ratio with .

Here are some useful and accurate expressions for the Rayleigh wave speed squared over the positive range of Poisson’s ratio with .

Polynomial expressions for the Rayleigh wave speed are given in equations (4) and (5) with respective coefficients given above. These expressions have been derived using Padé approximants around and for (Poisson ratio in the range 0.5 to ) and (Poisson ratio in the range 0.5 to 0), respectively. The two expansion values ( in equations (1) and (2)) were obtained by examining the area under the relative absolute error curve for increments of between 0.5 and 1. In principle, a least-squares solution for the value of producing the minimum error would be feasible for each Padé type, but in so doing we ignore the detailed shape of the error curve across the range of values. For example, Figure 5 shows the relative absolute error for the Rayleigh wave speed based on Padé type for expansions around and . While the error is less for the expansion around for most of the range of values, we observe that for larger values of , the errors become larger and exceed those for the expansion around . This basic behavior is characteristic of the errors obtained (but not shown) using the Padé types and . It is worth noting that for non-negative Poisson’s ratio of , the errors are smaller for expansions about for the three Padé types , , and . The question arises, is it possible to expand around another value that will have smaller errors for non-negative Poisson’s ratio? Figure 6 shows the relative absolute error for the Padé type expanded about and . The error in the latter case is smaller for all values up to approximately , after which it increases beyond that for the expansion about , but not significantly. The maximum error is about the same for both cases. Once more, similar behavior is observed for the other two Padé types and .

Figure 7 shows the relative absolute errors for the Rayleigh wave speed based on using the Padé type expanded around and . The behavior of these curves is different from those shown earlier—here there is a monotonic decrease in the error for most of the full range of as it increases. The errors are one hundred times smaller than those based on the Padé type shown in Figure 6. A somewhat extraordinary reduction of a further five times (so a total of a 500-fold reduction) in relative absolute error occurs for the Rayleigh wave speed estimate based on the Padé type expanded around and shown in Figure 8.

**Figure 5.** Relative absolute error for Rayleigh wave speed using the Padé approximants expanded around the points and .

**Figure 6.** Relative absolute error for Rayleigh wave speed using the Padé approximants expanded around the points and .

**Figure 7.** Relative absolute error for Rayleigh wave speed using the Padé approximants expanded around the points and .

`plot1RayleighWaveSpeedRelativeError` is a plotting function for the relative absolute error of the Rayleigh speed obtained using a single Padé approximant. The function has similar inputs described earlier.

**Figure 8.** Relative absolute error for Rayleigh wave speed using the Padé approximant expanded around .

It is worth summarizing the various error estimates arising from the Rayleigh wave speed based on the Padé approximant types studied for the two ranges of Poisson’s ratios (Table 1). These are compared to other published estimates given in Table 2. Tables 1 and 2 show this data and also the number of arithmetic operations required to compute the value of (equation (3)), from which we estimate any given Rayleigh wave speed. The latter information shows the tradeoff between the accuracy of the Rayleigh wave speed estimate and the associated computational effort. The operations included are addition, subtraction, multiplication, division, and the taking of a root or a trigonometric function; raising to a power is taken as a series of multiplications, and the minimum number of such operations is used wherever possible. It is assumed that an analytical solution is exact, that is known, and that for each approximate solution all coefficients are known and retained as integers until the calculation commences. In the case of the exact solution based on Cardano’s formula, two different expressions exist for different values of , and in this case, the number of operations is given for each path separated by a forward slash. Functions not previously introduced in the body of the text and required to calculate the estimates in Table 2 may be found in the Appendix.

The data in Tables 1 and 2 shows that the computational effort is generally greatest for the three analytical solutions. The approximate solutions based on the Padé approximants improve their error estimates approximately tenfold as we move from Padé types to for expansions around . The number of arithmetic operations increases by about five for Padé types to , without a significant change in the number of operations as we move to Padé types and . For the Padé types expanded around and for non-negative Poisson’s ratio, we find a remarkable reduction in the errors, commencing with a thirtyfold reduction in the Padé type , followed by a twentyfold reduction as we move from Padé types to , and a further tenfold reduction in the errors as we move to Padé types to . The Padé type expanded around has a fifteenfold smaller error than either of the Taylor expansions, and with fewer operations. The methods based on least-squares solutions that minimize the area under the absolute error curves perform strongly, with a good mix of relatively small errors and a small number of arithmetic operations. It is necessary to go to the approximation based on Padé type before the error is less than that for the solutions based on least squares, but this requires more arithmetic operations.

The Rayleigh wave speed was estimated based on expansions of the Rayleigh equation by Padé approximants and equating the numerator of that representation to zero. The numerator polynomials were solved for the normalized Rayleigh wave speed and provide five distinct solutions. The solutions have varying degrees of accuracy, depending on the value about which the Rayleigh equation is expanded. Good, accurate solutions occur for the full range of Poisson’s ratio, and even more accurate solutions are found for non-negative Poisson’s ratio. It is concluded that these expressions for the Rayleigh wave speed provide a useful approximation, with a balance between accuracy and number of arithmetic operations required.

This Appendix contains a number of functions that estimate the Rayleigh wave speed, which may be used to reproduce some results for the approximate solutions found in Table 2. Other needed functions have been presented in the body of the main text.

Here is the Bergmann formula from Vinh and Malischewsky [24].

Here is the Vinh and Malischewsky [18] formula to degree 2 in Poisson’s ratio.

Here is the Vinh and Malischewsky [18] formula to degree 3 in Poisson’s ratio.

Here is the Vinh and Malischewsky [18] formula to degree 4 in Poisson’s ratio.

Here is the Rahman and Michelitsch [18] formula using the Lanczos approximation.

Here is the Li [14] formula for the full range of Poisson’s ratio.

Here is the Li [14] formula for the positive range of Poisson’s ratio.

[1] | L. Rayleigh, “On Waves Propagated along the Plane Surface of an Elastic Solid,” Proceedings of the London Mathematical Society, S1-17(1), 1885 pp. 4-11. doi:10.1112/plms/s1-17.1.4. |

[2] | M. Rahman and J. R. Barber, “Exact Expressions for the Roots of the Secular Equation for Rayleigh Waves,” Journal of Applied Mechanics, 62(1), 1995 pp. 250-252. doi:10.1115/1.2895917. |

[3] | C. L. Liner, “Rayleigh Wave Approximations,” Journal of Seismic Exploration, 3, 1994 pp. 273-281. |

[4] | D. Nkemzi, “A New Formula for the Velocity of Rayleigh Waves,” Wave Motion, 26(2), 1997 pp. 199-205. doi:10.1016/S0165-2125(97)00004-8. |

[5] | P. G. Malischewsky, “Comment to ‘A New Formula for the Velocity of Rayleigh Waves’ by D. Nkemzi [Wave Motion 26 (1997) 199-205],” Wave Motion, 31(1), 2000 pp. 93-96. doi:10.1016/S0165-2125(99)00025-6. |

[6] | H. Mechkour, “The Exact Expressions for the Roots of Rayleigh Wave Equation,” Proceedings of the 2nd International Colloquium of Mathematics in Engineering and Numerical Physics (MENP-2), Bucharest, 2002, Geometry Balkan Press, 2003 pp. 96-104. |

[7] | P. C. Vinh and R. W. Ogden, “On Formulas for the Rayleigh Wave Speed,” Wave Motion, 39(3), 2004 pp. 191-197. doi:10.1016/j.wavemoti.2003.08.004. |

[8] | P. G. Malischewsky Auning, ” A Note on Rayleigh-Wave Velocities as a Function of the Material Parameters,” Geofísica internacional, 43(3), 2004 pp. 507-509. www.geofisica.unam.mx/unid_apoyo/editorial/publicaciones/investigacion/geofisica_internacional/anteriores/2004/03/Malischewsky.pdf. |

[9] | D. W. Nkemzi, “A Simple and Explicit Algebraic Expression for the Rayleigh Wave Velocity,” Mechanical Research Communications, 35(3), 2008 pp. 201-205. doi:10.1016/j.mechrescom.2007.10.005. |

[10] | P. G. Malischewsky, “Reply to Nkemzi, D. W., ‘A Simple and Explicit Algebraic Expression for the Rayleigh Wave Velocity,’ [Mechanical Research Communications (2007), doi:10.1016/j.mechrescom.2007.10.005],” Mechanical Research Communications, 35(6), 2008 p. 428. doi:10.1016/j.mechrescom.2008.01.011. |

[11] | X.-F. Liu and Y.-H. Fan, “A New Formula for the Rayleigh Wave Velocity,” Advanced Materials Research, 452-453, 2012 pp. 233-237. |

[12] | D. Royer, “A Study of the Secular Equation for Rayleigh Waves Using the Root Locus Method,” Ultrasonics, 39(3), 2001 pp. 223-225. doi:10.1016/S0041-624X(00)00063-9. |

[13] | M. Rahman and T. Michelitsch, “A Note on the Formula for the Rayleigh Wave Speed,” Wave Motion, 43(3), 2006 pp. 272-276. doi:10.1016/j.wavemoti.2005.10.002. |

[14] | X.-F. Li, “On Approximate Analytic Expressions for the Velocity of Rayleigh Waves,” Wave Motion, 44(2), 2006 pp. 120-127. doi:10.1016/j.wavemoti.2006.07.003. |

[15] | P. C. Vinh and P. G. Malischewsky, “Explanation for Malischewsky’s Approximate Expression for the Rayleigh Wave Velocity,” Ultrasonics, 45(1-4), 2006 pp. 77-81. doi:10.1016/j.ultras.2006.07.001. |

[16] | D. Royer and D. Clorennec, “An Improved Approximation for the Rayleigh Wave Equation,” Ultrasonics, 46(1), 2007 pp. 23-24. doi:10.1016/j.ultras.2006.09.006. |

[17] | A. V. Pichugin. “Approximation of the Rayleigh Wave Speed.” (Jan 10, 2008) people.brunel.ac.uk/~mastaap/draft06rayleigh.pdf. |

[18] | P. C. Vinh and P. G. Malischewsky, “Improved Approximations of the Rayleigh Wave Velocity,” Journal of Thermoplastic Composite Materials, 21(4), 2008 pp. 337-352. doi:10.1177/0892705708089479. |

[19] | M. Abramowitz and I. A. Segun, eds., Handbook of Mathematical Functions, New York: Dover Publications, 1965. |

[20] | D. Zwillenger, ed., Standard Mathematical Tables and Formulae, 31st ed., Boca Raton: CRC Press, 2003. |

[21] | P. R. Hewitt. “Cardano’s Formulas or a Pivotal Moment in the History of Algebra.” (Apr 7, 2009) livetoad.org/Courses/Documents/bb63/Notes/cardanos_formulas.pdf. |

[22] | J. E. White, Underground Sound: Application of Seismic Waves, New York: Elsevier, 1983. |

[23] | Mathematica, Release Version 9.0, Champaign: Wolfram Research, Inc., 2013. |

[24] | P. C. Vinh and P. G. Malischewsky, “An Approach for Obtaining Approximate Formulas for the Rayleigh Wave Velocity,” Wave Motion, 44(7-8), 2007 pp. 549-562. doi:10.1016/j.wavemoti.2007.02.001. |

A. T. Spathis, “Use of Padé Approximants to Estimate the Rayleigh Wave Speed,” The Mathematica Journal, 2015. dx.doi.org/doi:10.3888/tmj.17-1. |

A. T. (Alex) Spathis works in rock mechanics and rock dynamics. He has measured the stresses in the Earth’s crust at shallow depths of tens of meters down to moderate depths of over 1000 meters. This data assists in understanding earthquakes and in the design of safe underground mines. He has formal qualifications in applied mathematics, electrical engineering, and rock mechanics, and has a Ph.D. in geophysics.

**A. T. Spathis**

*Orica Technical Centre
PO Box 196
Kurri Kurri NSW
Australia 2327*

Remarkable advances have been made in radiotherapy for cancer. Tumors inside the body that move with respiration can now be tracked during irradiation or can be irradiated at a specific phase of respiration [1]. Since radiation of these wavelengths is invisible to the human eye, it is not possible to see whether a tumor that is moving during respiration is being irradiated accurately. Therefore, simulations that use the actual respiration wave to show the tumor being irradiated are useful for training and to explain the procedure to patients.

Radiation generated by radiotherapy equipment has a dosage rate, which is defined as the strength over time. Therefore, the duration of irradiation of a tumor inside the body at a certain dose is determined by the dose rate. For tumors in the brain, head, and neck region, fixing the target area in place can prevent tumor movement during irradiation. However, with tumors of the lung or abdomen, the displacement of the organs during respiration is substantial, and the tumor moves with respiration during the irradiation time. In conventional radiotherapy, respiratory displacement of the tumor is taken into account by targeting a large radiation field. However, when a large radiation field is used, the large radiation dose delivered to the patient in one session can cause severe side effects; thus, irradiation has to be carried out over a longer period with smaller doses.

For small tumors located inside the brain, precise irradiation of a small field has been shown to enable delivery of a single large dose without adverse side effects. An attempt has been made to apply this technology to tumors of the trunk, where the most important issue is countering the respiratory movement of the tumor. One way to achieve this is to detect respiratory displacement and conduct irradiation according to the positional information. One such method is to carry out irradiation when the tumor is in position within a certain range, and another method is to track respiratory displacement during irradiation. Revolutionary advances in radiation therapy technology have enabled both these methods to be used in practice [1].

Depicting the form of irradiation of a small tumor inside the body with countermeasures against respiratory movement in a three-dimensional simulation could promote better understanding of this therapeutic method. In the simulation, a target volume is set to encompass the shape of a small tumor. The tumor moves along the vertical axis of the trunk ( axis). For irradiation, either the radiation field moves in accordance with the tumor movement, or irradiation is performed only when the tumor has completely entered the radiation field in a set respiratory phase. At the same time, the respiration wave is output and the position of the tumor on that waveform is recreated.

Respiratory displacement was sampled at a rate of 25 times/s using a pressure sensor attached to the body. The sampled data was stored in a CSV file to be read into *Mathematica*. The read-in data is shown in the output of the list plot below. In the graph, the minimum value on exhalation during free respiration was defined as 0, and the maximum value on inhalation was defined as 100.

The notebook defines 3407 triplets.

This extracts the respiration wave data and plots it.

A single malignant tumor cell generated by the effects of carcinogenic factors at several stages forms a visible tumor mass through continued monoclonal proliferation. Cell density is high in the center of the tumor and is assumed to spread out in three dimensions in a normal distribution.

This defines the 3D normal distribution of tumor morphology.

This defines the location of the tumor at a given time with a given color.

The center of the tumor moves along the axis with amplitude given by the respiratory wave and shown on the left with a red point. Think of the front of the body as the front plane (the plane parallel to the - given by ).

The patient is lying on the surface of the bed (with respect to the graph, the patient lies on the - plane with the head in the negative direction, the feet in the positive direction, and looking up in the direction). As the patient breathes, the tumor moves in the direction of the length of the body (i.e. along the axis). A tumor-tracking beam acts on the - plane set at five times the standard deviation of the tumor spread. The beam moves with the respiratory wave in the same way as the tumor.

In this situation, the beam is set to turn on when it enters a set position in the respiratory wave amplitude (“Threshold ”). On and off gating of the radiation beam is easily observable on the respiratory waveform, the % threshold value being clearly indicated.

This shows the irradiation synchronized to respiration.

Stereotactic radiotherapy was originally developed for the treatment of diseased regions inside the cranium, which do not move once fixed in position. It has been demonstrated that targeting a small lesion from multiple directions enables delivery of a large radiation dose in one session, without causing side effects to the adjacent normal tissue. To apply this technology to tumors in the trunk region, which move in conjunction with respiration, the tumor needs to be immobilized. An attempt was made to irradiate the tumors from multiple directions with minimized respiratory movement by fixing the body in position and compressing the abdomen to reduce the movement of the diaphragm to very slight movement [2, 3]. This method was shown to be safe and effective and represents a technological innovation in stereotactic irradiation of the trunk region. Having patients hold their breath during irradiation is the simplest method, which is becoming widespread—a method equivalent to stereotactic radiotherapy used for the cranium. On the other hand, irradiation conducted under free-breathing conditions is the most appropriate physiological method, but requires a mechanism for irradiating during a phase synchronized with the respiratory wave [4, 5]. Moreover, the method of irradiating the tumor while tracking its movement with respiration has presented difficulties in controlling the motion of a movable section of the irradiation equipment [6, 7]. However, recent advances in irradiation equipment and control computers have now enabled both of these methods to be utilized.

To make these complicated therapies understandable is difficult with only written descriptions and static images. We have therefore attempted to develop a dynamic simulation model based on actual respiratory wave data. This simulation model has been well received by students and medical residents and is also effective in explaining the procedure to patients.

[1] | S. B. Jiang, “Technical Aspects of Image-Guided Respiration-Gated Radiation Therapy,” Medical Dosimetry, 31(2), 2006 pp. 141-151. doi:10.1016/j.meddos.2005.12.005. |

[2] | V. M. Remouchamps, F. A.Vicini, M. B. Sharpe, L. L. Kestin, A. A. Martinez, and J. W. Wong, “Significant Reductions in Heart and Lung Doses Using Deep Inspiration Breath Hold with Active Breathing Control and Intensity-Modulated Radiation Therapy for Patients Treated with Locoregional Breast Irradiation,” International Journal of Radiation Oncology *Biology *Physics, 55(2), 2003 pp. 392-406. doi:10.1016/S0360-3016(02)04143-3. |

[3] | M. Nakamura, K. Shibuya, A. Nakamura, T. Shiinoki, Y. Matsuo, M. Nakata, A. Sawada, T. Mizowaki, and M. Hiraoka, “Interfractional Dose Variations in Intensity-Modulated Radiotherapy with Breath-Hold for Pancreatic Cancer,” International Journal of Radiation Oncology *Biology *Physics, 82(5), 2012 pp.1619-1626. doi:10.1016/j.ijrobp.2011.01.050. |

[4] | Y. Otani, I. Fukuda, N. Tsukamoto, Y. Kumazaki, H. Sekine, E. Imabayashi, O. Kawaguchi, T. Nose, T. Teshima, and T. Dokiya, “A Comparison of the Respiratory Signals Acquired by Different Respiratory Monitoring Systems Used in Respiratory Gated Radiotherapy,” Medical Physics, 37, 2010 pp. 6178-6186. doi:10.1118/1.3512798. |

[5] | S. S. Vedam, P. J. Keall, V. R. Kini, and R. Mohan, “Determining Parameters for Respiration-Gated Radiotherapy,” Medical Physics, 28, 2001 pp. 2139-2146. doi:10.1118/1.1406524. |

[6] | A. Schweikard, H. Shiomi, and J. Adler, “Respiration Tracking in Radiosurgery,” Medical Physics, 31, 2004 pp. 2738-2741. doi:10.1118/1.1774132. |

[7] | A. Schweikard, H. Shiomi, and J. Adler, “Respiration Tracking in Radiosurgery without Fiducials,” International Journal of Medical Robotics and Computer Assisted Surgery, 1(2), 2005 pp. 19-27. doi:10.1002/rcs.38. |

H. Sekine and Y. Otani, “Development of Simulation Models of Respiratory Tracking and Synchronizing for Radiotherapy,” The Mathematica Journal, 2014. dx.doi.org/doi:10.3888/tmj.16-12. |

Hiroshi Sekine is a professor in the Department of Radiology, Jikei University, School of Medicine, Tokyo. His recent research interests relate to quantitative analysis of the time-dose-fractionation relationship of radiation therapy.

Yuki Otani is a physicist in the Department of Radiation Oncology, Graduate School of Osaka University, Osaka, Japan. His recent research interests relate to exact tracking of moving tumors in the body.

**Hiroshi Sekine**

*Department of Radiology
Jikei University School of Medicine
Jikei Daisan Hospital
4-11-1, Izumi-Honcho, Komae, Tokyo,
Japan. 201-8601*

**Yuki Otani**

Department of Radiation Oncology

Graduate School of Medicine, Osaka University

2-2, Yamadaoka, Suita, Osaka,

Japan. 565-0871

*y.otani@radonc.med.osaka-u.ac.jp*

This article carries out the evaluation of nuclear-electron attraction energy integrals using Gaussian-type functions with arbitrary Cartesian angular values. As an example, we calculate the corresponding matrix for the water molecule in the STO-3G basis set.

Evaluating molecular integrals has been an active field since the middle of the last decade. Efficient algorithms have been developed and implemented in various programs. Detailed accounts of molecular integrals can be found in the references of [1]. In this article, the third in a series describing algorithms for evaluating molecular integrals, we detail the evaluation of the nuclear-electron attraction energy integrals from a more didactic point of view, following the approach of Rys, Dupuis, and King [2] as implemented in the OpenMol program [3].

The energy caused by the attraction between an electron in the region described by the overlap of the orbitals , and a nuclear of charge located at is expressed by the nuclear-electron attraction integral

(1) |

in which is an unnormalized Cartesian Gaussian primitive.

Using the Gaussian product (see, for example [1]) and defining the angular part as :

(2) |

The pole problem can be solved by the Laplace transform

(3) |

which turns the integral into

(4) |

where for now, we have ignored the factor . In the following steps, we will make certain modifications, knowing in advance that they will help simplify the expressions later on. We first reduce the upper limit of to unity by making the changes of variable (recall from the Gaussian product that ):

(5) |

and

(6) |

Replace , , and in , to get

(7) |

We now multiply by the factor :

(8) |

Again, by inserting , we get

(9) |

Having arrived at the desired form, we reinsert the value of the angular part into the expression and separate the term enclosed by the curly brackets into three components , , and :

(10) |

Defining as the function of the component inside the bracket,

(11) |

and similarly for and , we rewrite the integral as

(12) |

We will show that the integrand in the expression for is in fact an overlap between two one-dimensional Gaussians, and we may use the results that have been developed in [1]. First, we expand the exponential parts of the integrand

(13) |

regrouping in terms of and , we have

(14) |

which becomes

(15) |

where and . These definitions let us compare this equation with the result of the Appendix, in which we see that equation (15) is simply

(16) |

where

(17) |

Substituting and ,

(18) |

into equation (13), we have

(19) |

Substitute this result into the definition of to get

(20) |

The integral has the same form as a one-dimensional overlap integral where the integrand is a Gaussian function centered at with an exponential coefficient .

From the observation above, we make use of the results developed for overlap integrals in [1]. For example, for ,

(21) |

In particular, we have the transfer equations

(22) |

The and functions take similar forms. The product is a polynomial in , and if we replace , then the integral in equation (12) is

(23) |

where is the said polynomial. The integral is a combination of the Boys function (see, for example, Reference 4 of [1])

(24) |

a strictly positive and decreasing function.

Aside from the obvious choice of using *Mathematica* to evaluate the Boys function, there are several ways of evaluating the integral. In practice, most programs store pretabulated values of the function at different intervals and interpolation is done as needed (e.g. by Chebyshev polynomials). Here we use the Gauss-Chebyshev quadrature numerical integration [4]. For simplicity, we have adopted almost verbatim the F77 code in [4, p. 46].

The function `Nea` evaluates the nuclear-electron attraction integral of two Gaussian primitives; here `alpha`, `beta`, `RA`, `RB`, `LA`, and `LB` are , , , , , and as defined earlier; `RR` is the nuclear position.

As in our two earlier articles [1, 5], we use the same data for the water molecule (, , the geometry optimized at the HF/STO-3G level). The molecule lies in the - plane with Cartesian coordinates in atomic units.

In the STO-3G basis set, each atomic orbital is approximated by a sum of three Gaussians; here are their unnormalized primitive contraction coefficients and orbital exponents.

Here are the basis function origins and Cartesian angular values of the orbitals, listed in the order , , , , , , and .

Specifically, for the nuclear-electron attraction energy integral between the first primitive of the orbital of hydrogen atom 1, , the first primitive of the orbital of the oxygen atom, , and atom 1 () is

(25) |

We have

From the Gauss-Chebyshev quadrature, the integral in equation (23) yields . The nuclear-electron integral (25) is . This is calculated as follows.

We would first need the normalization factor before evaluating the nuclear-electron energy matrix.

We have provided a didactic introduction to the evaluation of nuclear-electron attraction-energy integrals involving Gaussian-type basis functions by use of recurrence relations and a numerical quadrature scheme. The results are sufficiently general so that no modification of the algorithm is needed when larger basis sets with more Gaussian primitives or primitives with larger angular momenta are employed.

Consider the Gaussian product: . Combine and expand the coefficients

to get

Let and substitute in the exponent to get

The first three terms inside the second bracket factor to , and the last two can be reduced to . The original Gaussian product is thus

Here is a verification.

If one opts to use *Mathematica*’s own incomplete gamma function , equation (24) can be defined in closed form.

Here is an example.

This is the result.

Here is a comparison with the quadrature result.

Understandably, direct use of the `Gamma` function is much faster and yields more accurate results. We thank Paul Abbott for providing the example.

[1] | M. Hô and J. M. Hernández-Pérez, “Evaluation of Gaussian Molecular Integrals I,” The Mathematica Journal, 14(3), 2012. doi:10.3888/tmj.14-3. |

[2] | J. Rys, M. Dupuis, and H. F. King, “Computation of Electron Repulsion Integrals Using the Rys Quadrature Method,” Journal of Computational Chemistry, 4(2), 1983 pp. 154-157. doi:10.1002/jcc.540040206. |

[3] | G. H. F. Diercksen and G. G. Hall, “Intelligent Software: The OpenMol Program,” Computers in Physics, 8(2), 1994 pp. 215-222. doi:10.1063/1.168520. |

[4] | J. Pérez-Jorda and E. San-Fabián, “A Simple, Efficient and More Reliable Scheme for Automatic Numerical Integration,” Computer Physics Communications, 77(1), 1993 pp. 46-56. doi:10.1016/0010-4655(93)90035-B. |

[5] | M. Hô and J. M. Hernández-Pérez, “Evaluation of Gaussian Molecular Integrals II,” The Mathematica Journal, 15(1), 2013. doi:10.3888/tmj.15-1. |

M. Hô and J. M. Hernández-Pérez, “Evaluation of Gaussian Molecular Integrals,” The Mathematica Journal, 2014. dx.doi.org/doi:10.3888/tmj.16-9. |

Minhhuy Hô received his Ph.D. in theoretical chemistry at Queen’s University, Kingston, Ontario, Canada, in 1998. He is currently a professor at the Centro de Investigaciones Químicas at the Universidad Autónoma del Estado de Morelos in Cuernavaca, Morelos, México.

Julio-Manuel Hernández-Pérez obtained his Ph.D. at the Universidad Autónoma del Estado de Morelos in 2008. He has been a professor of chemistry at the Facultad de Ciencias Químicas at the Benemérita Universidad Autónoma de Puebla since 2010.

**Minhhuy Hô**

*Universidad Autónoma del Estado de Morelos
Centro de Investigaciones Químicas
Ave. Universidad, No. 1001, Col. Chamilpa
Cuernavaca, Morelos, Mexico CP 92010
*

**Julio-Manuel Hernández-Pérez
**

Facultad de Ciencias Químicas

Ciudad Universitaria, Col. San Manuel

Puebla, Puebla, Mexico CP 72570

julio.hernandez@correo.buap.mx