Evaluate mathematical constants to any precision:

Get approximate values for large integers:

Complex number results:

More elaborate symbolic mathematical constants can be detected using

NumericQ:

In general,

NumericQ expressions represent numbers that can be evaluated to any precision:

Evaluate the entries of a matrix numerically:

Evaluate numerically the numeric parts of a symbolic expression:

Make the coefficients of a polynomial numerical:

N[e] typically works by replacing numbers with machine numbers and computing the result:

This is equivalent to the expression with machine numbers:

The machine roundoff error shows up clearly on a log-log plot of the difference quotient error:

N works adaptively using arbitrary-precision numbers when

p is not

MachinePrecision:

With adaptive precision, the difference quotient error matches the theoretical value:

The adaptive precision control has a default limit,

$MaxExtraPrecision, for extra precision:

When the limit is reached, you can locally increase

$MaxExtraPrecision to resolve the difficulty:

N does not raise the precision of approximate numbers in its input:

The precision of the result is the same as that of the input:

You can use

SetPrecision to increase the precision of input expressions:

N does not affect exact numeric powers:

The base is modified:

The power is modified if it is not

NumericQ:

SparseArray objects are treated based on the represented array:

In general,

N[Normal[s]] is identical to

Normal:

Data objects like

InterpolatingFunction have special rules so that only the data is affected:

Only the appropriate data has been changed so that the new function uses machine numbers:

Operations like

Integrate use the corresponding

N-functions when appropriate:

This is using

NIntegrate:

For high requested precision, numerical algorithms may take a lot of time or need adjustment:

In this case you may want to use

NIntegrate directly:

For most expressions,

N affects the tree shown in

FullForm:

The

appears in front of

because of how

is represented:

The integers in

have just been converted to machine numbers:

Prevent an indexed variable from being affected by

N using the

NHoldAll attribute:

With this,

N only affects the coefficients:

Without this,

N affects the indices too:

Define a numerical constant equal to

:

In an exact symbolic expression the constant does not evaluate:

Add a definition that will work with arbitrary precision or accuracy:

Numerically evaluate an expression to accuracy 20:

Define a function that represents the real-valued root

for positive

and positive integer

:

Prevent its second argument from being converted to real using

NHoldRest:

An exact representation of the cube root of 2:

Machine-number approximation:

47-digit approximation:

Define a data object that represents a polynomial

in a sparse form

:

Make sure that

N only affects the coefficients, not the powers:

Default

N evaluation of the argument needs to be prevented for the rule to work:

A representation of the polynomial

:

Get the representation with approximate real coefficients:

Evaluate at

: