Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
179 views

The inverse of the gamma function over the reals is multivalued with an infinite number of branches. This self-answered question is about the principal inverse of the gamma function, Γ0-1(x), whose ...
njuffa's user avatar
  • 27.1k
1 vote
0 answers
101 views

My understanding is that R uses IEC 60559 rounding with "Round to nearest, ties to even", but it does not appear to be generating valid results. For decimal part .535 rounded to 2 places, my ...
simpleuser's user avatar
  • 1,711
1 vote
0 answers
79 views

If I run x=0:0.1:1; x==0.2, I get equality at the third element (as expected). However, if I change it to x=-1:0.1:1; x==0.2 I no longer get any hits. Why the change? (I am familiar with some details ...
magnesium's user avatar
  • 639
4 votes
1 answer
114 views

Question I was wondering if there is a numerically accurate way to compute sign(a² - b * c) * sqrt(abs(a² - b * c)) with floating point arithmetics because it suffers from (ordered from most to least ...
MothNik's user avatar
  • 131
0 votes
3 answers
167 views

One should not use == to compare real numbers, every C# developer knows that. Then why the Double.CompareTo method, from the framework, is implemented this way for checking equality? public int ...
paradise's user avatar
  • 540
3 votes
2 answers
246 views

I'm trying to write a function which returns the coefficients of the nth legendre polynomial. // store previous polynomials to make the recursive process faster unordered_map<int, vector<double&...
haifisch123's user avatar
0 votes
2 answers
86 views

I fill a numpy array with 0 or 1 depending if a computed array indexed value is more or less than a given value. This results in an array of zeros and ones. Matplotlib doesnt think so The comparison ...
Jeff Secor's user avatar
0 votes
0 answers
74 views

In SQL Server Management Studio: DECLARE @Amount FLOAT SELECT SUM(Amount) FROM Docs WHERE DocID IN (104482, 104483, 104484, 104486, 104489, 104491, 104493) -- displays in results window 178457,05 ...
Manolis GRS's user avatar
2 votes
1 answer
237 views

This is a self-answered question, as encouraged on Stackoverflow for sharing knowledge. As such, it is a follow-on to my previous self-answered question regarding accurate computation of the principal ...
njuffa's user avatar
  • 27.1k
2 votes
1 answer
474 views

Neumaier summation is an improvement of Kahan summation for accurately summing arrays of floats. import numba as nb @nb.njit def neumaier_sum(arr): s = arr[0] c = 0.0 for i in range(1, ...
Simd's user avatar
  • 21.5k
-1 votes
1 answer
78 views

12.7 - 20 + 7.3 = -8.8817841970013e-016 I got this problem when I read Programming in Lua book, and I cannot figure it out how to get zero as the result of the calculation. When I formatted the result ...
Ryal Naufal's user avatar
0 votes
1 answer
165 views

I had this C++ code: int x; double y; // do sth int z = ceil(x*y); If x = 410, y = 1.1, then z = 452 when it should've been 451. I changed to z = ceil(float(x*y)) and it works. My friend suggests z ...
Le_Square's user avatar
0 votes
0 answers
39 views

So of course: 1023.1 - 0.1 < 1023 [1] FALSE but... 1024.1 - 0.1 < 1024 [1] TRUE Is this a bug? Is it expected behaviour? Is there some way I can avoid this, such as rounding all my numbers to ...
Johann's user avatar
  • 292
0 votes
1 answer
97 views

I am thinking about calculating $(1-1/x)^y$ for very large x,y numbers in python. One way todo so, it to use exp(y*log1p(-1/x)), but I am not sure about its accuracy. Are they any results on using ...
user3563894's user avatar
0 votes
1 answer
147 views

I'm attempting to create a Python script that identifies all the unique intersection points, eliminating duplicates, among all the lines passing through a subset of points of a regular grid in 2D or ...
Edoardo Serra's user avatar
1 vote
2 answers
242 views

I have the following code, plotting a function on a grid, where the function happens to have a very large integer value: import matplotlib.pyplot as plt from matplotlib.ticker import ScalarFormatter, ...
D.R's user avatar
  • 127
1 vote
3 answers
103 views

For example, as I know, a float point x, which x/n^2 may not be equal to x/n/n, because in x/n/n, which would create an intermediate x/n first. For example: document.write(1.23456789/49 == 1....
wcminipgasker2023's user avatar
1 vote
0 answers
174 views

I am trying to do a very simple thing take a square shape 2d array take its transpose multiply the array with its transpose I am trying to perform the above steps in C++ and Python as shown in the ...
skm's user avatar
  • 5,777
3 votes
1 answer
113 views

I'm trying to sample a variable (SST) as a function of another variable (TCWV) using the function histogram, with weights set to the sample variable like this: # average sst over bins num, _ = np....
ClimateUnboxed's user avatar
1 vote
1 answer
92 views

In computers, the math operation of floating numbers is actually processed using the base number and the exponential number separately, and then combine them together. We learn this in our computation ...
Leo's user avatar
  • 37
0 votes
2 answers
561 views

I have a simple camera based 'modern' OpenGL 3D graphics display, for rendering relatively simple objects that are constructed from collections of specified points, lines and curves (e.g. a cube, ...
DavidH's user avatar
  • 107
-4 votes
1 answer
317 views

I decided to multiply two numbers: 1.0 17299991019999108999910899991119999 and as a result , I received in response: 1.729999101999911e+34 Code: print(1.0*17299991019999108999910899991119999) 1....
user avatar
1 vote
1 answer
65 views

The below program calculates 262 + 261 + 260 + ... + 21 + 20. Using double type to store sum: double sum = 0; for (int i = 0; i < 63; i++) { sum += pow(2.0, i); // print("i : $i sum :...
user avatar
1 vote
0 answers
192 views

First off, let me say that I am aware that we are constrained by the limitations of computer arithmetic and floating point numbers and that 0.8 doesn't equal 0.8, sometimes. I'm curious about ways to ...
Nate's user avatar
  • 11
3 votes
1 answer
95 views

For example: const n=5; const x=1.23; const y=n-x; document.write(x+y==n); the code about prints true for n=5,x=1.23,y=5-1.23 (value after rounded). I think it is just a "lucky" ...
displaydisplayname's user avatar

1
2 3 4 5
28