Skip to main content
Glama

volume

Calculate the volume of revolution around the x-axis for a given mathematical expression between specified start and end points.

Instructions

Calculate the volume of revolution around x-axis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYes
startYes
endYes

Implementation Reference

  • The handler function implements the volume of revolution calculation around the x-axis using the disk method. It approximates the integral numerically with 1000 steps, evaluating the given expression at each point to compute pi * y^2 * dx.
    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; }
  • Defines the input schema requiring a mathematical expression (string), start and end x-values (numbers), and output schema as a number representing the computed volume.
    inputSchema: z.object({ expression: z.string(), start: z.number(), end: z.number() }), outputSchema: z.number(),
  • index.js:148-173 (registration)
    Registers the 'volume' tool using ai.defineTool, including its name, description, schema, and handler function.
    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