NHoldAll

NHoldAll

is an attribute which specifies that none of the arguments to a function should be affected by N.

Details

  • 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.

Examples

open allclose all

Basic Examples  (1)

Prevent N from affecting the arguments of a function:

Scope  (3)

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:

Applications  (2)

Use an indexed variable:

With this attribute, the variables remain unchanged:

Define a data object that represents a polynomial in a sparse form {{c_(1),p_(1)},...}:

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 :

Properties & Relations  (1)

HoldAll prevents evaluation while NHoldAll only prevents numerical evaluation:

You can prevent both by setting both attributes:

Wolfram Research (1996), NHoldAll, Wolfram Language function, https://reference.wolfram.com/language/ref/NHoldAll.html.

Text

Wolfram Research (1996), NHoldAll, Wolfram Language function, https://reference.wolfram.com/language/ref/NHoldAll.html.

CMS

Wolfram Language. 1996. "NHoldAll." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NHoldAll.html.

APA

Wolfram Language. (1996). NHoldAll. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NHoldAll.html

BibTeX

@misc{reference.wolfram_2024_nholdall, author="Wolfram Research", title="{NHoldAll}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/NHoldAll.html}", note=[Accessed: 25-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_nholdall, organization={Wolfram Research}, title={NHoldAll}, year={1996}, url={https://reference.wolfram.com/language/ref/NHoldAll.html}, note=[Accessed: 25-December-2024 ]}