Wolfram Research

EffectivePrecision

Contributed by: Daniel Lichtblau

Source Notebook

Effective precision of an expression

ResourceFunction["EffectivePrecision"][expr]

gives the precision of the expression expr which is a list, equation, or similar comprised of numeric subexpressions.

Details and Options

Determines the effective numeric precision of an expression, ignoring heads that are not numeric functions, List, equation or inequality heads, and some related heads.

Examples

Basic Examples

A list with an explicit machine number has effective precision of MachinePrecision:

In[1]:=
ResourceFunction["EffectivePrecision"][{x, 1.}]
Out[1]=

If a machine number appears in an expression with a head that is neither a list, equation, inequality, nor a numeric function, then the effective precision is infinite:

In[2]:=
ResourceFunction["EffectivePrecision"][x[1.]]
Out[2]=

Scope

EffectivePrecision will return the lowest precision encountered in a mathematical subexpression:

In[3]:=
e = Map[N[#, 5*#] &, Range[5]]
Out[3]=
In[4]:=
ResourceFunction["EffectivePrecision"][e]
Out[4]=

MachinePrecision is contagious insofar as it is considered to be lower than any software float precision:

In[5]:=
ResourceFunction["EffectivePrecision"][Append[e, N[Pi]]]
Out[5]=

Properties and Relations

EffectivePrecision is intended primarily for mathematical expressions rather than programming language constructs:

In[6]:=
ResourceFunction["EffectivePrecision"][If[x == 3, 1.0, 5]]
Out[6]=

To find the lowest precision in an arbitrary expression one can use Precision:

In[7]:=
Precision[If[x == 3, 1.0, 5]]
Out[7]=

Resource History