{
  "openapi": "3.1.1",
  "info": {
    "title": "Step-by-Step Equation Solver API",
    "version": "1.0.0",
    "summary": "Solve linear, quadratic, rational and radical equations or linear systems with every step shown.",
    "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://equationsolversteps.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Solve linear, quadratic, rational and radical equations or linear systems with every step shown.",
        "description": "Shows the full working for linear and quadratic equations (factoring, completing the square or the quadratic formula), rational equations with domain restrictions, radical equations, higher polynomials and systems of 2–6 linear equations solved by Gaussian elimination with exact fractions. Every answer is checked by substitution and extraneous roots are flagged.\n\nMethodology:\n- Everything is moved to one side and simplified with exact fractions. The equation type is detected: polynomial (by degree), rational (variable in a denominator), radical (variable under a root), single occurrence of the variable (isolated with inverse operations), otherwise numeric.\n- Quadratics: factoring when the discriminant is a perfect square, completing the square or the quadratic formula on request; complex solutions are shown when the discriminant is negative.\n- Higher polynomials: the rational root theorem finds all rational roots exactly; a remaining quadratic is solved exactly, larger remainders numerically with the Durand–Kerner method.\n- Rational equations: the denominators are factored, values that make them zero are excluded, both sides are multiplied by the least common denominator, and candidates in the excluded set are rejected as extraneous.\n- Radical equations: the radical is isolated and both sides raised to the root’s power (repeated for a second radical); each candidate is substituted into the original equation and rejected if it fails.\n- Linear systems: Gauss–Jordan elimination on the augmented matrix with exact fractions, showing every row operation; inconsistent and dependent systems are recognised.",
        "tags": [
          "math"
        ],
        "x-mcp-tool": "equation_solver_steps",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EquationSolverStepsInput"
              },
              "examples": {
                "example1": {
                  "summary": "Quadratic by completing the square",
                  "value": {
                    "equations": "x^2 + 6x + 5 = 0",
                    "method": "square"
                  }
                },
                "example2": {
                  "summary": "Quadratic formula with surds",
                  "value": {
                    "equations": "2x^2 + 3x - 4 = 0",
                    "method": "formula"
                  }
                },
                "example3": {
                  "summary": "Rational equation with an excluded value",
                  "value": {
                    "equations": "x/(x-2) + 1/(x+2) = 8/(x^2-4)"
                  }
                },
                "example4": {
                  "summary": "Radical equation with an extraneous root",
                  "value": {
                    "equations": "sqrt(x + 3) = x - 3"
                  }
                },
                "example5": {
                  "summary": "Linear system with 3 unknowns",
                  "value": {
                    "equations": "x + y + z = 6\n2y + 5z = -4\n2x + 5y - z = 27"
                  }
                },
                "example6": {
                  "summary": "Cubic equation",
                  "value": {
                    "equations": "x^3 - 2x^2 - 5x + 6 = 0"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EquationSolverStepsResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "EquationSolverStepsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "equations": {
            "title": "Equation(s)",
            "description": "One equation per line. Several lines form a linear system (e.g. \"2x + y = 5\" and \"x - y = 1\").",
            "type": "string",
            "maxLength": 2000
          },
          "variable": {
            "title": "Solve for",
            "description": "Optional. Defaults to x (or the only variable). For systems: a comma-separated list of unknowns.",
            "type": "string",
            "maxLength": 60
          },
          "method": {
            "title": "Method for quadratics",
            "type": "string",
            "enum": [
              "auto",
              "factoring",
              "square",
              "formula"
            ],
            "default": "auto"
          },
          "searchMin": {
            "title": "Numeric search from",
            "description": "Only used when no symbolic method applies (e.g. cos(x) = x).",
            "type": "number",
            "default": -100
          },
          "searchMax": {
            "title": "Numeric search to",
            "type": "number",
            "default": 100
          }
        },
        "required": [
          "equations"
        ]
      },
      "EquationSolverStepsResult": {
        "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": [
              "type",
              "equation",
              "variables",
              "kind",
              "method",
              "status",
              "solutions",
              "extraneous",
              "excluded",
              "verification",
              "steps",
              "matrixSteps",
              "notes"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "single",
                  "system"
                ]
              },
              "equation": {
                "type": "string"
              },
              "variables": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "kind": {
                "type": "string"
              },
              "method": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "solved",
                  "no-solution",
                  "identity",
                  "infinite"
                ]
              },
              "solutions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "variable",
                    "value",
                    "latex",
                    "exact",
                    "real",
                    "imaginary"
                  ],
                  "properties": {
                    "variable": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    },
                    "latex": {
                      "type": "string"
                    },
                    "exact": {
                      "type": "boolean"
                    },
                    "real": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "imaginary": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Imaginary part for complex solutions, otherwise null."
                    }
                  }
                }
              },
              "extraneous": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "value",
                    "reason"
                  ],
                  "properties": {
                    "value": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              },
              "excluded": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "verification": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "solution",
                    "lhs",
                    "rhs",
                    "ok"
                  ],
                  "properties": {
                    "solution": {
                      "type": "string"
                    },
                    "lhs": {
                      "type": "string"
                    },
                    "rhs": {
                      "type": "string"
                    },
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "steps": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "matrixSteps": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "operation",
                    "matrix"
                  ],
                  "properties": {
                    "operation": {
                      "type": "string"
                    },
                    "matrix": {
                      "type": "string"
                    }
                  }
                }
              },
              "notes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}