Function reference · Math

subst

Substitutes one expression for another inside an expression tree.

subst(expression,value,replacement) replaces matching variables or supported compound subexpressions while preserving the surrounding symbolic structure. The substitution recurses into sums, products, functions, and powers.

It can replace more than a single symbol when the requested subexpression can be matched structurally.

Examples

These examples use Nerdamer Notation.

Replace a variable throughout nested structure.

subst(cos(x+1)^x,x,u)
// → cos(1+u)^u

Replace a complete subexpression.

subst(x+1,x+1,u)
// → u

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation · nerdamer API

Nerdamer Notation

Use this form inside input passed to nerdamer(...).

subst(arg1, arg2, arg3)

nerdamer.subst

Call the operation through the default nerdamer import.

nerdamer.subst(expression: ExpressionInput, value: ExpressionInput, withValue: ExpressionInput, includeNumeric: boolean): Expression

Parameters

NameTypeDescription
expressionExpressionInputThe expression being used to perform the substitution
valueExpressionInputThe value currently in the expression
withValueExpressionInputThe value that the substitution is being replaced with
includeNumericboolean

Returns

Expression

Browse the nerdamer API →

← Back to Reference