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.

Mathematica supports arbitrary precision and exact numbers, but it can also operate using normal machine-precision floating point numbers of the kind used in Excel and many other programs. When using machine-precision numbers, all the usual issues around floating-point arithmetic apply, including the possibility that precision might decline in certain calculations.

Useful links

Example questions

231 questions
7
votes
4 answers

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 Accuracy[] or Precision[]. f[x_] := E^Cos[x] NIntegrate[f[x], {x, 0,…
Oliver Spryn
  • 359
  • 4
  • 12
6
votes
0 answers

Can I force Mathematica to use machine precision?

Some built-in functions (like Exp) give an arbitrary precision result, even when the argument is a machine precision number. Example: Exp[-10.] // Precision MachinePrecision Exp[-1000.] // Precision 12.9546 I can of course Clip and Chop the…
Niki Estner
  • 36,101
  • 3
  • 92
  • 152
5
votes
1 answer

Infinite expression 1/0. encountered - caused by precision?

Planck's law dependent on frequency rho is as follows: B[T_, h_, rho_, k_, c_] := (2 h rho^3)/c^2 1/(Exp[h rho/(T k)] - 1) As you can see, the denominator can only be zero for rho = 0. All the rest are nonzero constants. Curiously if we try to…
C. E.
  • 70,533
  • 6
  • 140
  • 264
4
votes
1 answer

How to map HoldForm?

I'm trying to compare between Sqrt[3.] and Sqrt[3]. To display the result, I mapped HoldForm to display the expressions on the left hand column (code at end), but it seems like Sqrt[3.] had been evaluated before it was mapped on to. Is there any way…
seismatica
  • 5,101
  • 1
  • 22
  • 33
3
votes
2 answers

Make mathematica "forget" numbers beyond the precision goal

I need Mathematica to remember only things upto two decimal places. I'm currently using the unwieldy Floor[x*100]/100 which works but is there a better way to make it use two decimal places (throughout the notebook is okay). I tried N[x,{2,2}] but…
user1936752
  • 259
  • 2
  • 7
3
votes
1 answer

Reasonable choice of MachinePrecision, AccuracyGoal and PrecisionGoal for NDSolve

I am trying to use this model for later use in FindFit: model[x0_?NumberQ, r_?NumberQ, k_?NumberQ, n_?NumberQ] := model[x0, r, k, n] = First[x /. NDSolve[{x'[t] == r x[t] (1 - x[t]/k)^n, x[0] == x0}, x, {t, 0, 61}]] Assume now that those…
Ramiro Magno
  • 325
  • 1
  • 10
3
votes
2 answers

Simplify for precision

I have an a set of equations to solve — details irrelevant — the result of which will be converted into PostScript, a 1980s printer-control language the only floating precision of which is single. Therefore I care about precision. Consider a simple…
jdaw1
  • 499
  • 2
  • 9
3
votes
1 answer

Setting precision and machine underflow

As is well known, Mathematica changed how it handles numbers smaller than $MinMachineNumber in recent versions. I'm running Mathematica 12 on a Mac, and I cannot figure out why it's treating these differently: Exp[-N[2695, $MachinePrecision]] …
Lauren Pearce
  • 550
  • 2
  • 10
2
votes
1 answer

How to Chop correctly?

I want to count degeneracies in a list called spectrum. The list contains numbers of double (~ 15digits) precision. So it makes no sense if the noise below this precision is taken into account since it falsifies the result of degeneracy counting…
pawel_winzig
  • 1,577
  • 1
  • 12
  • 21
2
votes
1 answer

Showing what happens with a number beyond machineprecision

I want to play around a bit in Mathematica to understand how floating-point precision, rounding and truncation actually works. I understand that Machineprecision is $2^{-52}$. First of all I would like to create a binarynumber and show that it is…
GambitSquared
  • 2,311
  • 15
  • 23
1
vote
2 answers

Decimal output from a simple equation

Let x= 0.0000000000000000036; y = 1 - x If i type this in Mathematica the answer of y is 1. I want the answer to be as it is 0.9999999999999999964
Nikolas
  • 105
  • 9
1
vote
1 answer

Function that puts zero after a certain decimal in every element of the matrix

We know that in Mathematica there is some default precision, which you can also change. This means, that after a certain decimal(fixed by the precision), the computer puts pseudo random numbers. I am looking for a function F that would put…
Mencia
  • 1,324
  • 12
  • 26
1
vote
2 answers

How to increase the value of MinMachineNumber to avoid overflow error?

I have a complicated function called f2[re] f2[re_] := 1/(2 cep^(3/2) (cep - 2 cp) cp^(3/2) re) E^(-cp inf^2 - cep inf re - ce re^2 - (cep re \[Alpha]2)/cp - 2 (inf + re) \[Alpha]2) norm^2 \[Pi] (2 cep^(3/2) Sqrt[cp] E^((cep re…
Wisdom
  • 1,258
  • 7
  • 13
1
vote
2 answers

MemberQ[{0.01, 0.05}, (0.01*9*2)/9/2] returns False

Multiplying and dividing by the same stuff seems to alter the value. Quite curiously, if the value you start from is large enough (greater than 0.05 in my case) you do not see the problem. Any idea why? MemberQ[{0.01, 0.05}, (0.05*9*2)/9/2] returns…
Rho Phi
  • 1,420
  • 11
  • 21
0
votes
1 answer

N, machine precision and expression evaluation

I should state that I am a Mathematica beginner but I checked the questions about machine vs arbitrary precision (such as: this one ) and I continue to have the following issue while trying to evaluate an expression: After various calculations which…
George
  • 39
  • 3