CRAN Task View: Numerical Mathematics

Maintainer:Hans W. Borchers, Robin Hankin, Serguei Sokol
Contact:hwb at mailbox.org
Version:2024-07-27
URL:https://CRAN.R-project.org/view=NumericalMathematics
Source:https://github.com/cran-task-views/NumericalMathematics/
Contributions:Suggestions and improvements for this task view are very welcome and can be made through issues or pull requests on GitHub or via e-mail to the maintainer address. For further details see the Contributing guide.
Citation:Hans W. Borchers, Robin Hankin, Serguei Sokol (2024). CRAN Task View: Numerical Mathematics. Version 2024-07-27. URL https://CRAN.R-project.org/view=NumericalMathematics.
Installation:The packages from this task view can be installed automatically using the ctv package. For example, ctv::install.views("NumericalMathematics", coreOnly = TRUE) installs all the core packages or ctv::update.views("NumericalMathematics") installs all packages that are not yet installed and up-to-date. See the CRAN Task View Initiative for more details.

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.

Contents

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 contact the maintainer, either via e-mail or by submitting an issue or pull request in the GitHub repository linked above.

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 and Fixed Points

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. For finding roots of univariate and multivariate functions see the following 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.

Multiprecision and Symbolic Calculations

Python and SAGE Interfaces

Python, through its modules ‘NumPy’, ‘SciPy’, ‘Matplotlib’, ‘SymPy’, and ‘pandas’, has elaborate and efficient numerical and graphical tools available.

SageMath is an open source mathematics system based on Python, allowing to run R functions, but also providing access to systems like Maxima, GAP, FLINT, and many more math programs. SageMath can be freely used through a Web interface at CoCalc .

MATLAB Octave Julia and other Interfaces

Interfaces to numerical computation software such as MATLAB (commercial) or Octave (free) will be important when solving difficult numerical problems. Unfortunately, at the moment there is no package allowing to call Octave functions from within R.

Julia is “a high-level, high-performance dynamic programming language for numerical computing”, which makes it interesting for optimization problems and other demanding scientific computations in R.

Java Math functions can be employed through the ‘rjava’ or ‘rscala’ interfaces. Then package commonsMath allows calling Java JAR files of the Apache Commons Mathematics Library, a specialized library for all aspects of numerics, optimization, and differential equations.

Please note that commercial programs such as MATLAB, Maple, or Mathematica have facilities to call R functions.

CRAN packages

Core:cubature, Matrix, numDeriv, PolynomF.
Regular:ADPF, akima, arrangements, BB, Bessel, bignum, Brobdingnag, bspline, calculus, caracas, Carlson, clifford, combinat, commonsMath, conicfit, contfrac, contFracR, daarem, Deriv, disordR, dual, EigenR, elliptic, expint, expm, fastGHQuad, feather, features, FixedPoint, fourierin, frab, freealg, freegroup, gaussquad, geigen, gmp, GramQuad, gsl, hypergeo, interp, irlba, itp, jack, jacobi, jordan, JuliaCall, JuliaConnectoR, ktsolve, lamW, logOfGamma, m2r, magic, MASS, matlab, matlib, matrixcalc, mbend, minimaxApprox, MonoPoly, mpoly, multipol, mvp, mvQuad, nleqslv, numbers, onion, optR, orthopolynom, Pade, partitions, permutations, polyCub, polyMatrix, polynom, pracma, primefactr, primes, PRIMME, qspray, QZ, R.matlab, rARPACK, Rcpp, RcppAlgos, RcppArmadillo, RcppBigIntAlgos, RcppEigen, RcppGSL, reticulate, rim, Rlinsolve, rmatio, Rmpfr, rmumps, RootsExtremaInflections, rootSolve, Rserve, RSpectra, Ryacas, sanic, schumaker, signal, SimplicialCubature, SparseGrid, SparseM, SphericalCubature, splines2, spray, SQUAREM, statmod, stinepack, stokes, svd, symengine, tripack, turboEM, VeryLargeIntegers, weyl, XR, XRJulia, XRPython, Zseq.

Related links

Other resources