Basic Examples (4)
Use ExpandPureFunction to expand a function involving Gamma:
Use the 1-argument form with automatic variable detection:
Expand a ChebyshevT polynomial inside a Function:
Expand a trigonometric composition:
Scope (4)
ExpandPureFunction preserves symbolic parameters that have global values. Here, a has a global assignment but is correctly kept symbolic in the output:
User-defined functions (with DownValues) are expanded, while symbolic parameters (with OwnValues) are preserved:
Expand a multivariable pure function with named variables:
Expand a slot-based Function by supplying explicit variable names:
Applications (5)
Define a pure function that computes the regularized incomplete Beta function and expand it to reveal its representation in terms of the incomplete Beta and Gamma functions:
Expand the Sinc function (normalized Sin[x]/x) inside a pure function. FunctionExpand reduces it to its piecewise-free trigonometric form:
Use ExpandPureFunction to expand the Struve function StruveH in terms of Bessel functions and elementary expressions:
Expand a pure function involving the error function complement Erfc to obtain its representation in terms of Erfc itself (demonstrating the reflection identity):
Use ExpandPureFunction to transform the Fibonacci function into its closed-form expression involving the golden ratio:
Properties and Relations (2)
ExpandPureFunction uses FunctionExpand internally, while FullSimplifyFunction uses FullSimplify. This means ExpandPureFunction can achieve reductions that FullSimplify alone does not perform, and vice versa. In some cases, they give equivalent results:
An equivalent way to obtain the same result is by manually applying ExpressionToFunction. First, FunctionExpand is applied to the expression xGamma[x], and then "ExpressionToFunction" reconstructs the pure function from the expanded result:
ExpandPureFunction wraps this multi-step pattern into a single call, handling dummy variables and symbol blocking automatically. The key limitation of the manual approach is that it does not protect symbols with global OwnValues from being substituted — ExpandPureFunction adds that protection.
Possible Issues (3)
When the variable name supplied to ExpandPureFunction conflicts with a symbol appearing in the function body, the output may shadow the original parameter:
In the example above, the parameter b in the body is replaced by the function variable b, causing the multiplicative factor to disappear. Users should avoid naming the output variable the same as any symbolic parameter in the function body:
By design, ExpandPureFunction blocks only symbols with OwnValues. If a parameter is defined via DownValues (e.g., f[x_] := …), it will be evaluated during the expansion:
This is intentional. If preservation of such definitions is desired, one may wrap them with Block externally.
When using ExpandPureFunction inside Table, keep in mind that the Function wrapper captures all symbols in its body lexically. If the table iterator variable appears inside the Function body, it will not be substituted by Table:
Use With to inject the iterator value before constructing the Function:
Neat Examples (5)
Reveal closed-form representations of hypergeometric functions. Many special cases of Hypergeometric2F1 reduce to elementary functions when FunctionExpand is applied:
Expand a pure function involving the Pochhammer symbol (rising factorial) to reveal the underlying Gamma function ratio:
Obtain the explicit Gamma function representation of the Beta function:
Construct closed-form pure functions for the successive derivatives of the Gamma function. The With idiom ensures the derivative order k is injected before the Function wrapper captures it:
Visualize how ExpandPureFunction transforms the Mittag-Leffler function at specific parameter values into elementary functions. MittagLefflerE[α, z] generalizes the exponential; at α = 1 it recovers Exp, and at α = 2 it gives Cosh: