Skip to main content
Glama

fourier_transform

Transform time-domain functions into frequency-domain representations using the Fourier transform. Input a function, specify time and frequency variables, and generate precise results for advanced analysis.

Instructions

Calculate the Fourier transform of a function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesFunction of time
freqVarYesFrequency variable
timeVarYesTime variable

Implementation Reference

  • Core implementation of the fourier_transform tool logic using numerical integration to approximate the Fourier transform.
    const fourierTransform = (expr, t, omega) => { try { const node = math.parse(expr); // Using numerical integration for a basic approximation const limit = 50; // Approximation of infinity const steps = 1000; const dt = (2 * limit) / steps; let result = math.complex(0, 0); for (let i = 0; i < steps; i++) { const time = -limit + i * dt; const scope = { [t]: time }; const ft = math.evaluate(node, scope); const expTerm = math.exp( math.multiply( math.complex(0, -1), omega, time ) ); result = math.add(result, math.multiply(ft, expTerm, dt)); } return result.toString(); } catch (e) { return `Error: ${e.message}`; } };
  • index.js:457-471 (registration)
    Registration of the fourier_transform tool with Genkit's ai.defineTool, including schema definitions and handler that delegates to the core fourierTransform function.
    ai.defineTool( { name: 'fourier_transform', description: 'Calculate the Fourier transform of a function', inputSchema: z.object({ expression: z.string().describe('Function of time'), timeVar: z.string().describe('Time variable'), freqVar: z.string().describe('Frequency variable') }), outputSchema: z.string(), }, async ({ expression, timeVar, freqVar }) => { return fourierTransform(expression, timeVar, freqVar); } );
  • Input and output schema definitions for the fourier_transform tool using Zod validation.
    inputSchema: z.object({ expression: z.string().describe('Function of time'), timeVar: z.string().describe('Time variable'), freqVar: z.string().describe('Frequency variable') }), outputSchema: z.string(),

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