CRAN Task View: Numerical Mathematics

Maintainer:Hans W. Borchers
Contact:hwb at mailbox.org
Version:2018-02-12
URL:https://CRAN.R-project.org/view=NumericalMathematics

This task view on numerical mathematics lists R packages and functions that are useful for solving numerical problems in linear algebra and analysis. It shows that R is a viable computing environment for implementing and applying numerical methods, also outside the realm of statistics.

The task view will not cover differential equations, optimization problems and solvers, or packages and functions operating on times series, because all these topics are treated extensively in the corresponding task views DifferentialEquations, Optimization, and TimeSeries. All these task views together will provide a good selection of what is available in R for the area of numerical mathematics. The HighPerformanceComputing task view with its many links for parallel computing may also be of interest.

The task view has been created to provide an overview of the topic. If some packages are missing or certain topics in numerical math should be treated in more detail, please let the maintainer know.

Numerical Linear Algebra

As statistics is based to a large extent on linear algebra, many numerical linear algebra routines are present in R, and some only implicitly. Examples of explicitly available functions are vector and matrix operations, matrix (QR) decompositions, solving linear equations, eigenvalues/-vectors, singular value decomposition, or least-squares approximation.

Special Functions

Many special mathematical functions are present in R, especially logarithms and exponentials, trigonometric and hyperbolic functions, or Bessel and Gamma functions. Many more special functions are available in contributed packages.

Polynomials

Function polyroot() in base R determines all zeros of a polynomial, based on the Jenkins-Traub algorithm. Linear regression function lm() can perform polynomial fitting when using poly() in the model formula (with option raw = TRUE).

Differentiation and Integration

D() and deriv() in base R compute derivatives of simple expressions symbolically. Function integrate() implements an approach for numerically integrating univariate functions in R. It applies adaptive Gauss-Kronrod quadrature and can handle singularities and unbounded domains to a certain extent.

Interpolation and Approximation

Base R provides functions approx() for constant and linear interpolation, and spline() for cubic (Hermite) spline interpolation, while smooth.spline() performs cubic spline approximation. Base package splines creates periodic interpolation splines in function periodicSpline().

Root Finding

uniroot(), implementing the Brent-Decker algorithm, is the basic routine in R to find roots of univariate functions. There are implementations of the bisection algorithm in several contributed packages. For root finding with higher precision there is function unirootR() in the multi-precision package Rmpfr. And for finding roots of multivariate functions see the following two packages:

Discrete Mathematics and Number Theory

Not so many functions are available for computational number theory. Note that integers in double precision can be represented exactly up to 2^53 - 1, above that limit a multi-precision package such as gmp is needed, see below.

Multi-Precision Arithmetic and Symbolic Mathematics

MATLAB, Octave, Julia, and Python Interfaces

Interfaces to numerical computation software such as MATLAB (commercial) or Octave (free) will be important when solving difficult numerical problems. (Please note that the commercial programs SAS and Mathematica do have facilities to call R functions.)

Python, through its modules 'NumPy', 'SciPy', 'Matplotlib', 'SymPy', and 'pandas', has elaborate and efficient numerical and graphical tools available. And Julia is "a high-level, high-performance dynamic programming language for numerical computing", which makes it interesting for optimization problems and demanding scientific computations in R.

CRAN packages:

Related links: