# The NAG C Library - Included in Mark 24

Now at Mark 24, the NAG C Library contains over 1,500 algorithms which are powerful, reliable, flexible and ready for use from a wide range of operating systems, languages, environments and packages including Excel, Java, .NET, C#, VB and many more.

We've selected key highlights from the NAG Library and show in more detail how a particular function or set of functions can be used. A full comprehensive overview of what's new can be found in the online documentation.

To learn more about a specific area/function click on the relevant link below.

- Confluent and Gauss Hypergeometric Functions (Mark 24)
- Two-stage Spline Approximation to Scattered Data (Mark 24)
- Further Additions to Nearest Correlation Matrix (Mark 24)
- Heston Model with Term Structure (Mark 24)
- Optimization for Non-Negative Least Squares (Mark 24)
- Quadratic Eigenvalue Problem (Mark 24)
- Inhomogeneous Time Series (Mark 24)
- Gaussian Mixture Model (Mark 24)
- Best subset (Mark 24)
- Matrix Functions (Mark 24)
- Multi-start Optimization (Mark 23)
- Bound Optimization By Quadratic Approximation (Mark 23)
- Linear Quantile Regression (Mark 23)
- Sampling with Unequal Weights (Mark 23)
- Calling random number generators from a multi-threaded environment (Mark 23)
- Copulas
- Skipping Ahead the Mersenne Twister Random Number Generator (Mark 23)
- Global Optimization
- Nearest Correlation Matrix
- Partial Least Squares / Ridge Regression
- Quantiles
- Search routines

## New functionality at Mark 24

### Global Optimization techniques

*"In my work on financial optimization I was researching a problem in portfolio selection which turned out to have multiple solutions. The model I was using was not continuously differentiable and so I needed a direct search (non-gradient) solution method. Neumaier's Multi-level Coordinate Splitting technique seemed a suitable choice and I was able to obtain a copy of the beta-test version of the NAG implementation of this approach. I am pleased to say that it yielded satisfactory solutions to my problem. More important, from my research and development point of view, the software offers a user plenty of choice and control over the way the calculation is performed, the accuracy of the search and the final stopping criteria. This flexibility is very valuable when one is working with a new and untried optimization model."*

Dr Michael Bartholomew-Biggs

Head of Numerical Optimization Centre and School of Physics Astronomy and Mathematics, University of Hertford

Extensions to the Library have been made in many areas namely statistics, optimization, linear algebra, ordinary differential equations, regression, random number generators and special functions.

- Fast Fourier Transforms (FFTs) for two-dimensional and three dimensional real data. (NAG Library Chapter C06 - Summation of Series)
- Three-dimensional discrete wavelet transforms. Maximal overlap discrete wavelet transform (MODWT). (NAG Library Chapter C09 - Wavelet Transforms)
- Comprehensive one-dimensional adaptive quadrature routine and a variant for badly behaved Boundary Value Problems by the collocation method, and Runge–Kutta methods for non-stiff Initial Value Problems. (NAG Library Chapter D02 - Ordinary Differential Equations)
- The modified Shepard's method for interpolating in dimensions greater than 5. (NAG Library Chapter E01 - Interpolation)
- Two-stage approximation method for two-dimensional scattered dat.a (NAG Library Chapter E02 - Curve and Surface Fitting)
- Non-negative least squares and new MPS data reader. (NAG Library Chapter E04 - Minimizing or Maximizing a Function)
- Multi-start version of a least squares with nonlinear constraints function. (NAG Library Chapter E05 - Global Optimization of a Function)
- Extended range of matrix functions including The matrix logarithm, the matrix square root, the matrix exponential, general matrix powers and computing Fréchet derivatives. (NAG Library Chapter F01 - Matrix Operations)
- Solution of the real and complex quadratic eigenvalue problem, and for selected eigenvalues/vectors of general sparse matrices. (NAG Library Chapter F02 - Eigenvalues and Eigenvectors)
- Norm estimators for rectangular matrices. (NAG Library Chapter F04 - Simultaneous Linear Equations)
- Recursive, explicitly blocked QR factorization and applying Q for general matrices and for triangular-pentagonal matrices. Complete CS decomposition of an orthogonal or unitary matrix. (NAG Library Chapter F08 - Least Squares and Eigenvalue Problems (LAPACK))
- Block diagonal solver for real and complex nonsymmetric sparse matrices. (NAG Library Chapter F11 - Large Scale Linear Systems)
- Eigenvalues/vectors of general banded complex eigenproblems. (NAG Library Chapter F12 - Large Scale Eigenproblems)
- Functions for calculating summary statistics in a rolling window and combining summary statistics calculated on different data streams as well as a function for calculating probabilities from a multivariate Student's –distribution. (NAG Library Chapter G01 - Simple Calculations on Statistical Data)
- Functions for weighted nearest correlation matrix and calculating sums of squares matrices on streamed data. (NAG Library G02 - Correlation and Regression Analysis)
- Gaussian mixture model function. (NAG Library Chapter G03 - Multivariate Methods).
- Brownian bridge and random field functions. (NAG Library Chapter G05 - Random Number Generators).
- Functions for analysing inhomogeneous time series. (NAG Library Chapter G13 - Time Series Analysis).
- Best subset selections. (NAG Library Chapter H - Operations Research)
- Confluent and Gauss hypergeometric functions 1F1 and 2F1. Heston model with term structure. (NAG Library Chapter S - Approximations of Special Functions).
- Testing and setting Infs and NaNs. (NAG Library Chapter X07 - IEEE Arithmetic)

The new functionality added at Mark 24 further enhances the comprehensive collection of numerical and statistical techniques offered by the Library:

Numerical facilities

### Option Pricing Formulae

*"We use NAG at the Manchester Business School, first and foremost, because we trust its accuracy. The introduction of NAG option pricing routines accessible from MATLAB and Excel-VBA has greatly expanded its clientele from a small group of hard core Fortran and C/C++ programmers to large population of PhD Finance, MSc Quantitative Finance, MSc Mathematical Finance, and finance specialist undergraduate students. NAG has made complex derivative models accessible to a much wider audience whose primary goal is to understand the models instead of being bogged down by the nuts-and-bolts of coding. Even for the hard core option pricing experts, now that they do not have to reinvent the wheel all the times, they can concentrate on advancing the models. The MATLAB and Excel-VBA interface allows the experienced hard Quant to build up prototype models quickly."*

Dr Ser-Huang Poon

Professor of Finance, Manchester Business School, University of Manchester

- Optimization, including linear, quadratic, integer and nonlinear programming and least squares problems
- Ordinary and partial differential equations, and mesh generation
- Numerical integration and integral equations
- Roots of nonlinear equations (including polynomials)
- Solution of dense, banded and sparse linear equations and eigenvalue problems
- Solution of linear and nonlinear least squares problems
- Special functions
- Curve and surface fitting and interpolation

Statistical facilities

- Random number generation
- Simple calculations on statistical data
- Correlation and regression analysis
- Multivariate methods
- Analysis of variance and contingency table analysis
- Time series analysis
- Nonparametric statistics