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
5
votes
0 answers

Statsmodels logistic regression convergence problems

I'm trying to run a logistic regression in statsmodels on a large design matrix (~200 columns). The features include a number of interactions, categorical features and semi-sparse (70%) integer features. Although my design matrix is not actually…
5
votes
2 answers

Is Python's epsilon value correct?

According to Wikipedia: Machine epsilon is defined as the smallest number that, when added to one, yields a result different from one In Python, epsilon can be found using sys.float_info.epsilon and returns a value equivalent to 2^-52. However, I…
Bull
  • 11,771
  • 9
  • 42
  • 53
5
votes
3 answers

Verlet Integration in Haskell

I am new to Haskell, and as an exercise I've been trying to implement some of the code (written in Mathematica) from Joel Franklin's book Computational Methods in Physics. I've written the following code to take a lambda expression (acceleration) as…
castle-bravo
  • 1,389
  • 15
  • 34
5
votes
1 answer

Fit a distribution to a Counter in scipy

I have a collections.Counter object with a count of the occurrences of different values like this: 1:193260 2:51794 3:19112 4:9250 5:6486 How can I fit a probability distribution to this data in scipy? scipy.stats.expon.fit() seems to want a list…
Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98
5
votes
2 answers

Avoiding numerical overflow when calculating the value AND gradient of the Logistic loss function

I am currently trying to implement a machine learning algorithm that involves the logistic loss function in MATLAB. Unfortunately, I am having some trouble due to numerical overflow. In general, for a given an input s, the value of the logistic…
5
votes
3 answers

Is log(a*b) always faster in Matlab than log(a) + log(b)?

Is log(a*b) always faster in Matlab than log(a) + log(b)? I tested for several inputs and it seems log(a*b) is faster. Can you more experienced guys give me some opinions on this? Maybe warnings that this might not always be the case, or…
user2381422
  • 5,645
  • 14
  • 42
  • 56
5
votes
4 answers

Signaling or catching 'nan' as they occur in computations in numerical code base in c++

We have numerical code written in C++. Rarely but under certain specific inputs, some of the computations result in an 'nan' value. Is there a standard or recommended method by which we can stop and alert the user when a certain numerical…
hAcKnRoCk
  • 1,118
  • 3
  • 16
  • 30
5
votes
1 answer

Find x in a^x = a (mod n)

I want to calculate am mod n, where n is a prime number, and m is very large. Rather doing this with binary power calculation, I'd like to find such x that ax = a (mod n) and then calculate a(m mod x) mod n. Obviously such x exists for any a,…
Grigor Gevorgyan
  • 6,753
  • 4
  • 35
  • 64
5
votes
1 answer

Using R to solve equations

How might I solve for the roots of an equation of the following form numerically in R: f(r)=r*c+1-B*c-exp(-M(B-r)) Where M, B and c are known constants. Thanks in advance.
2han12
  • 51
  • 1
  • 1
  • 2
5
votes
1 answer

Does D std lib include something like boost.fusion and boost.mpl?

I'm still evaluating if i should start using D for prototyping numerical code in physics. One thing that stops me is I like boost, specifically fusion and mpl. D is amazing for template meta-programming and i would think it can do mpl and fusion…
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
5
votes
1 answer

Matlab, integration of conservation laws

I was wondering if there are established robust libraries or FEX-like packages to deal with scalar conservation laws (say 1D) in matlab. I am currently dealing with 1D non-linear, non-local, conservation laws and the diffusive error of first order…
Acorbe
  • 8,367
  • 5
  • 37
  • 66
5
votes
3 answers

How to fit a curve by a series of segmented lines in Matlab?

I have a simple loglog curve as above. Is there some function in Matlab which can fit this curve by segmented lines and show the starting and end points of these line segments ? I have checked the curve fitting toolbox in matlab. They seems to do…
Cassie
  • 1,179
  • 6
  • 18
  • 30
5
votes
2 answers

Algorithm to calculate modified Bessel function of the first kind

Could you tell me a fast and accurate method to calcuate BesselK(mu,z), BesselI(mu,z), where mu is real number?
minhbsu
  • 113
  • 3
  • 10
5
votes
1 answer

unexpected results with specific rounding mode

First of all, sorry for the bad title :/ I'm trying to reproduce a paper's results on calculating the eigenvalues of a tridiagonal symmetric matrix. I'm determining some values 'upper and lower bounds' by rounding to plus and minus infinity,…
dx_mrt
  • 707
  • 7
  • 13
5
votes
1 answer

Avoiding weird homography values when normalizing

People familiar with Homographies will know that you have to normalize it dividing by any of the matrix components in order to keep homogeneous coordinates. An homography is a 3x3 matrix and it is usually normalized dividing by the element at…
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164