Questions tagged [machine-precision]

For questions on the use of machine-precision real numbers (also known as floats), the numbers that can be directly manipulated through the underlying numerical capabilities of your computer system.

Filter by
Sorted by
Tagged with
42 votes
2 answers
4k views

Meaning of backtick in floating-point literal

If I compute, say, 1/3//N, Mathematica displays 0.333333 as the result. When I copy that output to use elsewhere, the paste ...
Joseph O'Rourke's user avatar
21 votes
2 answers
2k views

New General::munfl error and loss of precision

The latest version 11.3.0.0 of Mathematica returns Indeterminate when evaluating Log[Exp[-800.]]. I believe this was not ...
Valerio's user avatar
  • 1,962
11 votes
2 answers
831 views

Dr. StrangeNumbers or: How I Learned to Stop Worrying and Love Floating Point Arithmetic

The following is the program. ...
howard's user avatar
  • 393
19 votes
5 answers
4k views

Numerical underflow for a scaled error function

I calculate a scaled error function defined as f[x_] := Erfc[x]*Exp[x^2] but it can not calculate f[30000.]. ...
こじま's user avatar
  • 193
10 votes
2 answers
2k views

DeleteDuplicates[] does not work as expected on floating point values

Here is my simple example, and in this case function DeleteDuplicates does not work as expected. I want to FindRoot of my ...
Arnold Klein's user avatar
31 votes
8 answers
2k views

Elegant high precision `log1p`?

Sometimes it is hard to understand how numerical expressions are evaluated. I remember reading claims by Wolfram on how smart the Kernel is to evaluate expressions trees numerically by recognizing ...
alfC's user avatar
  • 877
42 votes
2 answers
1k views

Is there a difference between Divide[a,b] and a/b?

In this comment it was asserted that Divide[a,b] and a/b are different, though the documentation indicates that they are the ...
Mark Adler's user avatar
  • 4,939
9 votes
3 answers
1k views

Very different results from evaluating same expression with different precisions

When I evalute the following expression, ...
MATIRMAK's user avatar
  • 739
5 votes
2 answers
845 views

Underflow error General::munfl from E^x instead of Exp[x]

In contrast to earlier versions, Mathematica 11.3 and 12.0 generate lots of underflow errors from my code, e.g. ...
Quantum Sharpener's user avatar
5 votes
2 answers
894 views

How to make the computer consider two numbers equal up to a certain precision

My problem is that I have a matrix A and the computer says is not Hermitian (self-adjoint). Then I check which elements make A ...
Mencia's user avatar
  • 1,294
9 votes
2 answers
604 views

Precision differences

I run this sum and get the symbolic answer below : Sum[ (1/(k^2 - k) - 1/k^2), {k, 2, Infinity}] $2 - \frac{\pi^2}{6}$ I look up the sequence on OEIS and ...
Fred Daniel Kline's user avatar
18 votes
2 answers
562 views

Rounding problems inside InputField

The community needs to determine if this is behavior is a bug or not. – Mr.Wizard Consider the following InputField ...
P. Fonseca's user avatar
  • 6,635
15 votes
4 answers
661 views

Terrible accuracy of DawsonF

DawsonF[30.] returns 0. The correct value is 0.016676... At least it prints a warning message, ...
a06e's user avatar
  • 11.1k
8 votes
1 answer
923 views

Machine-Precision and Arbitrary Precision [closed]

What is meant by a machine number in the Mathematica documentation? What is the difference between machine-precision and fixed-point precision? What is arbitrary precision?
Undertherainbow's user avatar
8 votes
3 answers
6k views

Machine precision near zero: not fulfilled?

I am puzzled by the behavior of Mathematica machine precision with numbers approaching zero. This manifests itself, e.g., with FixedPoint and the like. In the ...
user8074's user avatar
  • 1,572
11 votes
1 answer
681 views

Compilation of Total with compensated summation

I sometimes obtain an unexpected error when trying to call a compiled version of Total with compensated summation turned on. More specifically I define ...
Eckhard's user avatar
  • 1,395
11 votes
2 answers
874 views

Does Mathematica have an equivalent of Python's float.as_integer_ratio?

The Python programming language has a float.as_integer_ratio(x) function which exactly converts an IEEE 754 floating-point number into a numerator/denominator pair ...
David Zhang's user avatar
  • 2,306
10 votes
1 answer
306 views

Can Someone Please Explain Internal`$SameQTolerance?

If I input Internal`$SameQTolerance (* output = 0.30103 *) which is the approximation of Log[10,2], or ...
user155812's user avatar
9 votes
1 answer
752 views

Machine Epsilon

I'm trying to evaluate the machine epsilon of my computer (see below). I wrote this: ...
Eric's user avatar
  • 93
7 votes
4 answers
3k views

Mathematica Precision

How can I set the output precision of the following statement to 10 decimal places? I was looking through the documentation, and for some reason, all I could find was ...
Oliver Spryn's user avatar
26 votes
2 answers
2k views

Different floating-point numbers equal?

Let's define two different numbers. x = 1. y = 1. + 2^-52 (* equivalently, 1 + $MachineEpsilon *) Let's make sure they're different with ...
2012rcampion's user avatar
  • 7,801
16 votes
4 answers
455 views

Does Mathematica have an equivalent of C's nextafter?

In C (and many other programming languages), there is a function double nextafter(double x, double y) which takes two (IEEE 754) floating-point numbers and ...
David Zhang's user avatar
  • 2,306
10 votes
1 answer
395 views

Plot of $\sin(x^x)$ is missing from $x=143$

When plotting the graph of $\sin(x^x)$ I noticed that there is no plot from about $x=143$. I don't suppose there is a purely mathematical explanation for this? So, why is there no graph in ...
GambitSquared's user avatar
5 votes
6 answers
3k views

Why is this Mandelbrot set's implementation infeasible: takes a massive amount of time to do?

The Mandelbrot set is defined by complex numbers such as $z=z^2+c$ where $z_0=0$ for the initial point and $c\in\mathbb C$. The numbers grow very fast in the iteration. ...
hhh's user avatar
  • 2,573
10 votes
3 answers
894 views

Mathematica Plot: Inconsistency when plotting large values

I am working with a function in Mathematica and I am getting some inconsistencies when I plot it. As I really need to understand were this comes from I would appreciate any help. I am working with a ...
silky's user avatar
  • 103
9 votes
1 answer
249 views

Plot3D discrepancy between MMA 10 and 11.3 - possible small numbers issue

I'm having some troubles with the following code I wrote in MMA 10 some time ago: ...
Fraccalo's user avatar
  • 5,917
6 votes
4 answers
3k views

Making a calculation with high precision

I would like to make the following calculation: 1/Sqrt[1 - (150^2 10^(-4))/(9 10^16.)] - 1 Mathematica 8 returns 0. The result is obviously not 0, but my ...
Thanos's user avatar
  • 993
6 votes
1 answer
134 views

Bug in floating-point number comparisons near $MachineEpsilon?

I stumbled over the following weird behavior when comparing floating-point numbers close to 1.0: qq = 1.0 + 60.0 $MachineEpsilon; and then ...
RonH's user avatar
  • 281
4 votes
0 answers
175 views

Is it possible to get the original number from DecimalForm?

Bug introduced in 5.2 or earlier and persisting through 13.1.0 [CASE:4315787] Wrong behavior of NumberForm (DecimalForm outputs ...
Alexey Popkov's user avatar
4 votes
2 answers
3k views

Precision of number not maintained when saved via Export

Assume that the output of my calculation is a and is a number such as: a = 100.1252135246354847; ...
dearN's user avatar
  • 5,311
3 votes
1 answer
278 views

Why to do parentheses change the results of a calculation?

I'm getting results that are sensitive to where I place parentheses with respect to operations that are associative1 (and should thus be insensitive to such placement). For example, if I define2 <...
orome's user avatar
  • 12.8k
2 votes
1 answer
292 views

How to stop Mathematica from turning .02 into 0.019999999999999997` [closed]

...
Daniel Berkowitz's user avatar
2 votes
1 answer
175 views

Efficient Round edition with different rounding direction

As pointed out in this post, Mathematica has a special version of Round that Round rounds numbers of the form x.5 toward the nearest even integer. A comment by ...
matheorem's user avatar
  • 16.9k
2 votes
1 answer
1k views

How to increase significant digits in Mathematica

How can I increase the number of significant digits in Mathematica? When I import a matrix, an element like 112.5276 is rounded to 112.528. I would like to increase the number of significant digits ...
MOON's user avatar
  • 3,824
0 votes
1 answer
99 views

Why this very simple problem turns to "Indeterminate"?

Why the following calculation gives Indeterminate value? ...
Bekaso's user avatar
  • 629
0 votes
2 answers
240 views

The precision of the number

I have problem in Mathematica with unnecessary rounding which is caused by high precision. For example I have value a = 2.052685846*10^-1865, when I make ...
Ziva's user avatar
  • 787
30 votes
2 answers
4k views

Why does Mathematica results differ from C++ results within machine precision?

I am trying to wrap my head around floating-point precision. Performing the following numeric operation: 275./6.*1.03692775514337 in Mathematica and C++ and ...
DrDirk's user avatar
  • 447
17 votes
2 answers
343 views

CompiledFunction returns machine numbers smaller than $MinMachineNumber

When thinking on the workaround for this LogLogPlot bug suggested by halirutan I noticed that CompiledFunction actually can ...
Alexey Popkov's user avatar
11 votes
1 answer
142 views

Abnormal behavior of RealDigits[x]

In the Details of the document of RealDigits writes the following line: RealDigits[x] normally returns a list of digits of ...
xzczd's user avatar
  • 62.8k
9 votes
1 answer
556 views

What explains the inaccuracies in machine-precision 'integers' with trigonometry or powers?

This Mathematica tutorial notes some strange behaviour with calculations such as Sin[10^50]: ...
numbermaniac's user avatar
8 votes
2 answers
530 views

Dealing with numbers too large for machine precision in Graphics

Graphics only supports machine precision numbers (i.e. number that can be converted to machine precision). Take for example ...
Szabolcs's user avatar
  • 232k
8 votes
1 answer
810 views

Really understanding precision

I've been reading the documentation in Mathematica about precision, namely: Exact and Approximate Results Arbitrary-Precision Numbers Arbitrary-Precision Calculations Machine-Precision Numbers ...
Vicent's user avatar
  • 1,091
7 votes
1 answer
156 views

Using Differences on data: trouble with floats and doubles

Consider the following data set (after I have run FullForm), which is imported from a file (stored typically as 10.040): ...
tkott's user avatar
  • 4,939
6 votes
4 answers
493 views

How do I convert an inexact number smaller than $MinMachineNumber to machine-precision?

I was trying to convert some arbitrary-precision numbers to machine-precision numbers using N[myNumber,MachinePrecision]. But, although my test number did lose some ...
Ruslan's user avatar
  • 7,102
6 votes
0 answers
167 views

Can I force Mathematica to use machine precision? [duplicate]

Some built-in functions (like Exp) give an arbitrary precision result, even when the argument is a machine precision number. Example: ...
Niki Estner's user avatar
  • 35.9k
6 votes
1 answer
162 views

Issues with $MachineEpsilon

I'm attempting to add $MachineEpsilon to numbers I am pulling from the domains of 3 interpolating functions. I pulled 3 numbers, and for one of these numbers adding ...
Nicole's user avatar
  • 87
6 votes
1 answer
287 views

ConvexHullMesh fails with small numbers

When I try to get the ConvexHullMesh of a List of points that are "small scale", I get errors: ...
DPF's user avatar
  • 1,067
5 votes
1 answer
232 views

Compilation, square roots, and integers

After looking at this question, particularly this answer, I wrote my own performance test, using the two functions ...
rogerl's user avatar
  • 4,197
5 votes
1 answer
434 views

MachinePrecision versus $MachinePrecision in NDSolve

I'd like to understand why one of these inputs gives me an error and the other doesn't: ...
Max's user avatar
  • 1,030
4 votes
1 answer
833 views

Could the PrecisionGoal for NDSolve be a negative number?

The help of Mathematica doesn't say so much about the PrecisionGoal for NDSolve, and I never considered much about it even after ...
xzczd's user avatar
  • 62.8k