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
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,949
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
  • 887
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
  • 457
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,851
21 votes
2 answers
3k 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
20 votes
1 answer
2k views

Quadruple-precision (128 bit) arithmetic

Is it possible to force Mathematica to perform computations with hardware supported quadruple-precision? The following test suggest, that all of the computations with fixed precision, different than <...
mmal's user avatar
  • 3,508
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
18 votes
2 answers
567 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,665
17 votes
2 answers
346 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
17 votes
4 answers
467 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,316
15 votes
4 answers
676 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.3k
12 votes
1 answer
815 views

Why does 1 - Exp[-10.0^12] cause an out-of-memory error?

I would like to understand why evaluation of the expression 1 - Exp[-10.0^12] causes an out-of-memory error and how can I prevent such errors when calculating ...
Ray Shadow's user avatar
  • 7,816
11 votes
2 answers
887 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,316
11 votes
2 answers
841 views

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

The following is the program. ...
howard's user avatar
  • 403
11 votes
1 answer
698 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
1 answer
143 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
  • 66k
10 votes
1 answer
396 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
10 votes
2 answers
932 views

Why is Mathematica destroying this graph?

Here I have a picture of a function I graphed: reg[x_,y_]:=(x^2+y^2)Cos[4ArcTan[y/x]]; Plot3D[reg[x,y],{x,-2,2},{y,-2,2},AxesLabel->Automatic] And here is ...
silvascientist's user avatar
10 votes
3 answers
897 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
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
10 votes
1 answer
316 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
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
9 votes
3 answers
2k views

Very different results from evaluating same expression with different precisions

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

How to detect underflow/overflow (post 11.3)?

This old trick used to work before 11.3: SetSystemOptions["CheckMachineUnderflow" -> True] But no longer... so how can we explicitly check for this in v12+?? ...
M.R.'s user avatar
  • 31.4k
9 votes
2 answers
608 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
9 votes
1 answer
318 views

IntegerPart - is this a known bug?

I'm working in Mathematica 13.0 and I type a=0.00001; IntegerPart[a/a] and well, the output is 0. Try with almost any other value of ...
sonarventu's user avatar
9 votes
1 answer
779 views

Machine Epsilon

I'm trying to evaluate the machine epsilon of my computer (see below). I wrote this: ...
Eric's user avatar
  • 93
9 votes
1 answer
167 views

Why am I getting wildly incorrect results from FirstPassageTimeDistribution with inexact transition matrix?

Working on some large systems using DiscreteMarkovProcess, I changed the transition matrix to machine precision vs using exact values, which sped things up handily. ...
ciao's user avatar
  • 25.8k
9 votes
1 answer
252 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
  • 6,057
8 votes
2 answers
544 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
  • 235k
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,592
8 votes
1 answer
833 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,101
8 votes
1 answer
934 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
1 answer
121 views

Unexpected behavior from CoordinateBoundingBoxArray with Into[1] and 0.41

I want to get the four corners of a Cuboid. This usually works: CoordinateBoundingBoxArray[{-{1., 1.}, {1., 1.}}, Into@1] gives ...
masterxilo's user avatar
  • 5,739
8 votes
1 answer
1k views

What is wrong with importing Real32 or Real64?

Those who visit the chat might have seen the question of varkor. I'm posting it here in the hope that I have missed something. Assume you have a real number ...
halirutan's user avatar
  • 113k
8 votes
2 answers
607 views

how to get single, and quad Precision out of Mathematica which match Fortran result

by default, if a number has decimal . after it, then Mathematica will do computation using machine Precision, which on my PC (intel hardware) running windows 7 64 ...
Nasser's user avatar
  • 143k
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
7 votes
3 answers
438 views

Since when does Mathematica have an 'Inf' symbol?

When I do: ...
berniethejet's user avatar
  • 1,417
7 votes
4 answers
362 views

Definition of $MachineEpsilon

$MachineEpsilon x = 0.0000000000000001 % + 1 % - 1 As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$). However, if I ...
GambitSquared's user avatar
7 votes
2 answers
992 views

Accurately evaluating the hypergeometric function

As part of another problem, I am working to evaluate hypergeometric functions such as Hypergeometric2F1[1, 1, n, -1] for large $n$. I am hoping to obtain at ...
Doubt's user avatar
  • 315
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
7 votes
1 answer
270 views

Bug in ListPlot?

I want to check if this is a bug before I email WR about it. I can't get ListPlot[] to make scatter plots over a very small area: ...
Jerry Guern's user avatar
  • 4,602
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
  • 1,003
6 votes
4 answers
508 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,152
6 votes
3 answers
830 views

A bug with high precision

Consider the following two numbers: num1=0.0006000000000000001`; num2=0.0006000000000000003`; num2 appeared from ...
John Taylor's user avatar
  • 5,659
6 votes
1 answer
163 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
356 views

Table does not give expected result with `30 but right with `40

I want Mathematica to generate a table, but I am very confused by its behaviour. tab = Table[i, {i, 6.311, 6.312, 0.001}] Now I get the desired result, namely {6....
Charlotte Myin's user avatar
6 votes
1 answer
290 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
6 votes
2 answers
178 views

How can I make 1+$MachineEpsilon not look like 1?

I undarstand that 1+$MachineEpsilon is actually not equal 1. However, it persists to look like it was equal ...
gaazkam's user avatar
  • 817

1
2 3 4 5