{
  "openapi": "3.1.1",
  "info": {
    "title": "Numerical Equation Solver & Optimizer API",
    "version": "1.0.0",
    "summary": "Every root of f(x) = 0 in an interval, Newton or bisection steps, systems and minima.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://prooflineequationsolver.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Every root of f(x) = 0 in an interval, Newton or bisection steps, systems and minima.",
        "description": "Finds every root of an equation such as cos(x) = x in an interval (sign changes refined with Brent’s method, touching roots detected), shows the iteration table of bisection or Newton’s method, solves systems of up to six nonlinear equations with a damped Newton method, and locates minima and maxima with Brent’s method or golden-section search. The numeric counterpart to the exact step-by-step solver; part of the Proofline math notebook.\n\nMethodology:\n- Expressions are read by Proofline’s own parser (no eval): + − * / ^, implicit products, the usual functions; ln is the natural logarithm, log is base 10.\n- All roots: the interval is sampled at 401 points; every sign change is refined with Brent’s method (inverse quadratic interpolation, secant and bisection with guaranteed convergence). Sign changes across a pole (tan x) are rejected because |f| stays large. Local minima of |f| near zero without a sign change are refined by minimising f² and reported as touching roots.\n- Bisection halves a bracket with a sign change; Newton’s method uses a central-difference derivative with step ∛ε·max(1, |x|); both list every iteration.\n- Systems: damped Newton method with a forward-difference Jacobian and LU decomposition with partial pivoting; the step is halved until the largest residual decreases.\n- Minima and maxima: sampled local extrema refined with Brent’s minimiser (parabolic interpolation + golden section) or plain golden-section search; extrema at the interval ends are flagged.\n\nNumerical methods find roots and extrema to floating-point precision; roots closer together than 1/400 of the interval can be missed, and Newton’s method may converge to a different root than expected.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "proofline_equation_solver",
        "x-owner-app": "proofline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProoflineEquationSolverInput"
              },
              "examples": {
                "example1": {
                  "summary": "All roots of cos(x) = x",
                  "value": {
                    "problem": "equation",
                    "equations": "cos(x) = x",
                    "from": -5,
                    "to": 5
                  }
                },
                "example2": {
                  "summary": "Three roots of a cubic",
                  "value": {
                    "problem": "equation",
                    "equations": "x^3 - 6x^2 + 11x - 6",
                    "from": 0,
                    "to": 4
                  }
                },
                "example3": {
                  "summary": "Newton’s method for √2 with iteration table",
                  "value": {
                    "problem": "equation",
                    "equations": "x^2 = 2",
                    "method": "newton",
                    "start": "1"
                  }
                },
                "example4": {
                  "summary": "Bisection steps for x³ − 2x − 5 = 0",
                  "value": {
                    "problem": "equation",
                    "equations": "x^3 - 2x - 5 = 0",
                    "method": "bisection",
                    "from": 2,
                    "to": 3,
                    "tolerance": 0.000001
                  }
                },
                "example5": {
                  "summary": "Circle meets hyperbola: nonlinear system",
                  "value": {
                    "problem": "system",
                    "equations": "x^2 + y^2 = 4\nx*y = 1",
                    "variables": "x, y",
                    "start": "2, 0.5"
                  }
                },
                "example6": {
                  "summary": "Minimum of x⁴ − 3x² + x",
                  "value": {
                    "problem": "minimum",
                    "equations": "x^4 - 3x^2 + x",
                    "from": -3,
                    "to": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProoflineEquationSolverResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ProoflineEquationSolverInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "problem": {
            "title": "Problem",
            "type": "string",
            "enum": [
              "equation",
              "system",
              "minimum",
              "maximum"
            ],
            "default": "equation"
          },
          "equations": {
            "title": "Equation, function or system",
            "description": "One equation (cos(x) = x, or x^3 - 2x - 5 meaning = 0), one function for minimum/maximum, or one equation per line for a system. Use + − * / ^, implicit products (2x), sin, cos, tan, exp, ln (natural log), log (base 10), sqrt, abs, pi and e. Angles are in radians.",
            "type": "string",
            "maxLength": 4000
          },
          "variables": {
            "title": "Unknowns",
            "description": "Default x; for a system a comma-separated list such as x, y (as many as equations).",
            "type": "string",
            "maxLength": 200
          },
          "method": {
            "title": "Method",
            "description": "Systems always use Newton’s method.",
            "type": "string",
            "enum": [
              "brent",
              "bisection",
              "newton",
              "golden"
            ],
            "default": "brent"
          },
          "from": {
            "title": "Interval from",
            "type": "number",
            "default": -10
          },
          "to": {
            "title": "Interval to",
            "type": "number",
            "default": 10
          },
          "start": {
            "title": "Start value(s)",
            "description": "Newton’s method: one number, or one per unknown for a system (default 1 for each unknown; for one equation the interval midpoint).",
            "type": "string",
            "maxLength": 200
          },
          "tolerance": {
            "title": "Tolerance",
            "description": "Stop when the bracket, the step or the residual is below this value.",
            "type": "number",
            "minimum": 1e-16,
            "maximum": 0.1,
            "default": 1e-12
          },
          "maxIterations": {
            "title": "Iteration limit",
            "type": "integer",
            "minimum": 1,
            "maximum": 10000,
            "default": 100
          }
        },
        "required": [
          "equations"
        ]
      },
      "ProoflineEquationSolverResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "problem",
              "method",
              "variables",
              "functions",
              "interval",
              "solutions",
              "converged",
              "message",
              "evaluations",
              "iterationTable"
            ],
            "properties": {
              "problem": {
                "type": "string",
                "enum": [
                  "equation",
                  "system",
                  "minimum",
                  "maximum"
                ]
              },
              "method": {
                "type": "string",
                "enum": [
                  "brent",
                  "bisection",
                  "newton",
                  "golden"
                ]
              },
              "variables": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "functions": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The expressions set to zero (equation lhs − rhs) or the function minimised/maximised."
              },
              "interval": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "number"
                  },
                  "to": {
                    "type": "number"
                  }
                }
              },
              "solutions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "x",
                    "f",
                    "kind",
                    "iterations"
                  ],
                  "properties": {
                    "x": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "f": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      },
                      "description": "Residuals at x (equations) or the function value (extrema)."
                    },
                    "kind": {
                      "type": "string"
                    },
                    "iterations": {
                      "type": "integer"
                    }
                  }
                }
              },
              "converged": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              },
              "evaluations": {
                "type": "integer"
              },
              "iterationTable": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "columns",
                  "rows"
                ],
                "properties": {
                  "columns": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": [
                          "number",
                          "null"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}