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
13
votes
6 answers

Numerical library for Scala

I'm looking for a library to do numerical computing in Scala (or Java, although something that can use scala functions would be way nicer!) with at least the following capabilities: L-BFGS Minimizers (Powell, QuasiNewton, ...) Numerical…
em70
  • 6,088
  • 6
  • 48
  • 80
13
votes
2 answers

Bezier Cubic Curves: moving with uniform acceleration

Let's say I have a Bezier curve B(u), if I increment u parameter at a constant rate I don't obtain a costant speed movement along the curve, because the relation between u parameter and the point obtained evaluating the curve is not linear. I've…
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
12
votes
2 answers

Numerically stable method for solving quadratic equations

Using floating point, It is known that the quadratic formula does not work well for b^2>>4ac, because it will produce a loss of significance, as it is explained here. I am asked to find a better way to solve quadratic equations, I know there is…
John Keeper
  • 245
  • 2
  • 7
12
votes
2 answers

Why are structs so much faster than classes for this specific case?

I have three cases to test the relative performance of classes, classes with inheritence and structs. These are to be used for tight loops so performance counts. Dot products are used as part of many algorithms in 2D and 3D geometry and I have run…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
12
votes
3 answers

how can I evaluate the derivative of a spline function in R?

R can generate a spline function using splinefun() in the splines library. However, I need to evaluate this function at its first and second derivatives. Is there a way to do this? for example library(splines) x <- 1:10 y <- sin(pi/x) #just an…
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
12
votes
1 answer

Is numpy.sum implemented in such a way that numerical errors are avoided?

It is well known that adding up numbers can result in numerical errors (for example, if the first number is really large, whereas there are many other small numbers). This can be solved adding up the numbers in a non straight-forward way. See for…
12
votes
1 answer

numpy gradient function and numerical derivatives

The array the numpy.gradient function returns depends on the number of data-points/spacing of the data-points. Is this expected behaviour? For example: y = lambda x: x x1 = np.arange(0,10,1) x2 = np.arange(0,10,0.1) x3 =…
user1654183
  • 4,375
  • 6
  • 26
  • 33
11
votes
1 answer

Recursive arc-length reparameterization of an arbitrary curve

I have a 3D parametric curve defined as P(t) = [x(t), y(t), z(t)]. I'm looking for a function to reparametrize this curve in terms of arc-length. I'm using OpenSCAD, which is a declarative language with no variables (constants only), so the solution…
11
votes
4 answers

How to get binary representation of floating-point number in PHP?

Is there any way to get the binary representation of a floating point number in PHP? Something like Java's Double.doubleToRawLongBits(). Given a positive floating point number, I'd like to get the largest representable floating-point number which is…
Jenni
  • 1,668
  • 4
  • 20
  • 28
11
votes
6 answers

Generating Full Period/Full Cycle Random Numbers or Permutations Similar to LCG but without odd/even

I wish to generate psuedo-random numbers/permutations that 'occupy' a full period or full cycle within a range. Usually an 'Linear Congruential Generator' (LCG) can be used to generate such sequences, using a formula such as: X = (a*Xs+c) Mod…
andora
  • 1,326
  • 1
  • 13
  • 23
11
votes
6 answers

incremental way of counting quantiles for large set of data

I need to count the quantiles for a large set of data. Let's assume we can get the data only through some portions (i.e. one row of a large matrix). To count the Q3 quantile one need to get all the portions of the data and store it somewhere, then…
Gacek
  • 10,184
  • 9
  • 54
  • 87
11
votes
3 answers

Robust polygon normal calculation

is there a good robust algorithm to calculate normal vector of a convex polygon (in 3D, of course)? For triangles, it is easy: one takes two of the triangle's edges and calculates the cross product: vec3 u = point[0] - point[1], v = point[0] -…
the swine
  • 10,713
  • 7
  • 58
  • 100
11
votes
2 answers

Vertical line fit using polyfit

Its just a basic question. I am fitting lines to scatter points using polyfit. I have some cases where my scatter points have same X values and polyfit cant fit a line to it. There has to be something that can handle this situation. After all, its…
Naresh
  • 633
  • 1
  • 7
  • 26
10
votes
1 answer

log(1+x) is to log1p as log(1-x) is to?

provides a more accurate method for computing log(1+x) for doubles. Is there a similarly precise manner for computing log(1-x)? The reason I ask is because I'm trying to do some work in log-space for greater precision (I'm mostly…
user
  • 7,123
  • 7
  • 48
  • 90
10
votes
3 answers

log-sum-exp trick why not recursive

I have been researching the log-sum-exp problem. I have a list of numbers stored as logarithms which I would like to sum and store in a logarithm. the naive algorithm is def naive(listOfLogs): return math.log10(sum(10**x for x in…
Jacob
  • 1,423
  • 16
  • 29