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
9
votes
2 answers

e^x without math.h

I'm trying to find ex without using math.h. My code gives wrong anwsers when x is bigger or lower than ~±20. I tried to change all double types to long double types, but it gave some trash on input. My code is: #include double…
user17221096
9
votes
5 answers

How do I calculate the "difference" between two sequences of points?

I have two sequences of length n and m. Each is a sequence of points of the form (x,y) and represent curves in an image. I need to find how different (or similar) these sequences are given that fact that one sequence is likely longer than the other…
WanderingPhd
  • 189
  • 1
  • 9
9
votes
1 answer

How can you implement Householder based QR decomposition in Python?

I'm currently trying to implement the Householder based QR decomposition for rectangular matrices as described in http://eprints.ma.man.ac.uk/1192/1/qrupdating_12nov08.pdf (pages 3, 4, 5). Apparently I got some of the pseudocode wrong though, since…
9
votes
4 answers

Minimize rounding error when dividing by integers

I am attempting to form a double precision floating point number (64-bit) by taking the ratio of one product of integers divided by another product of integers. I wish to do so in a way that reduces the rounding error. I am familiar with Kahan…
Paul Chernoch
  • 5,275
  • 3
  • 52
  • 73
9
votes
7 answers

Multivariate Bisection Method

I need an algorithm to perform a 2D bisection method for solving a 2x2 non-linear problem. Example: two equations f(x,y)=0 and g(x,y)=0 which I want to solve simultaneously. I am very familiar with the 1D bisection ( as well as other numerical…
9
votes
7 answers

Lisp, OCaml or what for Runge Kutta?

Which language would you propose for solving a system with: first order differential equations complex variables N-dimensions using 4th order Runge Kutta or the like. Speed matters a lot but would sacrifice for: Elegant (clean and short)…
Eelvex
  • 8,975
  • 26
  • 42
9
votes
2 answers

Newton Raphson hybrid algorithm not reaching a solution

Brief explanation of the problem: I use Newton Raphson algorithm for root finding in polynomials and doesn't work in some cases. why? I took from "numerical recipes in c++" a Newton Raphson hybrid algorithm, which bisects in case New-Raph is not…
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
9
votes
4 answers

Fast gradient-descent implementation in a C++ library?

I'm looking to run a gradient descent optimization to minimize the cost of an instantiation of variables. My program is very computationally expensive, so I'm looking for a popular library with a fast implementation of GD. What is the recommended…
Jim
  • 4,509
  • 16
  • 50
  • 80
8
votes
4 answers

Is there a numerically optimal order of matrix multiplication?

TL;DR: The question is about multiplication ACCURACY I have to multiply matrices A (100x8000), B (8000x27) and C (27x1). Since matrices B and C are constant and A is variable, I prefer to calculate it as: ABC = np.dot(A, np.dot(B, C)). However I…
8
votes
1 answer

Exact value of a floating-point number as a rational

I'm looking for a method to convert the exact value of a floating-point number to a rational quotient of two integers, i.e. a / b, where b is not larger than a specified maximum denominator b_max. If satisfying the condition b <= b_max is…
8
votes
1 answer

How does odeint() from scypy python module work?

I am a physics student interested in solving ODEs numerically. I usually write my own solvers in C using Runge–Kutta methods. I recently learned Python, and I used SciPy’s odeint function to solve ODEs. But I am worried about how the function…
8
votes
1 answer

Solving heat equation with python (NumPy)

I solve the heat equation for a metal rod as one end is kept at 100 °C and the other at 0 °C as import numpy as np import matplotlib.pyplot as plt dt = 0.0005 dy = 0.0005 k = 10**(-4) y_max = 0.04 t_max = 1 T0 = 100 def…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
8
votes
2 answers

What's wrong with my GMRES implementation?

I'm trying to implement GMRES in Jupyter Notebook, which is (in case you don't know): This is my code: import numpy as np def GMRes(A, b, x0, e, nmax_iter, restart=None): r = b - np.asarray(np.dot(A, x0)).reshape(-1) x = [] q = [0] *…
Patricio Sard
  • 2,092
  • 3
  • 22
  • 52
8
votes
3 answers

The time-corrected Verlet numerical integration formula

There is a commonly used verlet-integration formula on the web by Johnathan Dummer, called Time-Corrected Verlet. However I've read several forum posts, that people get weird or unexpected results with it in certain conditions. Formula by Johnathan…
8
votes
2 answers

Implementation of generalized hypergeometric function pFq

Is there an implementation callable from C or C++ that allows the evaluation of the generalized hypergeometric function pFq(a1,...,ap; b1,...,bp; x)? I tried GSL and Boost, but I don't think the generalized function is available in either of those…
a06e
  • 18,594
  • 33
  • 93
  • 169