{
  "openapi": "3.1.1",
  "info": {
    "title": "Matrix & Linear Algebra Lab API",
    "version": "1.0.0",
    "summary": "Exact-fraction RREF with steps, determinant, inverse, null space, eigenvalues, LU/QR and Ax = b.",
    "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://matrixlinearalgebralab.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Exact-fraction RREF with steps, determinant, inverse, null space, eigenvalues, LU/QR and Ax = b.",
        "description": "Enter matrices with whole numbers, fractions or decimals and get exact results: row reduction with every row operation, determinant, inverse, rank, null space, A + B, A·B and solutions of A x = b. Eigenvalues are exact for 2×2/3×3 cases with rational or quadratic roots and numeric (shifted QR algorithm) otherwise; LU, QR and the condition number are computed numerically.\n\nMethodology:\n- Entries are parsed as exact fractions (BigInt numerators and denominators), so row reduction, determinants, inverses, ranks, null spaces and solutions of A x = b are exact, with no rounding.\n- Row reduction is Gauss–Jordan elimination: swap to a non-zero pivot, scale the pivot row to 1, clear the column above and below; every operation is listed with the matrix after it.\n- Eigenvalues: the characteristic polynomial is computed exactly (Faddeev–LeVerrier). Rational roots and a remaining quadratic give exact eigenvalues (with surds or complex values); otherwise the matrix is reduced to Hessenberg form and the shifted QR algorithm finds the eigenvalues numerically. Eigenvectors are exact null spaces for rational eigenvalues and numeric (inverse iteration) otherwise.\n- LU uses partial pivoting (P·A = L·U); QR uses Householder reflections; the condition number is σmax/σmin from the singular values (Jacobi eigenvalues of AᵀA). These are double-precision numeric results.",
        "tags": [
          "math"
        ],
        "x-mcp-tool": "matrix_linear_algebra_lab",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MatrixLinearAlgebraLabInput"
              },
              "examples": {
                "example1": {
                  "summary": "Overview of a 3×3 matrix",
                  "value": {
                    "operation": "analyze",
                    "matrixA": "2 0 0\n0 3 4\n0 4 9"
                  }
                },
                "example2": {
                  "summary": "Solve A x = b with steps",
                  "value": {
                    "operation": "solve",
                    "matrixA": "2 1 -1\n-3 -1 2\n-2 1 2",
                    "vectorB": "8 -11 -3"
                  }
                },
                "example3": {
                  "summary": "Inverse with fractions",
                  "value": {
                    "operation": "inverse",
                    "matrixA": "1 2 3\n0 1 4\n5 6 0"
                  }
                },
                "example4": {
                  "summary": "Eigenvalues of a 2×2 matrix",
                  "value": {
                    "operation": "eigen",
                    "matrixA": "2 1\n1 3"
                  }
                },
                "example5": {
                  "summary": "Null space of a rank-deficient matrix",
                  "value": {
                    "operation": "nullspace",
                    "matrixA": "1 2 3\n2 4 6\n1 1 1"
                  }
                },
                "example6": {
                  "summary": "Product A·B",
                  "value": {
                    "operation": "multiply",
                    "matrixA": "1 2\n3 4",
                    "matrixB": "0 1\n1 0"
                  }
                },
                "example7": {
                  "summary": "QR decomposition",
                  "value": {
                    "operation": "qr",
                    "matrixA": "12 -51 4\n6 167 -68\n-4 24 -41"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MatrixLinearAlgebraLabResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "MatrixLinearAlgebraLabInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "operation": {
            "title": "Operation",
            "type": "string",
            "enum": [
              "analyze",
              "rref",
              "determinant",
              "inverse",
              "rank",
              "nullspace",
              "transpose",
              "add",
              "subtract",
              "multiply",
              "solve",
              "lu",
              "qr",
              "eigen",
              "condition"
            ],
            "default": "analyze"
          },
          "matrixA": {
            "title": "Matrix A",
            "description": "One row per line (or rows separated by ;), entries separated by spaces or commas. Fractions like 1/3 and decimals are fine. Up to 10×10.",
            "type": "string",
            "maxLength": 4000
          },
          "matrixB": {
            "title": "Matrix B",
            "description": "Only for A + B, A − B and A · B.",
            "type": "string",
            "maxLength": 4000
          },
          "vectorB": {
            "title": "Right-hand side b",
            "description": "Only for \"Solve A x = b\": one number per row of A.",
            "type": "string",
            "maxLength": 1000
          }
        },
        "required": [
          "matrixA"
        ]
      },
      "MatrixLinearAlgebraLabResult": {
        "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": [
              "operation",
              "size",
              "exact",
              "matrix",
              "scalar",
              "scalarNumeric",
              "vectors",
              "factors",
              "eigen",
              "properties",
              "steps",
              "notes"
            ],
            "properties": {
              "operation": {
                "type": "string",
                "enum": [
                  "analyze",
                  "rref",
                  "determinant",
                  "inverse",
                  "rank",
                  "nullspace",
                  "transpose",
                  "add",
                  "subtract",
                  "multiply",
                  "solve",
                  "lu",
                  "qr",
                  "eigen",
                  "condition"
                ]
              },
              "size": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "rows",
                  "cols"
                ],
                "properties": {
                  "rows": {
                    "type": "integer"
                  },
                  "cols": {
                    "type": "integer"
                  }
                }
              },
              "exact": {
                "type": "boolean",
                "description": "True when every number is an exact fraction."
              },
              "matrix": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "description": "Resulting matrix (entries as exact fractions or decimals)."
              },
              "scalar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "scalarNumeric": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "vectors": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "description": "Null-space basis or solution vectors."
              },
              "factors": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "matrix"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "matrix": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              },
              "eigen": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "value",
                    "real",
                    "imaginary",
                    "multiplicity",
                    "exact",
                    "vectors"
                  ],
                  "properties": {
                    "value": {
                      "type": "string"
                    },
                    "real": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "imaginary": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "multiplicity": {
                      "type": "integer"
                    },
                    "exact": {
                      "type": "boolean"
                    },
                    "vectors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "properties": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "value"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  }
                }
              },
              "steps": {
                "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"
              }
            }
          }
        }
      }
    }
  }
}