Skip to main content
Glama
sdiehl
by sdiehl

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expr_keyYes
replacement_expr_keyYes
var_nameYes

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sdiehl/sympy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server