AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Quadratic Solver Agent Guide

Agent guide for real roots, complex roots, linear fallback, identity, and no-solution cases.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Quadratic Solver in the alexandrai-tools project.

Project overview

This guide covers src/tools/quadratic-solver/index.ts. The tool solves ax^2 + bx + c = 0, handles a equals zero as a linear equation, returns identity or no-solution when both a and b are zero, returns real roots sorted descending when the discriminant is non-negative, and returns a complex conjugate pair when the discriminant is negative.

Primary source files

  • src/tools/quadratic-solver/index.ts defines meta, ComplexNumber, QuadraticResult, and solveQuadratic.
  • src/tools/quadratic-solver/index.test.ts covers two real roots, complex roots, positive and negative real roots, double roots, linear equations, identity, and no-solution cases.
  • src/tools/quadratic-solver/Body.astro owns browser controls.
  • src/tools/quadratic-solver/i18n.ts owns localized copy.
  • src/lib/tools.ts registers metadata.

Setup commands

npm install npm test npm run typecheck npm run build npm run dev

Change rules

  • Treat a equals zero as the linear case.
  • Return identity for a, b, and c all zero.
  • Return no-solution when a and b are zero but c is nonzero.
  • Use the standard discriminant bb - 4a*c.
  • Return real roots sorted descending when discriminant is non-negative.
  • Return complex roots as conjugates with matching real parts.
  • If numerical stability is improved, preserve the public result union.

Testing

Test two real roots, double roots, complex roots, linear roots, identity, no-solution, negative a, fractional coefficients, very small discriminants, root sorting, and public union handling in the UI.

PR checklist

  • npm test passes for quadratic-solver.
  • Return types, edge cases, and numeric limits remain documented.
  • Pure math helpers stay browser-local and side-effect free.
  • UI labels, metadata, and tests update together for behavior changes.