substitute_expression
Perform symbolic substitution in mathematical expressions by replacing a specified variable with another expression. Returns the resulting expression key for further use.
Instructions
Substitutes a variable in an expression with another expression using SymPy's subs method.
Args:
expr_key: The key of the expression to perform substitution on.
var_name: The name of the variable to substitute.
replacement_expr_key: The key of the expression to substitute in place of the variable.
Example:
# Create variables x and y
intro("x", [], [])
intro("y", [], [])
# Create expressions
expr1 = introduce_expression("x**2 + y**2")
expr2 = introduce_expression("sin(x)")
# Substitute y with sin(x) in x^2 + y^2
result = substitute_expression(expr1, "y", expr2)
# Results in x^2 + sin^2(x)
Returns:
A key for the resulting expression after substitution.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expr_key": "<expr_key>",
"var_name": "<var_name>",
"replacement_expr_key": "<replacement_expr_key>"
},
"name": "substitute_expression"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr_key | Yes | ||
| replacement_expr_key | Yes | ||
| var_name | Yes |