# Tag Info

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

This function, as any similar hill, tent or hat functions, implements the expansion-and-folding scheme. This means that in the most benign interpretation you lose in each iteration one bit from the ...
• 6,109

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

I thought it would be interesting to see how the number of bits of precision affects the error. I wrote the following using arb, a library for interval arithmetic (and in particular a library that ...
Accepted

### Is half precision supported by modern architecture?

Intel support for IEEE float16 storage format Intel supports IEEE half as a storage type in processors since Ivy Bridge (2013). Storage type means you can get a memory/cache capacity/bandwidth ...
• 2,126

### Meaning of "-0.0" in Python?

Floating point numbers (according to the standard1 nearly all programming languages use) are stored with a certain number of bits in the mantissa, in the exponent, and with a sign bit. As such, ...
• 55.7k
Accepted

### Why are log and exp considered 'expensive' computations in ML?

To add to Lutz Lehmann's answer, you can look up the latency for the CPU instructions in this comprehensive table by Agner Fog. For example, on the Intel Ivy Bridge processors: FADD / FSUB (floating ...
• 10.3k
Accepted

### What are some good strategies to test a floating point arithmetic implementation for double numbers?

You should test transition points. Floating-point numbers have several distinct "ranges": Standard/Normal arithmetic Subnormal arithmetic Infinite arithmetic NaN arithmetic Zero arithmetic ...
• 3,971

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

Other answers have explained the results from Python, Julia, Maxima, C, and Mathematica. I'll explain the result you got from ChatGPT. Generally, the way that ChatGPT works is that you ask a question, ...
• 261
Accepted

### Are BLAS implementations guaranteed to give the exact same result?

No, that is not guaranteed. If you are using a NETLIB BLAS without any optimizations, it it mostly true that the results are the same. But for any practical usage of BLAS and LAPACK one uses a highly ...

### Matrix multiplication accuracy Matlab vs Python

First, see Mark L. Stone's answers, which is completely correct. Second, realize that this is the reason why people told you to use relative errors in your numerical analysis class. :) Third, the ...
• 11.5k

### Matrix multiplication accuracy Matlab vs Python

Here is R1, as computed in MATLAB: ...
• 2,232

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

Perhaps the reason you are stunned is that you don't understand that what you are asking to calculate is impossible to ever calculate exactly. So if you want the answer to some precision, you need to ...
• 239
Accepted

### Evaluating $\log(\exp(x)+1)$ for negative $x$

Use the (IEEE standard) library function log1p, which should be present in all programming languages. The function log1p(x) ...
• 11.5k

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

Unfortunately this comes down to the math library. IEEE754 does not mandate exactly how the cosine should be computed (technically one doesn't even need to include a function to compute the cosine to ...
• 11.5k

### C, Julia, Python, Maxima, Mathematica, ChatGPT and numerical errors

We could use exact arithmetic to compute the correct value. A range of exact numbers $e$ correspond to the same $a=5.0$ representation in float32 IEEE754, plot over this range: You can see that after ...
• 2,665

### Why are log and exp considered 'expensive' computations in ML?

$\exp$, $\sin$, $\tan$ and their inverse and otherwise related functions are transcendental, defined by an infinite power series. Meaning it takes some effort to evaluate uniformly good approximations....
• 6,109

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

The numeric precision is not perfect. You get rounding errors during your computation. When working with floats, don't check if they are = 0, but check if their absolute distance to 0 is smaller than ...
• 121
Accepted

### Accuracy loss in single-precision Euclidean norm computation

The squares are harmless (as long as they don't overflow/underflow), because the relative perturbation they introduce is of the order of the machine precision $u\approx 10^{-8}$. Your troubles here ...
• 11.5k

### Accurate computation of logbinomial(x,y)

The proposed computation of $\ln{x \choose y}$ via the logarithm of the beta function does not give rise to catastrophic cancellation other than for cases where $y=0$, or $y =x$, which are easily ...
• 1,895
Accepted

### Small, unpredictable results in runs of a deterministic model

There are aspects of modern computing systems that are inherently non-deterministic that can cause these kinds of differences. As long as the differences are very small in comparison with the ...
• 18.8k
Accepted

### Order of operations, numerical algorithms

Let's denote by $\otimes,\oplus,\ominus$ (I was lazy trying to get circled version of division operator) the floating-point analogs of exact multiplication ($\times$), addition ($+$), and subtraction (...
• 8,672