Skip to main content
Glama

volume

Calculate the volume of revolution around the x-axis by providing a mathematical expression and specifying the start and end points for integration.

Instructions

Calculate the volume of revolution around x-axis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endYes
expressionYes
startYes

Implementation Reference

  • The handler function implements the disk method for volume of revolution around the x-axis using numerical approximation with 1000 steps and eval for y-value computation.
    async ({ expression, start, end }) => { // Volume of revolution using disk method const steps = 1000; const dx = (end - start) / steps; let volume = 0; for (let i = 0; i < steps; i++) { const x = start + i * dx; const y = eval(expression.replace(/x/g, `(${x})`)); volume += Math.PI * y * y * dx; } return volume; }
  • Schema definition including input parameters (expression, start, end) and output as number.
    { name: 'volume', description: 'Calculate the volume of revolution around x-axis', inputSchema: z.object({ expression: z.string(), start: z.number(), end: z.number() }), outputSchema: z.number(),
  • index.js:148-173 (registration)
    The tool 'volume' is registered using ai.defineTool with schema and handler.
    ai.defineTool( { name: 'volume', description: 'Calculate the volume of revolution around x-axis', inputSchema: z.object({ expression: z.string(), start: z.number(), end: z.number() }), outputSchema: z.number(), }, async ({ expression, start, end }) => { // Volume of revolution using disk method const steps = 1000; const dx = (end - start) / steps; let volume = 0; for (let i = 0; i < steps; i++) { const x = start + i * dx; const y = eval(expression.replace(/x/g, `(${x})`)); volume += Math.PI * y * y * dx; } return volume; } );

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