compound_interest
Calculate compound interest by inputting principal, interest rate, time, and compounding frequency. Use this tool to determine investment growth or loan repayment amounts accurately.
Instructions
Calculate compound interest
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compounds | No | ||
| principal | Yes | ||
| rate | Yes | ||
| time | Yes |
Implementation Reference
- index.js:217-219 (handler)The asynchronous handler function that calculates the compound interest based on principal, rate, time, and optional compounding frequency using the formula P*(1 + r/n)^(n*t).async ({ principal, rate, time, compounds = 12 }) => { return principal * Math.pow(1 + rate/compounds, compounds * time); }
- index.js:209-215 (schema)Zod schemas defining the tool's input parameters (principal: number, rate: number as decimal, time: number in years, compounds: optional number) and output as a number.inputSchema: z.object({ principal: z.number(), rate: z.number(), // annual interest rate as decimal time: z.number(), // years compounds: z.number().optional() // times per year }), outputSchema: z.number(),
- index.js:205-220 (registration)The tool registration via ai.defineTool method, specifying name, description, input/output schemas, and inline handler implementation.ai.defineTool( { name: 'compound_interest', description: 'Calculate compound interest', inputSchema: z.object({ principal: z.number(), rate: z.number(), // annual interest rate as decimal time: z.number(), // years compounds: z.number().optional() // times per year }), outputSchema: z.number(), }, async ({ principal, rate, time, compounds = 12 }) => { return principal * Math.pow(1 + rate/compounds, compounds * time); } );