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
133
votes
14 answers

How can I use numpy.correlate to do autocorrelation?

I need to do auto-correlation of a set of numbers, which as I understand it is just the correlation of the set with itself. I've tried it using numpy's correlate function, but I don't believe the result, as it almost always gives a vector where the…
Ben
  • 66,838
  • 37
  • 84
  • 108
133
votes
5 answers

Dealing with float precision in Javascript

I have a large amount of numeric values y in javascript. I want to group them by rounding them down to the nearest multiple of x and convert the result to a string. How do I get around the annoying floating point precision? For example: 0.2 +…
92
votes
1 answer

Is there special significance to 16331239353195370.0?

Using import numpy as np I've noticed that np.tan(np.pi/2) gives the number in the title and not np.inf 16331239353195370.0 I'm curious about this number. Is it related to some system machine precision parameter? Could I have calculated it from…
Aguy
  • 7,851
  • 5
  • 31
  • 58
73
votes
12 answers

Check if a varchar is a number (T-SQL)

Is there an easy way to figure out if a varchar is a number? Examples: abc123 --> no number 123 --> yes, its a number
grady
  • 12,281
  • 28
  • 71
  • 110
47
votes
3 answers

How do I obtain the machine epsilon in R?

Is there a constant that stores the machine epsilon in R?
xiaodai
  • 14,889
  • 18
  • 76
  • 140
35
votes
15 answers

Sampling a random subset from an array

What is a clean way of taking a random sample, without replacement from an array in javascript? So suppose there is an array x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] and I want to randomly sample 5 unique values; i.e. generate a random subset of…
Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
26
votes
6 answers

What's the numerically best way to calculate the average

what's the best way to calculate the average? With this question I want to know which algorithm for calculating the average is the best in a numerical sense. It should have the least rounding errors, should not be sensitive to over- or underflows…
Tobias Langner
  • 10,634
  • 6
  • 46
  • 76
25
votes
8 answers

Implementing the derivative in C/C++

How is the derivative of a f(x) typically calculated programmatically to ensure maximum accuracy? I am implementing the Newton-Raphson method, and it requires taking of the derivative of a function.
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
25
votes
1 answer

Fast algorithm to calculate Pi in parallel

I am starting to learn CUDA and I think calculating long digits of pi would be a nice, introductory project. I have already implemented the simple Monte Carlo method which is easily parallelize-able. I simply have each thread randomly generate…
tskuzzy
  • 35,812
  • 14
  • 73
  • 140
23
votes
12 answers

As Java is to Scala, C++ is to ...?

Although C++0x is quite an improvement to C++ (type inference, anonymous functions, and so on), I have to say that Scala seems even better. The thing is that Scala only runs on the JVM, although it seems like it can also run on top of C#. Ideally, I…
Marcus P S
  • 871
  • 10
  • 16
22
votes
2 answers

__builtin_prefetch, How much does it read?

I'm trying to optimize some C++ (RK4) by using __builtin_prefetch I can't figure out how to prefetch a whole structure. I don't understand how much of the const void *addr is read. I want to have the next values of from and to loaded. for (int i =…
Mikhail
  • 7,749
  • 11
  • 62
  • 136
19
votes
1 answer

sample random point in triangle

Suppose you have an arbitrary triangle with vertices A, B, and C. This paper (section 4.2) says that you can generate a random point, P, uniformly from within triangle ABC by the following convex combination of the vertices: P = (1 - sqrt(r1)) * A +…
dsg
  • 12,924
  • 21
  • 67
  • 111
19
votes
8 answers

How to find a binary logarithm very fast? (O(1) at best)

Is there any very fast method to find a binary logarithm of an integer number? For example, given a number x=52656145834278593348959013841835216159447547700274555627155488768 such algorithm must find y=log(x,2) which is 215. x is always a power of…
psihodelia
  • 29,566
  • 35
  • 108
  • 157
18
votes
5 answers

Making C code plot a graph automatically

I have written a program which writes a list of data to a '.dat' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code plot it automatically? My output is of the form: x-coord analytic …
JMzance
  • 1,704
  • 4
  • 30
  • 49
18
votes
2 answers

How can I plot the derivative of a graph in gnuplot?

I have a set of measurements of a variable over time. I have these measurements in a file called "results" with this format: # time sample 0 5 12 43 234 342 etc... I can easily plot this in gnuplot with: plot "results" Is there any…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
1
2 3
99 100