Substitution (subs)
Substitute a rule, or a list of rules, in an expression.
How to write it
subs(expr, rules)
- expr
- Any expression: a number, a formula, a list or a matrix. Takes an expression.
- rules
- What to put in place of what. Takes a rule, or a list of rules.
Examples
subs(x^2 + 1, x -> 2)In the solver,
Open in the solversubs(x^2 + 1, x -> 2)gives5.subs(x^2 + y, [x -> 1, y -> 2])In the solver,
Open in the solversubs(x^2 + y, [x -> 1, y -> 2])gives3.
Related functions
- to_radicals
Write algebraic numbers, given as roots of polynomials, with radicals.
- simplify
Simplify an expression, optionally under assumptions.
- together
Combine fractions into one over a common denominator.
- resultant
Resultant of two polynomials in a variable.
- apart
Split a rational expression into partial fractions.
- power_expand
Expand powers and logarithms of products and powers.