The Best Numerical Library Comes to Python - NAG For Python
Written by Mike James   
Thursday, 27 September 2018

You might think that calling "NAG" the best numerical library is hype, but it has impeccable academic credentials and it has been around for a long time. The fact that NAG is taking Python seriously is as much a validation of the importance of the language as a numerical tool as anything else.

It is a bit too strong to say that adding it to the list of languages that NAG supports is a validation that Python has "come of age", but it does put it up there with the classics C, Fortran, Java etc.


The NAG - Numerical Algorithms Group - library has been available since the days of the mainframe and it has routines for doing all of the classical number crunching tasks and a lot of very new things. The key feature of the NAG library is that it is reliable because it is put together by numerical analysts who you can presume know what they are doing. The NAG library isn't free, although there is a trial offer, and not everyone will be able to justify it.

To explain the NAG library would be to descend into a long list of what is available and you can see this on its web site. The main things to understand are that as well as a strong collection of statistical routines, some users are under the impression that NAG is "just" a stats package and hence some sort of alternative to using R say. It has a lot of core stats routines - Stepwise Regression, LASSO, LARS, Ridge regression, Time Series, mixture models, quantiles, random number generators and so on. However don't think that the range of algorithms is limited to just the "headline" algorithyms. There are hundreds of routines from a very wide range of areas. To name just a few: root finding, wavelet transformation, integration, ODEs, PDEs and of course a complete set of linear algebra routines and linear models. It would be fair to describe the majority as "state of the art".

Of course there are some new features: 

  • Derivative Free Optimization for Data Fitting
  • Struve Functions
  • NAG Optimization Modelling Suite
  • Interior Point Method for Nonlinear Optimization
  • Semidefinite Programming (SDP)
  • Nearest Correlation Matrix
  • Three Body Problem using High-Order Runge-Kutta Interpolation 

I have to admit that I have no idea what a Struve function is but no doubt someone out there is relieved to find that it has at last been included in the NAG library. I, wearing my physicist hat, am intrigued by the inclusion of a Runge-Kutta numerical approach to the three body problem and wonder if I could make some interesting graphics using it.



I started using the NAG library in Fortran many versions ago and you can still do so as well as in C, C++, Java, .NET, and even Excel. When you have run out of steam using off the shelf routines you can use NAG from your favourite language.

Adding Python to the list is a mark of how important the language has become for science and numerical work.The new Python interface works with Python 2.7 to 3.7 and it uses NumPy. All of the routines work with native Python data structures and integration seems to be good. I couldn't find any mention of using it with Jupiter notebooks, but I can't see why not.



More Information

NAG Library for Python


Related Articles

NAG Routines for Supercomputers

NAG for Intel Xeon Phi Coprocessor

NAG Updates C Library

New number crunching library - NAG C Mark 9

.NET Version of Mathematical Algorithms

How To Number Crunch - NAG for .NET


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook or Linkedin.



Guido van Rossum Joins Microsoft

Creator of Python, Guido van Rossum, has joined Microsoft as a Distinguished Engineer in the Developer Division. His stated aim is to make Python better. We can't wait to find out what that results in [ ... ]

IBM Announces Code Spot Challenge For Wildfires

IBM has announced the Code Spot Challenge on Wildfires. The objective will be to forecast wildfires in Australia during the month of February 2021, with the aim of improving and gaining better underst [ ... ]

More News





or email your comment to:

Last Updated ( Thursday, 11 October 2018 )