Skip to main content
Tweeted twitter.com/#!/StackMma/status/218337139757301761
edited body
Source Link
István Zachar
  • 47.2k
  • 20
  • 145
  • 293

There are multiple ways to convert an expression to machine precision, for example:

In[1]:= a = Sqrt[2]
Out[1]= Sqrt[2]

In[2]:= {1.a, 1`a, N@a, SetPrecision[a,MachinePrecision]}
Out[2]= {1.41421,1.41421,1.41421,1.41421}

In[3]:= Precision /@ %
Out[3]= {MachinePrecision,MachinePrecision,MachinePrecision,MachinePrecision}

My question is whether or not these methods are absolutely equivalent. Is isit just a matter of personal taste which one to use, or are there examples where they behave differently?

There are multiple ways to convert an expression to machine precision, for example:

In[1]:= a = Sqrt[2]
Out[1]= Sqrt[2]

In[2]:= {1.a, 1`a, N@a, SetPrecision[a,MachinePrecision]}
Out[2]= {1.41421,1.41421,1.41421,1.41421}

In[3]:= Precision /@ %
Out[3]= {MachinePrecision,MachinePrecision,MachinePrecision,MachinePrecision}

My question is whether or not these methods are absolutely equivalent. Is is just a matter of personal taste which one to use, or are there examples where they behave differently?

There are multiple ways to convert an expression to machine precision, for example:

In[1]:= a = Sqrt[2]
Out[1]= Sqrt[2]

In[2]:= {1.a, 1`a, N@a, SetPrecision[a,MachinePrecision]}
Out[2]= {1.41421,1.41421,1.41421,1.41421}

In[3]:= Precision /@ %
Out[3]= {MachinePrecision,MachinePrecision,MachinePrecision,MachinePrecision}

My question is whether or not these methods are absolutely equivalent. Is it just a matter of personal taste which one to use, or are there examples where they behave differently?

Source Link
Simon Woods
  • 85.4k
  • 8
  • 180
  • 326

Converting to machine precision

There are multiple ways to convert an expression to machine precision, for example:

In[1]:= a = Sqrt[2]
Out[1]= Sqrt[2]

In[2]:= {1.a, 1`a, N@a, SetPrecision[a,MachinePrecision]}
Out[2]= {1.41421,1.41421,1.41421,1.41421}

In[3]:= Precision /@ %
Out[3]= {MachinePrecision,MachinePrecision,MachinePrecision,MachinePrecision}

My question is whether or not these methods are absolutely equivalent. Is is just a matter of personal taste which one to use, or are there examples where they behave differently?