# NAG Library - New Content

### The NAG Library contains hundreds of 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 in the NAG Library can be found in the online documentation.

A User's View - 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

Numerical and Statistical Facilities

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

### Numerical facilities

• Optimization, including linear, quadratic, integer and nonlinear programming, least squares problems and semi-definite programming
• 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
• Nearest correlation matrix
• Correlation and regression analysis
• Multivariate methods
• Analysis of variance and contingency table analysis
• Time series analysis
• Nonparametric statistics

## Portfolio Optimization - An Example of Portfolio Optimization

A User's View - 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

New functionality

Extensions to the Library have been made in many areas included quadrature, statistics, wavelet and Fast Fourier Transforms, ordinary differential equations, interpolation, surface fitting, optimization, matrix operations, linear algebra, operations research, and special functions.

• Routines for real symmetric discrete Fourier transforms with simplified interface. (NAG Library Chapter C06 Summation of Series)
• Routines for inserting coefficients to make working with the DWT functions easier. Also routines for the maximal overlap discrete wavelet transform (MODWT) and its inverse in one dimension, for time series analysis. (NAG Library Chapter C09 Wavelet Transforms)
• New routine for high dimensional quadrature using sparse grids. (NAG Library Chapter D01 Quadrature)
• Replacement for the general nonlinear boundary value problem solver using collocation. (NAG Library Chapter D02 Ordinary Differential Equations)
• Routine for the triangulation of a two-dimensional scattered grid, and routine for the barycentric interpolation on function values on a triangulated scattered grid. (NAG Library Chapter E01 Interpolation)
• Routine for minimax polynomial fitting of a set of data points. (NAG Library Chapter E02 Curve and Surface Fitting)
• New and improved algorithms are available for the matrix logarithm, the matrix square root, the matrix exponential and general matrix powers. Also routines for computing Fréchet derivatives. (NAG Library Chapter F01 Matrix Operations, Including Inversion)
• Routines for the solution of the real and complex quadratic eigenvalue problem, and a driver routine for calculating selected eigenvalues/vectors of symmetric sparse matrices. (NAG Library Chapter F02 Eigenvalues and Eigenvectors)
• Routines for recursive, explicitly blocked factorization and applying for general matrices and for triangular-pentagonal matrices, and routines for the complete CS decomposition of an orthogonal or unitary matrix. (NAG Library Chapter F08 Least Squares and Eigenvalue Problems (LAPACK))
• Routine for the bandwidth reduction of a sparse symmetric matrix by reverse Cuthill-McKee reordering. (NAG Library Chapter F11 Large Scale Linear Systems)
• Routine for scaled accumulated dot product (BLAS_DDOT). (NAG Library Chapter F16 Further Linear Algebra Support Routines)
• Routine for computing probabilities for the Dickey-Fuller unit root test. (NAG Library Chapter G01 Simple Calculations on Statistical Data)
• Additional nearest correlation matrix routine that allows the leading principal submatrix to be preserved. Also routines for performing Least Angle Regression (LARS), Least Absolute Shrinkage and Selection Operator (LASSO) and forward stagewise regression. (NAG Library Chapter G02 Correlation and Regression Analysis)
• Routines for generating training and validation datasets suitable for use in cross-validation. (NAG Library Chapter G05 Random Number Generators)
• Kernel density estimation using a Gaussian kernel. (NAG Library Chapter G10 Smoothing in Statistics)
• Routines for computing: the Dickey-Fuller unit root test statistic; applying the unscented Kalman filter to a nonlinear state-space model with additive noise; and change point analysis using the PELT algorithm or using binary segmentation. (NAG Library Chapter G13 Time Series Analysis)
• Routine for solving mixed integer nonlinear programming problems; optional settings via two option routines. Also routine for approximating solutions to the classical travelling salesman problem via simulated annealing. (NAG Library Chapter H Operations Research)
• Routines for evaluating the Gauss hypergeometric function for real arguments and for computing the European option price from Heston's stochastic volatility model with term structure. (NAG Library Chapter S Approximations of Special Functions)
• A chapter of routines for controlling the OpenMP environment. (NAG Library Chapter X06 OpenMP Utilities)