Questions tagged [precision]

Issues related to the representation of numerical quantities in a finite representation in a given base differing from their exact mathematical value.

Filter by
Sorted by
Tagged with
28 votes
6 answers
6k views

How can the gravitational n-body problem be solved in parallel?

How can the gravitational n-body problem be solved numerically in parallel? Is precision-complexity tradeoff possible? How does precision influence the quality of the model?
  • 383
28 votes
4 answers
6k views

Is half precision supported by modern architecture?

I am new to computer science and I was wondering whether half precision is supported by modern architecture in the same way as single or double precision is. I thought the 2008 revision of IEEE-754 ...
26 votes
3 answers
4k views

What's the state-of-the-art in highly oscillatory integral computation?

What's the state-of-the-art in the approximation of highly oscillatory integrals in both one dimension and higher dimensions to arbitrary precision?
18 votes
2 answers
4k views

Numerically stable way of computing angles between vectors

When applying the classical formula for the angle between two vectors: $$\alpha = \arccos \frac{\mathbf{v_1} \cdot \mathbf{v_2}}{\|\mathbf{v_1}\| \|\mathbf{v_2}\|}$$ one finds that, for very small/...
  • 1,145
17 votes
1 answer
3k views

How can I avoid catastrophic cancellation?

I have the following formula that I need to rewrite in order to avoid catastrophic cancellation. $$y =\sqrt{\frac{1}{2}\left(1-\sqrt{1-x^{2}}\right)}$$ As $x$ becomes smaller, $\sqrt{1-x^{2}}$ ...
  • 273
14 votes
3 answers
5k views

Single versus double floating-point precision

Single precision floating point numbers take up half the memory and on modern machines (even on GPUs it seems) operations can be done with them at almost twice the speed compared to double precision. ...
  • 1,300
14 votes
1 answer
928 views

Scientific computing with Python with modern GPUs with double precision

Has anyone here used double precision scientific computing with new generation (e.g. K20) GPUs through Python? I know that this technology is rapidly evolving, but what is the best way to do this ...
  • 516
13 votes
2 answers
1k views

Why can ill-conditioned linear systems be solved precisely?

According to the answer here, large condition number (for linear system solving) decreases the guaranteed number of correct digits in the floating point solution. Higher order differentiation matrices ...
12 votes
2 answers
996 views

Higher precision floating-point arithmetic in numerical PDE

I have the impression, from very different resources and talks with researches, that there is a growing demand for high precision computations in numerical partial differential equations. Here, high ...
  • 3,570
12 votes
5 answers
2k views

Numerical derivative and finite difference coefficients: any update of the Fornberg method?

When one want to compute numerical derivatives, the method presented by Bengt Fornberg here (and reported here) is very convenient (both precise and simple to implement). As the original paper date ...
  • 323
10 votes
2 answers
816 views

Diagonalization of Dense Ill Conditioned Matrices

I am trying to diagonalize some dense, ill-conditioned matrices. In machine precision, results are inaccurate (returning negative eigenvalues, eigenvectors do not have the expected symmetries). I ...
  • 101
9 votes
4 answers
439 views

Small, unpredictable results in runs of a deterministic model

I have a sizable model (~5000 lines) written in C. It is a serial program, with no random number generation anywhere. It makes use of the FFTW library for functions using FFT - I do not know the ...
9 votes
2 answers
264 views

Representing Eisenstein numbers without floats

I have a project where I need to use quadratic fields Specifically numbers of the form $a + b \sqrt{-3}$ with $a,b \in \mathbb{Q}$. For example here are the prime numbers in Eisenstein integers: I ...
9 votes
0 answers
496 views

Updating matrix diagonal with Woodbury matrix identity and maintaining numerical accuracy

I have a dense matrix A and its corresponding inverse $A^{-1}$. The Woodbury matrix identity states: $$ (A + UCV)^{-1} = A^{-1} - A^{-1}U(C^{-1} + VA^{-1}U)^{-1}VA^{-1} $$ I wish to perform small ...
  • 1,300
8 votes
6 answers
799 views

What algorithm for solving a set of stiff ODEs would be easiest to port to high precision floating point arithmetic?

I want to solve a relatively small system of stiff ODEs (< 10 first-order equations) using high precision floating point arithmetic (using MPFR or alike). What would be the easiest algorithm to ...
  • 6,109
8 votes
2 answers
149 views

How can I numerically solve an ODE to $N$ provably correct digits?

Suppose we have an initial value problem of the form $$ \frac{\mathrm{d} \mathbf{x}}{\mathrm{d} t} = f(\mathbf{x}) \qquad \mathbf{x}(0) = \mathbf{x}_0 $$ where $\mathbf{x}_0 \in \mathbb{R}^n$ is known ...
8 votes
3 answers
2k views

Need for quad precision in scientific computing?

Even if quad precision is not directly supported by most CPUs, many Compilers (GNU, Intel) support them. Also some software packages allow to compile with quad precision, e.g. PETSc. But is there ...
  • 800
7 votes
4 answers
915 views

Why is $\exp(\ln(x))-x\neq0$ in floating point arithmetic?

Analytically, the expression $$\exp(\ln(x))-x \enspace,$$ should give 0. However, in Matlab, it does not. x = linspace(1, 10, 10); exp(log(x)) - x; for $x \in ...
  • 309
7 votes
1 answer
307 views

Why should I renormalize physical variables?

I am working with legacy physical codes and I develop new ones based on the output of them. They all use their own internal normalization of variables (for example all distances are divided by the ...
  • 323
7 votes
4 answers
3k views

computing the determinant of a dense nonsymmetric 100x100 matrix having very big and very small eigenvalues

The motivation for my question is the following: in one of Project Euler questions there is a need to count the spanning trees of a rectangular grid graph of dimension 100x500. By the Matrix-Tree ...
  • 223
7 votes
2 answers
123 views

What good are hard-sphere event-driven molecular dynamics simulations in the face of chaos?

Simple hard-sphere dynamical systems can exhibit chaotic dynamics. Due to finite-precision arithmetic when implemented on a computer, the presence of chaos implies that for a given set of initial data,...
7 votes
1 answer
578 views

What is the numerical difference between abs(z)^2 and z x z*, where z is a complex number

I am doing research in electromagnetics (a branch of physics) and I deal with complex numbers in my computing tasks (I use MATLAB). Let's say $z$ is a complex number. To calculate the square of the ...
  • 73
7 votes
3 answers
548 views

Does there exist an arbitrary-precision convex optimization solver?

I have a relatively simple convex optimization problem that involves less than 100 variables but contains a terribly ill-conditioned matrix. I have tried CVX and CPLEX; even though both can typically ...
7 votes
1 answer
229 views

Numerically stable and fast sum of last K elements in sequence

Suppose I have a long, possibly infinite, sequence $x := [x_1, x_2, ...]$, and I want to use it to compute another sequence $y:=[y_1, y_2, ...]$ where each element is the sum of the last K elements of ...
  • 171
7 votes
1 answer
184 views

Stable computation of ratio of sums of large numbers

I have two sets of large positive numbers $a_1,\ldots,a_n$ and $b_1,\ldots,b_n$. By 'large' I mean of the order of $10^{10}$. I want to calculate the ratio $$R = \frac{a_1 - a_2 + \cdots +(-1)^{n+1}...
6 votes
2 answers
2k views

Determine the step size in a differential equation numerical solver

How can we define the precision we require in a numerical differential equation solver? What is it that I have to optimize to know? And how do I know that I'm at a sufficient time-step value? For ...
6 votes
2 answers
4k views

Are there tasks in machine learning which require double precision floating points?

Double-precision calculations are significantly slower or more expensive than single-precision calculations. For example, the NVidia Tesla which performs well on doubles is much more expensive then ...
6 votes
1 answer
243 views

Is it possible to proof a-b+b = a for all double floating-point numbers?

I want to know whether the equation : a-b+b = a is always true for a, b belongs to double precision floating-point number and |a|>=|b|. If the equation is true, how can I proof it? If not, what ...
  • 63
6 votes
2 answers
16k views

C++ libraries for Fast Fourier Transform in high precision

I am looking for a C++ library for Fast Fourier Transform (FFT) in high precision (e.g., using high precision real data types similar to mpfr_t in MPFR or ...
6 votes
1 answer
164 views

Compile-time error control vs. interval arithmetic?

I use interval arithmetic for reliable computing. Now, a procedure coded in a good implementation of interval arithmetic takes perhaps about eight times as much as the same procedure carried out ...
5 votes
1 answer
582 views

Error propagation in recurrence relation

I have a recurrence relation $$P_{n} = A_{n} P_{n-1} - B_{n}P_{n-2}$$ with given $P_{0}$ and $P_{1}$. Numerically, each $A_{n}$ and $B_{n}$ is calculated with some precision. The same applies to ...
  • 203
5 votes
1 answer
146 views

How do I globally change the precision of a piece of code in Python to debug it?

I am solving a system of non-linear equations using the Newton-Raphson method in Python. This involves using the solve(Ax,b) function (...
5 votes
1 answer
929 views

Half precision in Fortran

To improve the time efficiency of my code, I'd like to test a lower precision for real number, using e.g. half precision (2 bytes). However, I'm not sure if I can do that in Fortran. After playing ...
5 votes
2 answers
139 views

Odd accuracy barrier in C/PETSc regarding finite elements

I’m implementing a finite element code (translating from a working MATLAB version, so I have results to compare to) and for some odd reason, some of my computations are only accurate to around 6 ...
5 votes
0 answers
61 views

Evaluate Nth root of a rational to a correctly rounded float

Excuse my lack of vocabulary for I have no formal training in this field, which is also why I ask this question - it may be trivial or it may be impossible. I want to evaluate an expression in the ...
  • 153
4 votes
2 answers
115 views

Analytical convergent sequence and numerical divergent sequence

Is it possible to construct a sequence that converges in theory but when computed numerically with a computer program is diverging. I feel that today our computer programs doesn't allow such ...
  • 269
4 votes
2 answers
5k views

Number of equations and precision of SciPy's integrate.odeint()

Is there any reason why SciPy's integrate.odeint() should become less precise when the number of equations increase? I'm trying to solve these two sets of differential equations: $\frac{dy_1}{dx} = ...
4 votes
1 answer
6k views

Machine epsilon (eps)

The wiki for machine epsilon says: "Machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic" If machine epsilon is the upper bound on the relative ...
4 votes
2 answers
141 views

Under what circumstances can two (nearly) identical sparse matrices give different solutions to Mx = b?

Suppose I have two sparse matrices, $A$ and $B$, of size $N \times N$. They each have the same sparcity pattern ("footprint"). They each also have values which in theory should be identical, but aren'...
  • 263
4 votes
3 answers
1k views

Inverse of ill-conditioned symmetric matrix

I've got a matrix K, with dimensions $(n, n)$ where each element is computed using the following equation: $$K_{i, j} = \exp(-\alpha t_i^2 -\gamma(t_i - t_j)^2 - \...
  • 143
4 votes
1 answer
201 views

Compute hypergeometric function ratio: $\frac{_{2}F_{1}(a+1,b;c;x)}{_{2}F_{1}(a,b;c;x)}$?

I need a numerically stable way to compute the following ratio: $$\frac{_{2}F_{1}(a+1,b;c;x)}{_{2}F_{1}(a,b;c;x)}$$ All the parameters are real numbers, with $a< 0$,$\ $ $b,c > 0$ and $0<x&...
  • 1,689
4 votes
1 answer
107 views

Summation of trigonometric functions results in error with finite precision

Consider the following expression: $$f(t) = B+\sum_{k=1}^{N} A_k\cos(\omega_kt)$$ where $A$ and $B$ are known. the frequencies are also known but are not multiples of a fundamental frequency. However, ...
3 votes
3 answers
428 views

Are scaled equations still needed?

If one wants to solve a problem in physics, one often has to deal with very small numbers because of the units, e.g. the energy range of interest of semiconductors lies in the region $eV \approx 10^{-...
  • 267
3 votes
1 answer
346 views

Testing 1D root-finding procedures for robustness

How can I test whether a given 1D root-finding procedure is robust? I know that there are data sets and resources online for different kinds of optimization, but I have yet to find anything with ...
3 votes
1 answer
285 views

precision loss in non-trigonometric, periodic functions using FFTW and NaNs after marching forward in time (Fortran)

I have developed a pseudospectral solver of the Navier-Stokes equations using FFTW. I tested my formulation of right hand sides (RHS) of the NS equations against standard trigonometric functions (...
3 votes
2 answers
381 views

Known issues with eigenvalue numerics?

Are there any known issues (such as precision issues) with $\mathsf{MATLAB}$ eig and charpoly functions for large enough $\{-1,0,+1\}$ matrices? Even if I change $1$ or $2$ entries between matrices ...
  • 149
3 votes
1 answer
61 views

Dynamic tolerance in a conditional loop to obtain maximum precision allowed by machine floating point numbers

I have coded a simple program for a root finding problem using Halley's method. Here is the code: ...
3 votes
1 answer
416 views

log-sum-exp trick for signed/complex numbers

I need to evaluate a sum of values that are on many different orders of magnitude in scale but might be signed. I’ve had great luck with the “log-sum-exp” trick for an unsigned version of my problem, ...
3 votes
1 answer
532 views

GSL linear algebra LU/determinant precision

I am working with symmetric matrices of order $n \times n$ where $n \leq 50$. The diagonal elements of my matrices are a fixed number $d$ and the off diagonal elements are limited to two small numbers ...
  • 458
3 votes
1 answer
272 views

How to include negative number in the log-sum-exp?

I want to know summation of some small numbers, such as {e^-1000, -e^1001, e^1002...} If all numbers are positive, I can use log-sum-exp algorithm. But unfortunately, negative numbers are also ...