Skip to main content
Glama

derivative

Compute the derivative of a mathematical expression with respect to a specified variable. Simplify calculus tasks and solve differentiation problems efficiently.

Instructions

Calculate the derivative of a mathematical expression

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesMathematical expression (e.g., "x^2", "e^x", "sin(x)")
variableNoVariable to differentiate with respect to (default: x)

Implementation Reference

  • index.js:9-17 (handler)
    Core handler logic for the 'derivative' tool: parses mathematical expression and computes symbolic derivative using mathjs.
    const derivative = (expr, variable = 'x') => { try { const node = math.parse(expr); const derivativeExpr = math.derivative(node, variable); return derivativeExpr.toString(); } catch (e) { return `Error: ${e.message}`; } };
  • Input/output schema for the derivative tool: requires expression string, optional variable, returns string result.
    name: 'derivative', description: 'Calculate the derivative of a mathematical expression', inputSchema: z.object({ expression: z.string().describe('Mathematical expression (e.g., "x^2", "e^x", "sin(x)")'), variable: z.string().optional().describe('Variable to differentiate with respect to (default: x)') }), outputSchema: z.string(),
  • index.js:80-93 (registration)
    Registration of the 'derivative' tool using ai.defineTool, including schema definition and handler reference.
    ai.defineTool( { name: 'derivative', description: 'Calculate the derivative of a mathematical expression', inputSchema: z.object({ expression: z.string().describe('Mathematical expression (e.g., "x^2", "e^x", "sin(x)")'), variable: z.string().optional().describe('Variable to differentiate with respect to (default: x)') }), outputSchema: z.string(), }, async ({ expression, variable = 'x' }) => { return derivative(expression, variable); } );

Other Tools

Related 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/nbiish/mcp-calc-tools'

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