Back to functions

Expression.sub


substitute

Substitutes a given value for another given value


Usage: nerdamer(expression).sub(value, for_value)


Parameters

String value The value being substituted.
String for_value The value to substitute for.

EXAMPLES:
var x = nerdamer('3*(x+1)^3+8*(x+1)^2+u').sub('x+1', 'u');
console.log(x.toString());
x = nerdamer('cos(x)*tan(x)').sub('tan(x)', 'sin(x)/cos(x)').evaluate()
console.log(x.toString());
//one more
x = nerdamer('(x+1)*cos(x+1)').sub('x+1', 'u');
console.log(x.toString());
OUTPUT:
Back to functions