Questions tagged [numerical-stability]

In the mathematical subfield of numerical analysis, numerical stability is a generally desirable property of numerical algorithms. The precise definition of stability depends on the context. One is numerical linear algebra and the other is algorithms for solving ordinary and partial differential equations by discrete approximation.

104 questions
0
votes
1 answer

Same time integration code in Matlab and python, matlab is stable, python blows up

Here is an algorithm of Exponential time differencing method, using the original Matlab code from Oxford clc clear % viscosity nu = 0.5; % Spatial grid and initial condition: N = 128; x = 2*pi*(0:N-1)'/N; u = cos(x).*(1+sin(x)); v = fft(u); %…
0
votes
1 answer

Best Way to Add 3 Numbers (or 4, or N) in Java - Kahan Sums?

I found a completely different answer to this question, the whole original question makes no sense anymore. However, the answer way be useful, so I modify it a bit... I want to sum up three double numbers, say a, b, and c, in the most numerically…
0
votes
2 answers

How can I multiply an nxn matrix A in fortran x times to get its power without amplifying rounding errors?

How can I multiply an NxN matrix A in Fortran x times to get its power without amplifying rounding errors?
0
votes
1 answer

Intersection of two triangles in the plane

The intersection of two triangles is either empty or an n-gon (for n up to 6). In theory, it is easy to come up with an algorithm to compute the intersection area. One can compute the possible intersections of all line segments and combine them with…
J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0
votes
1 answer

error bound in function approximation algorithm

Suppose we have the set of floating point number with "m" bit mantissa and "e" bits for exponent. Suppose more over we want to approximate a function "f". From the theory we know that usually a "range reduced function" is used and then from such…
0
votes
1 answer

Implicit Euler method for integration of ODEs

For those of you familiar with the method, it is known that one must solve the equation: y(i+1) = y(i) + h*F( X(i+1), Y(i+1) ) However, F is usually not linear, and the resulting equation usually has many different solutions for y(i+1). Which…
0
votes
2 answers

Articles on analysis of mixed precision numerical algorithms?

Many numerical algorithms tend to run on 32/64bit floating points. However, what if you had access to lower precision (and less power hungry) co-processors? How can then be utilized in numerical algorithms? Does anyone know of good books/articles…
anon
  • 41,035
  • 53
  • 197
  • 293
0
votes
1 answer

How to fix this round-off error?

Apologies for the long code. This is as far as I could reduce it. #include #include #include #include #include using namespace std; class View : public QWidget { …
Arlen
  • 6,641
  • 4
  • 29
  • 61
0
votes
1 answer

Absolute and absolute relative error (numerical errors)

I'd like to understand how absolute and relative errors work in order to write some code. Suppose, we have x1*=4.54 x2*=3.00 and x3*=15.0, accuracy: 3 digits. How do we define: a. the absolute error of x1*-x2*+x3* and b. the absolute relative…
user1807155
0
votes
1 answer

Algorithms for Performing Large Integer Matrix Operations w/ Numerical Stability

I'm looking for a library that performs matrix operations on large sparse matrices w/o sacrificing numerical stability. Matrices will be 1000+ by 1000+ and values of the matrix will be between 0 and 1000. I will be performing the index calculus…
0
votes
1 answer

Numerically stable average of java.util.Dates

I've got a bunch of Dates and I want to find their average. How many Dates within 100 years of now can I sum before I run into overflow problems? Any gotchas? What's the best way to calculate the average, avoiding overflow problems?
Riley Lark
  • 20,660
  • 15
  • 80
  • 128
-1
votes
1 answer

Homemade deep learning library: numerical issue with relu activation

For the sake of learning the finer details of a deep learning neural network, I have coded my own library with everything (optimizer, layers, activations, cost function) homemade. It seems to work fine when benchmarking in on the MNIST dataset, and…
Learning is a mess
  • 7,479
  • 7
  • 35
  • 71
-1
votes
1 answer

Weighted cross-entropy tensorflow

I couldn't find a tensorflow built-in that allows you to pass in labels which don't sum to 1, so tried writing my own: (Input is [batch_size,labels]) tf.reduce_mean(tf.reduce_sum(y_true,axis=1) * tf.reduce_logsumexp(y_pred_logits,axis=1) -…
Akababa
  • 327
  • 3
  • 21
-3
votes
1 answer

Improve precision on numpy narrays

I have written this optimization procedure using numpy where I have to perform the following calculation: B is a symmetric negative semi-definite matrix and I the identity matrix. The problem is that the values of B can be too big (>1e25) and when…
1 2 3 4 5 6
7