Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Expressions > Evaluation Control > NHoldAll >

NHoldAll

NHoldAll
is an attribute which specifies that none of the arguments to a function should be affected by N.
  • NHoldAll, NHoldFirst, and NHoldRest are useful in ensuring that arguments to functions are maintained as exact integers, rather than being converted by N to approximate numbers.
Prevent N from affecting the arguments of a function:
Prevent N from affecting the arguments of a function:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
System symbols with the NHoldAll attribute:
The arguments of Derivative remain unchanged with N:
N leaves the derivative order while changing the point of evaluation:
Define a pure function:
The function with coefficients converted to numerical values:
The positional parameters remain unchanged with N because Slot has the NHoldAll attribute:
Use an indexed variable:
With this attribute, the variables remain unchanged:
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 above to work:
A representation of the polynomial :
Get the representation with approximate real coefficients:
Evaluate at :
HoldAll prevents evaluation while NHoldAll only prevents numerical evaluation:
You can prevent both by setting both attributes:
New in 3
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF