()
| 284 | |
| 285 | |
| 286 | def build(): |
| 287 | out = [] |
| 288 | for c in CASES: |
| 289 | cat = c["cat"] |
| 290 | common = dict(id=c["id"], category=cat, tier=c.get("tier", "core"), title=c["title"], latex=c["latex"]) |
| 291 | if cat in ("numeric", "cl-numeric"): |
| 292 | if c.get("integer"): |
| 293 | verify = {"kind": "integer", "value": str(c["f"]())} |
| 294 | else: |
| 295 | verify = {"kind": "decimal", "sigdigits": c["prec"], "value": dec(c["f"](), c["prec"] + 12)} |
| 296 | inputs = { |
| 297 | "ce": {"mathjson": c["ce"], "op": "N", "precision": c.get("prec", 0)}, |
| 298 | "sympy": {"expr": c["sympy"], "op": "N", "precision": c.get("prec", 0)} if c.get("sympy") else None, |
| 299 | "mathjs": {"expr": c["mathjs"], "op": "N", "precision": c.get("prec", 0)} if c.get("mathjs") else None, |
| 300 | "numpy": {"expr": c["numpy"], "op": "N"} if c.get("numpy") else None, |
| 301 | } |
| 302 | elif cat == "evaluate": |
| 303 | # `.evaluate()` to an exact closed form (limit / definite or |
| 304 | # improper integral). Verified numerically; the oracle additionally |
| 305 | # requires the result be symbolic (not a bare float) to count as a |
| 306 | # genuine exact-evaluation improvement. |
| 307 | verify = {"kind": "value", "value": dec(c["f"](), 50)} |
| 308 | inputs = { |
| 309 | "ce": {"mathjson": c["ce"], "op": "evaluate"}, |
| 310 | "sympy": {"expr": c["sympy"], "op": "evaluate"} if c.get("sympy") else None, |
| 311 | "mathjs": None, "numpy": None, |
| 312 | } |
| 313 | elif cat == "solve": |
| 314 | # Real roots are baked here (mpmath) so the oracle can check a tool's |
| 315 | # returned roots against an independent reference set. |
| 316 | verify = {"kind": "roots", "var": "x", "values": c["roots"]} |
| 317 | inputs = { |
| 318 | "ce": {"mathjson": c["ce"], "op": "solve", "var": "x"}, |
| 319 | "sympy": {"expr": c["sympy"], "op": "solve", "var": "x"} if c.get("sympy") else None, |
| 320 | "mathjs": None, "numpy": None, |
| 321 | } |
| 322 | elif cat in ("simplify", "derivative"): |
| 323 | pts = c.get("points", DEF_POINTS) |
| 324 | if cat == "simplify": |
| 325 | values = [dec(c["f"](p), 50) for p in pts] |
| 326 | op = "simplify" |
| 327 | vr = {"kind": "sample", "var": "x", "points": [dec(p, 50) for p in pts], "values": values} |
| 328 | ce_in = {"mathjson": c["ce"], "op": "simplify"} |
| 329 | py_op = {"op": "simplify"} |
| 330 | else: |
| 331 | values = [dec(diff(c["f"], p), 50) for p in pts] |
| 332 | vr = {"kind": "sample", "var": "x", "points": [dec(p, 50) for p in pts], "values": values} |
| 333 | ce_in = {"mathjson": c["ce"], "op": "diff", "var": "x"} |
| 334 | py_op = {"op": "diff", "var": "x"} |
| 335 | inputs = { |
| 336 | "ce": ce_in, |
| 337 | "sympy": {"expr": c["sympy"], **py_op} if c["sympy"] else None, |
| 338 | "mathjs": {"expr": c["mathjs"], **py_op} if c["mathjs"] else None, |
| 339 | "numpy": None, |
| 340 | } |
| 341 | verify = vr |
| 342 | else: # antiderivative |
| 343 | a, b = c.get("interval", DEF_INTERVAL) |
no test coverage detected