Skip to main content
Glama
nbiish
by nbiish

fourier_transform

Calculate the Fourier transform of a function to analyze signals in the frequency domain. Convert time-domain expressions to frequency-domain representations for signal processing applications.

Instructions

Calculate the Fourier transform of a function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesFunction of time
timeVarYesTime variable
freqVarYesFrequency variable

Implementation Reference

  • Core handler function that computes the Fourier transform using numerical integration approximating the integral from -inf to inf with symmetric limits.
    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}`;
      }
    };
  • Tool schema defining input parameters (expression, timeVar, freqVar) and string output.
    {
      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(),
    },
  • index.js:457-471 (registration)
    Registers the fourier_transform tool using ai.defineTool, including schema and thin handler wrapper 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);
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what the tool does ('Calculate') without mentioning computational characteristics, error handling, output format, or performance considerations. For a mathematical computation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, with no wasted information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a Fourier transform operation, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, how results are formatted, or any mathematical assumptions, leaving significant gaps for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter descriptions in the schema (e.g., 'Function of time' for expression). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Calculate the Fourier transform of a function', which specifies the verb ('Calculate') and resource ('Fourier transform'). However, it doesn't distinguish this tool from its sibling 'laplace_transform' or 'z_transform', which are related mathematical transforms, so it doesn't fully differentiate from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'laplace_transform' or 'z_transform'. It lacks context about appropriate mathematical scenarios, prerequisites, or exclusions, leaving the agent to infer usage based on general knowledge of Fourier transforms.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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