Skip to main content
Glama

analyze_formula

Analyzes mathematical properties of formulas, including domain, range, and critical points, to support mathematical visualization and computation.

Instructions

Analyzes mathematical properties of a formula (domain, range, critical points).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formulaYes
analysis_typeNobasic

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the core logic of 'analyze_formula'. It parses the formula with sympy, computes domain, range (for detailed), or critical points based on analysis_type, and returns formatted results.
    @mcp.tool()
    def analyze_formula(formula: str, analysis_type: AnalysisType = "basic") -> str:
        """Analyzes mathematical properties of a formula (domain, range, critical points)."""
        try:
            x = sympy.symbols('x')
            expr = sympy.sympify(formula)
            results = [f"Analysis for '{formula}' ('{analysis_type}' type):"]
            if analysis_type == "basic" or analysis_type == "detailed":
                domain = continuous_domain(expr, x, sympy.S.Reals)
                results.append(f"- Domain: {domain}")
            if analysis_type == "detailed":
                f_range = function_range(expr, x, domain)
                results.append(f"- Range: {f_range}")
            if analysis_type == "critical_points":
                derivative = sympy.diff(expr, x)
                results.append(f"- Derivative: {derivative}")
                critical_points = sympy.solveset(derivative, x, domain=sympy.S.Reals)
                if not critical_points:
                    results.append("- Critical Points: None found.")
                else:
                    results.append(f"- Critical Points: {critical_points}")
            return "\n".join(results)
        except Exception as e:
            return f"Error analyzing formula '{formula}'. Details: {e}"
  • AnalysisType Literal type definition used for the analysis_type parameter in the tool's input schema, specifying 'basic', 'detailed', or 'critical_points'.
    AnalysisType = Literal["basic", "detailed", "critical_points"]

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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/TheGrSun/Desmos-MCP'

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