Questions tagged [epsilon]

The machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic. The quantity is also called "macheps" or "unit roundoff".

The IEEE standard does not define the terms machine epsilon and unit roundoff, so differing definitions of these terms are in use, which can cause some confusion.

The following different definition is much more widespread outside academia: Machine epsilon is defined as the smallest number that, when added to one, yields a result different from one.

158 questions
10
votes
3 answers

calculating a function in matlab with very small values

I am making a function in matlab to compute the following function: for this function we have: This is my implementation in matlab of the function: function [b]= exponential(e) %b = ? b= (exp (e) -1)/e; When I test the function with very small…
franvergara66
  • 10,524
  • 20
  • 59
  • 101
8
votes
1 answer

Why can't I include the standard algorithm library after defining 'epsilon' in C++?

When I include the algorithm library before defining epsilon, the following code compiles: #include #include #define epsilon 0.00001 int main() { std::cout << epsilon; return 0; } When I switch them around, it…
rvvermeulen
  • 169
  • 8
8
votes
1 answer

Epsilon in quadruple precision (gcc)

According to wikipedia, the layouts of the different precision data types are single precision: exponent (e): 8 bits, fraction (f): 23 bits double precision: e: 11 bits, f: 52 bits quadruple precision: e: 15 bits, f: 112 bits. I wrote a small…
okruz
  • 95
  • 3
8
votes
3 answers

How to choose epsilon value for floating point?

Since we know that 0.1 + 0.2 != 0.3 due to limited number representation, we need to instead check hat abs(0.1+0.2 - 0.3) < ε. The question is, what ε value should we generally choose for different types? Is it possible to estimate it depending on…
Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166
8
votes
6 answers

Python epsilon is not the smallest number

What does sys.float_info.epsilon return? On my system I get: >>> sys.float_info.epsilon 2.220446049250313e-16 >>> sys.float_info.epsilon / 2 1.1102230246251565e-16 >>> 0 < sys.float_info.epsilon / 2 < sys.float_info.epsilon True How is this…
Ella Sharakanski
  • 2,683
  • 3
  • 27
  • 47
8
votes
2 answers

Why does PHP not provide an Epsilon constant for floating point comparisons?

After seeing many PHP questions about comparing the equality of floats where the answer is to simply choose an arbitrary value for Epsilon and then do if( abs($a-$b) < 0.000001 ). The trouble is that Epsilon is typically much smaller than the values…
Sammitch
  • 30,782
  • 7
  • 50
  • 77
7
votes
3 answers

Get Machine epsilon in Microsoft Excel

This seems like a question better directed at those with some programming experience rather than just general Excel users, hence my asking on here as opposed to Superuser. Is there any way, preferably through a function, to return epsilon (i.e. the…
SSilk
  • 2,433
  • 7
  • 29
  • 44
7
votes
2 answers

Implement Matlab's eps(x) function in C++

I'm trying to implement Matlab's eps(x) function in C++ For example, in Matlab: >> eps(587.3888) ans = 1.1369e-13 >> eps(single(587.3888)) ans = 6.1035e-05 However, when I try to do this in C++ I am not able to get the correct single precision…
kyle
  • 197
  • 1
  • 2
  • 11
7
votes
1 answer

What is the closure of a left-recursive LR(0) item with epsilon transitions?

Let's say I have this grammar: A: ε | B 'a' B: ε | B 'b' What is considered to be the closure of the item A: • B 'a'? In other words, how do I deal with the epsilon transitions when figuring out closures?
user541686
  • 205,094
  • 128
  • 528
  • 886
6
votes
6 answers

Minimum and maximum of the last 1000 values of the changing list

I'm creating an iterative algorithm (Monte Carlo method). The algorithm returns a value on every iteration, creating a stream of values. I need to analyze these values and stop the algorithm when say 1000 returned values are withing some epsilon. I…
ovgolovin
  • 13,063
  • 6
  • 47
  • 78
6
votes
2 answers

Does using epsilon in comparison of floating-point break strict-weak-ordering?

Does following class breaks strict-weak-ordering (in comparison to regular std::less (So ignoring edge case values such as Nan)) struct LessWithEpsilon { static constexpr double epsilon = some_value; bool operator() (double lhs, double rhs)…
Jarod42
  • 203,559
  • 14
  • 181
  • 302
5
votes
3 answers

Machine precision estimations

Some people say that machine epsilon for double precision floating point numbers is 2^-53 and other (more commonly) say its 2^-52. I have messed around estimating machine precision using integers besides 1 and aproaching from above and below (in…
njvb
  • 1,377
  • 3
  • 18
  • 36
5
votes
1 answer

Buggy floating point handling in Visual Studio?

There's an update in the end! I have a little story. I wanted to calculate the machine epsilon (the largest epsilon > 0 satisfying condition 1.0 + epsilon = 1.0) in a C program compiled by MS Visual Studio 2008 (running on Windows 7 in a 64 bit PC).…
tim
  • 81
  • 1
  • 6
5
votes
2 answers

Keras, Tensorflow - What is the meaning of K.epsilon when computing metrics

I am computing Recall and Accuracy for my model and I am wondering why people add Keras.epsilon() to their variables (examples found on stackoverflow : Macro metrics (recall/F1...) for multiclass CNN or How to calculate F1 Macro in Keras? ) Thank…
chalbiophysics
  • 313
  • 4
  • 15
5
votes
2 answers

Inconsistent hashcode and equals java

After researching I still can't find the specific solution for my problem. I have an "approximately equals" method that uses an epsilon, while my hashCode method uses the exact values. This breaks the precondition of HashSet when I compare the…
Alex Blasco
  • 793
  • 11
  • 22
1
2
3
10 11