Questions tagged [numerical-methods]

Algorithms which solve mathematical problems by means of numerical approximation (as opposed to symbolic computation).

Numerical methods include the study of algorithms that use numerical approximation (as opposed to general symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). Numerical methods naturally find applications in all fields of science and engineering, and include implementations of many important aspects of computation including: solving ordinary and partial differential equations, numerical linear algebra, stochastic differential equations, Markov chains, and so forth.

Numerical methods use several approaches to calculate observables. For example, iterative methods that form successive approximations that converge to the exact solution only in a limit. A convergence test, often involving the residual, is specified in order to decide when a sufficiently accurate solution has (hopefully) been found. Examples include Newton's method, the bisection method, and Jacobi iteration. Another example is the use of discretization, a procedure that is used when continuous problems must sometimes be replaced by a discrete problem whose solution is known to approximate that of the continuous problem.

The field of numerical methods includes many sub-disciplines. Some of the major ones are:

  • Computing values of functions

  • Interpolation, extrapolation, and regression

  • Solving equations and systems of equations

  • Solving eigenvalue or singular value problems

  • Optimization

  • Evaluating integrals

  • Differential equations

2104 questions
17
votes
1 answer

How to call UMFPACK as MATLAB does?

The problem I wish to solve a general system of linear equations A*x=b. The m-by-m matrix is sparse, real, square, somewhat poorly-conditioned, non-symmetric, but it is singular (rank(A)==m-1) because x is known only up to an additive constant. I…
jvriesem
  • 1,859
  • 3
  • 18
  • 40
17
votes
2 answers

How can I increase the number of subdivisions for functions in `scipy.integrate.dblquad`?

I'm using scipy.integrate.dblquad, and I get this error: UserWarning: The maximum number of subdivisions (50) has been achieved. If increasing the limit yields no improvement ... I want to increase this limit to see if the integral is…
Dan
  • 12,157
  • 12
  • 50
  • 84
16
votes
9 answers

Generating digits of square root of 2

I want to generate the digits of the square root of two to 3 million digits. I am aware of Newton-Raphson but I don't have much clue how to implement it in C or C++ due to lack of biginteger support. Can somebody point me in the right…
Quixotic
  • 2,424
  • 7
  • 36
  • 58
16
votes
1 answer

Is boost::math::sinc_pi unnecessarily complicated?

This is not a question about template hacks or dealing with compiler quirks. I understand why the Boost libraries are the way they are. This is about the actual algorithm used for the sinc_pi function in the Boost math library. The function sinc(x)…
16
votes
2 answers

What's the best way to calculate a numerical derivative in MATLAB?

(Note: This is intended to be a community Wiki.) Suppose I have a set of points xi = {x0,x1,x2,...xn} and corresponding function values fi = f(xi) = {f0,f1,f2,...,fn}, where f(x) is, in general, an unknown function. (In some situations, we might…
jvriesem
  • 1,859
  • 3
  • 18
  • 40
15
votes
5 answers

Where do I find the machine epsilon in C#?

The machine epsilon is canonically defined as the smallest number which added to one, gives a result different from one. There is a Double.Epsilon but the name is very misleading: it is the smallest (denormalized) Double value representable, and…
Alexandre C.
  • 55,948
  • 11
  • 128
  • 197
15
votes
2 answers

is there a c++ library for ordinary differential equation (ODE) solvers?

More specifically, i'm interested in 8th order Dormand-Prince embedded method, it's based on Runge-Kutta, and stiff equations. I use Numerical Recipes 3 but i often have trouble compiling their libraries. I'd like to know of alternatives.
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
15
votes
5 answers

efficiently determining if a polynomial has a root in the interval [0,T]

I have polynomials of nontrivial degree (4+) and need to robustly and efficiently determine whether or not they have a root in the interval [0,T]. The precise location or number of roots don't concern me, I just need to know if there is at least…
user168715
  • 5,469
  • 1
  • 31
  • 42
15
votes
4 answers

argsort for a multidimensional ndarray

I'm trying to get the indices to sort a multidimensional array by the last axis, e.g. >>> a = np.array([[3,1,2],[8,9,2]]) And I'd like indices i such that, >>> a[i] array([[1, 2, 3], [2, 8, 9]]) Based on the documentation of numpy.argsort I…
DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
15
votes
4 answers

Numerical ODE solving in Python

How do I numerically solve an ODE in Python? Consider \ddot{u}(\phi) = -u + \sqrt{u} with the following conditions u(0) = 1.49907 and \dot{u}(0) = 0 with the constraint 0 <= \phi <= 7\pi. Then finally, I want to produce a parametric plot…
dustin
  • 4,309
  • 12
  • 57
  • 79
14
votes
4 answers

Which numerical library to use for porting from Matlab to C++?

I am currently prototyping some algorithms in Matlab that rely on matrix, DSP, statistics and image analysis functionality. Some examples of what I may need: eigenvectors convolution in 2D and 3D FFT Short Time Fourier Transform Hilbert…
Andy
  • 3,251
  • 4
  • 32
  • 53
14
votes
2 answers

Solving PDE with implicit euler in python - incorrect output

I will try and explain exactly what's going on and my issue. This is a bit mathy and SO doesn't support latex, so sadly I had to resort to images. I hope that's okay. I don't know why it's inverted, sorry about that. At any rate, this is a linear…
Oria Gruber
  • 1,513
  • 2
  • 22
  • 44
14
votes
7 answers

Automatic differentiation library in Scheme / Common Lisp / Clojure

I've heard that one of McCarthy's original motivations for inventing Lisp was to write a system for automatic differentiation. Despite this, my Google searches haven't yielded any libraries/macros for doing this. Are there any Scheme/Common…
14
votes
2 answers

N body simulation in C++

I am trying to implement an OpenMP version of the 2-dimensional n-body simulation. But there is a problem: I assume each particle's initial velocity and acceleration are zero. When the particles first gather together, they would disperse out in a…
user3558391
  • 161
  • 2
  • 7
14
votes
1 answer

Calculate eigenvalues/eigenvectors of hundreds of small matrices using CUDA

I have a question on the eigen-decomposition of hundreds of small matrices using CUDA. I need to calculate the eigenvalues and eigenvectors of hundreds (e.g. 500) of small (64-by-64) real symmetric matrices concurrently. I tried to implement it by…
Yifei Huang
  • 141
  • 1
  • 3