compound_interest
Calculate compound interest for investments or loans by inputting principal amount, interest rate, time period, and compounding frequency.
Instructions
Calculate compound interest
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| principal | Yes | ||
| rate | Yes | ||
| time | Yes | ||
| compounds | No |
Implementation Reference
- index.js:217-219 (handler)Inline async handler that calculates compound interest using the formula P * (1 + r/n)^(nt)async ({ principal, rate, time, compounds = 12 }) => { return principal * Math.pow(1 + rate/compounds, compounds * time); }
- index.js:209-215 (schema)Zod schemas defining input parameters (principal, rate, time, optional compounds) and number outputinputSchema: 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)Tool registered using ai.defineTool with name, description, schema, and handlerai.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); } );