Skip to main content
Glama
nbiish
by nbiish

z_transform

Calculate the Z-transform of discrete-time functions to analyze signals and systems in the frequency domain. Provide the function expression, time variable, and Z-transform variable for computation.

Instructions

Calculate the Z-transform of a function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesFunction of discrete time
timeVarYesDiscrete time variable
zVarYesZ-transform variable
limitNoUpper limit for summation (default: 100)

Implementation Reference

  • Core handler function implementing the Z-transform calculation using numerical summation of f[n] * z^{-n} from n=0 to limit.
    const zTransform = (expr, n, z, limit = 100) => {
      try {
        const node = math.parse(expr);
        let result = math.complex(0, 0);
        
        for (let k = 0; k <= limit; k++) {
          const scope = { [n]: k };
          const fn = math.evaluate(node, scope);
          const zTerm = math.pow(z, -k);
          result = math.add(result, math.multiply(fn, zTerm));
        }
        
        return result.toString();
      } catch (e) {
        return `Error: ${e.message}`;
      }
    };
  • index.js:473-488 (registration)
    Registers the z_transform tool with Genkit AI, specifying name, description, input/output schemas, and handler.
    ai.defineTool(
      {
        name: 'z_transform',
        description: 'Calculate the Z-transform of a function',
        inputSchema: z.object({
          expression: z.string().describe('Function of discrete time'),
          timeVar: z.string().describe('Discrete time variable'),
          zVar: z.string().describe('Z-transform variable'),
          limit: z.number().optional().describe('Upper limit for summation (default: 100)')
        }),
        outputSchema: z.string(),
      },
      async ({ expression, timeVar, zVar, limit = 100 }) => {
        return zTransform(expression, timeVar, zVar, limit);
      }
    );
  • Defines the input schema (expression, timeVar, zVar, optional limit) and output schema (string) for the z_transform tool.
    inputSchema: z.object({
      expression: z.string().describe('Function of discrete time'),
      timeVar: z.string().describe('Discrete time variable'),
      zVar: z.string().describe('Z-transform variable'),
      limit: z.number().optional().describe('Upper limit for summation (default: 100)')
    }),
    outputSchema: z.string(),

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