Wolfram Research

Function Repository Resource:

EffectivePrecision

Source Notebook

Get the effective precision of an expression

Contributed by: Daniel Lichtblau

ResourceFunction["EffectivePrecision"][expr]

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

Details and Options

ResourceFunction["EffectivePrecision"] 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 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, use Precision:

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

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information