The NAG Library is a set of mathematical and statistical algorithms used by thousands around the world for the solution of numerical problems. Every release of the Library has included numerical code contributed by professionals working in industry and academia. These esteemed “Code Contributors” generously give their code to help others gain benefit from their expert algorithms. Each code donated is then documented, tested, maintained and supported by NAG experts and engineered to run on different software and hardware configurations. This Q&A looks into the code contribution process by interviewing eight individuals who have contributed code in order to gain their insights into the activity.

**Interviewees**

**Maurice Cox,**National Physical Laboratory, UK**Mike Croucher,**Research Software Engineer, University of Sheffield**Edvin Deadman,**NAG Accelerator Software Engineer and former University of Manchester KtP Associate**Fred Hickernell,**Professor, Illinois Institute of Technology**Rebecca Killick,**Lecturer in Statistics, University of Lancaster**Craig Lucas,**NAG Senior Technical Consultant**Christopher Mower,**Msc Student University of Manchester**Klaus Schittkowski,**Professor, University of Bayreuth

### Q: Tell us a little about how your relationship with the Numerical Algorithms Group (NAG) began, and how it has evolved to the present?

**Fred Hickernell**

Some years ago, my student and I had written an algorithm to generate scrambled digital nets, which are used to improve the efficiency of Monte Carlo calculations. We came into contact with NAG, and they agreed to adopt the algorithm into the NAG Library.

**Maurice Cox**

I was involved with the NAG Library since the early days and collaborated closely with Brian Ford, Jeremy du Croz, David Sayers, etc. In the 1980s, I made a number of contributions to the NAG Library: interpolation, curve and surface fitting and linear algebra in particular.

**Rebecca Killick **

My relationship with NAG began when they invited me to give a seminar at their offices following my submission to the takeAiM competition. During my visit they noted that they would like to include my work in a future release but that the current open source license I used prevented them from doing this. I subsequently gave them permission to use the code and have been encouraging people in my group to release their code to NAG ever since.

**Klaus Schittkowski**

I’ve known about NAG for 30+ years. Moreover, I got in contact with one of the early representatives of NAG and some authors of the nonlinear optimization codes of NAG (P. Gill. W. Murray, M. Saunders) during my stay at Stanford University. My ongoing research in developing optimization algorithms and software and, especially permanent cooperation with industrial companies from very different areas, lead to various contacts with NAG users.

### Q: Why do you/did you choose to contribute code to the NAG Library and how does it benefit you?

**Fred Hickernell**

I think that it is important for good code to be widely available. At the same time, testing and maintaining code is a big job. NAG is well-situated to do both.

**Maurice Cox**

I originally developed code for DASL, the NPL Data Approximation Subroutine Library, first of all in ALGOL and then Fortran. I decided to submit a number of items to the NAG Library, its stringent entry requirements benefited the software documentation and the test data sets immensely. That benefit ensued from the rigorous reviewing of my submissions by, mainly, Ian Gladwell. I used DASL a lot in my work, and when subroutines were embedded in the NAG Library, I used those as well or instead.

**Rebecca Killick**

I chose to contribute to NAG because I believe in making my work as widely available as possible. I distribute my code via R, but this isn’t used by everyone, so the opportunity to widen take up of my work by donating code to NAG is wonderful. There is no direct quantifiable benefit to me, but it may increase citation counts.

**Klaus Schittkowski**

NAG is widely known especially in academia, but also in industry. Software becoming part of NAG might help to make the software and the author more visible.

### Q: Could you talk a little about/describe the specific code/s that you have contributed to the Library?

**Fred Hickernell**

Digital nets can be thought of as highly stratified samples of the unit cube. Earlier versions of this algorithm — developed by others — provided purely deterministic samples. We implemented a random scrambling scheme — introduced by others — that preserves the high degree of stratification. Our code in the NAG Library can be used to efficiently price financial derivatives, for example.

**Maurice Cox**

I contributed subroutines for operating with polynomials in a Chebyshev basis: interpolation in 2-D, least squares fitting in 2-D and 3-D, the former with constraints, differentiation and integration of a polynomial, and evaluation of standard uncertainties associated with a fitted polynomial and its derivatives and integrals. I also contributed subroutines for operating with splines in a b-spline basis, including the spline counterparts of the polynomial routines above. I think a *tour de force *was spline surface fitting for scattered data, when I put considerable effort into a special form of regularization to impose smoothness on the fitted surface and to make the code run as efficiently as possible.

Today, the second effort would not be called for! I also contributed probably the first NAG Linear Algebra routines for dealing with structured systems, based on variable-bandwidth Cholesky decomposition.

**Rebecca Killick**

I have directly contributed the code for the PELT algorithm which detects changes in the underlying structure of a data set in a fast but exact way.

**Klaus Schittkowski**

The code MisQP (Mixed-integer sequential Quadratic Programming), which entered the NAG Library at Mark 25, is based on a completely new mathematical approach to solve nonlinear mixed-integer problems. Its development has been sponsored by shell over three years, since they found out that, for a large class of practical mixed-integer optimization problems, the existing algorithms are either not applicable (e.g. require relaxable integer variables, analytical model formulations, …) or are by far too expensive in terms of number of function evaluations, the main performance criterion in many engineering applications.

### Q: What do you see as the key benefit for the end user from accessing your methods via the NAG Library?

**Christopher Mower**

In applications such as finance one may wish to compute an approximate correlation matrix which can be potentially indefinite and, hence, not a valid correlation matrix. Usually, a nearest correlation matrix replaces the approximate, and it is often desirable to weight or fix some elements known to be accurate; however, this can be expensive to compute. The matrix computed via shrinking will be a valid correlation matrix but is not necessarily the nearest, and shrinking is able to fix and weight elements. The main benefit users of the NAG Library will see is a vast difference in speed between current nearest correlation matrix algorithms and shrinking; the shrinking method, even for large matrices, is computationally inexpensive compared to existing nearest correlation matrix algorithms.

**Fred Hickernell**

The code is highly reliable. The Library contains some of the best algorithms available.

**Maurice Cox**

Key benefits are robustness of the Chebyshev and b-spline bases, and the ability to have polynomial degrees when necessary in the hundreds and an unlimited number of spline knots. Backward error-analyses exist for most of my contributed code: the solution provided is the exact solution of a closely neighboring problem.

**Rebecca Killick**

Accessing my work via the NAG library gives it a ‘seal of approval’ and assures people that the code is accurate and correct.

**Klaus Schittkowski**

Optimization requires the computation of objective function and constraint function values. If the underlying application is complex and requires, e.g., the solution of ordinary or partial differential equations, FE analysis, or any other dynamic systems, and if NAG software is applied for the numerical evaluation of these systems, it is then much easier to call just another NAG routine than installing an external solver.

### Q: How can NAG ensure customers and the community continue to benefit from code contributions such as yours?

**Edvin Deadman**

The key is to continue our good relations and collaborations with academic institutions, as this is ultimately where most algorithms originate. It is clear how much NAG gets out of such collaborations. We need to ensure that academic institutions themselves continue to benefit from working with NAG.

**Craig Lucas **—** speaking of his role in the Nearest Correlation Matrix team at NAG**

Build relationships with research students through attending meetings, conferences, etc. Foster relationships with particular research groups. Make collaboration with NAG an obvious next step when people are developing algorithms.

**Christopher Mower**

The best way NAG can continue to benefit its customers and communities, I feel, is to continue to sponsor Msc and Ph.D. projects.

**Maurice Cox**

At NPL, being a standards laboratory, traceability and provenance are key in our work. I consider that NAG’s trademark is reliability, which should always be emphasized at every opportunity.

**Rebecca Killick **

NAG should have a campaign to directly ask researchers for their code. I never would have thought to donate code until I was asked.

**Klaus Schittkowski**

Difficult. I mentioned before that many years ago, I got in contact with a NAG representative during a conference. Maybe, a more visible scientific representation of NAG could help, e.g., by motivating authors to cite NAG more significantly and by organizing more NAG sessions.

### Q: Do you think that producing good quality software is recognized as highly as academic research and papers are?

**Edvin Deadman**

Producing good software is increasingly becoming part of academic research life. A huge number of academic papers, particularly in applied mathematics, physical sciences and engineering, go hand-in-hand with new pieces of software. Peers need access to this software in order to verify and expand on the results. Therefore, it is now quite usual to see software, written as part of a research project, made available on, for example, GitHub. in addition, the usability and documentation for such software is improving.

That said, I do not think producing good software is recognized as highly as producing papers yet, but this is certainly changing. For example, several UK universities now have recognized ‘research software engineer’ positions.

**Fred Hickernell**

It should be, but it may not be yet.

**Rebecca Killick**

No, even when you write a paper about your software and get lots of citations, it isn’t treated as highly as “proper” research.

**Klaus Schittkowski**

Depends on the scientific tradition and visibility in the public. The answer is definitely yes in the U.S., e.g., and definitely no or maybe in Europe.

### Q: Do you think that students have the right skills to write quality software? And if they don’t, how does this affect the community now and in the future?

**Craig Lucas**

No, in general. Students are driven by results. They write a code that will give them the right answer, in that it demonstrates a theory etc. They have probably thought very little about how others would use their code. How well will it behave on a similar problem, for example? They are unlikely to have written test code or provided adequate documentation. They will be given no credit for writing the software for their research degree, so this is understandable. They may be contributing to a department or community code. They may have quality control in place, or they may not. The code will grow organically but not coherently. The student is unlikely to have training in code optimization and the tools to identify and fix inefficient aspects.

**Fred Hickernell**

They do not. This is something that we are trying to address at my institution, but it needs to be addressed by the whole computational science and engineering community. Computational mathematicians understand how to prove that algorithms work, but they do not know how to implement them. Computer scientists may know how to write quality software, but they do not understand mathematical software well.

**Christopher Mower**

As an Msc student who has written quality software that has been implemented in the NAG Library, I am evidence that students do have the right skills.

**Rebecca Killick**

Undergraduate maths/stats students don’t see the value in being able to code, they see this as a computer scientist’s job. However, if they go on to get a job using their maths/stats skills, they need to be able to code. Their code often doesn’t have to be fast or perfect, as they will be using the output to produce reports, but they should be able to code for their own use. Sadly, they don’t see the value.

Ph.D. students appear to see the value in being able to write good code, and I personally encourage all my students to make their code available to the world. Hence, it would be useful for them to be able to write quality software, but the student needs to have the interest and ability for it to be useful to them.

Ultimately, if you are able to translate your work into a piece of software that other people can use, your work will live on. You can have the best theory and results in the world, but unless people can use it, it will be forgotten.

**Klaus Schittkowski**

The answer to the first question is no, in general. It is extremely difficult to teach the required skills in special courses for many reasons. However, students have to write theses (diploma, Master, Ph.D., …), and they learn from the supervisor or other available sources how to write qualified numerical software. But the supervisor has to possess the experience and the skills to write quality software, which is not available in general. However, I am quite sure that good students will easily pick up the required skills in a very short time if this turns out to be important.