Home/Tools/solve_system

Solve system

Analytically solve a system of equations for given variables.

Endpoint: POST /api/v1/solve_system

When to use

Solve a linear or polynomial system for several variables simultaneously.

Input schema

Validated server-side with Zod. The same schema feeds OpenAPI and the MCP tool list.

{
  "type": "object",
  "properties": {
    "equations": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "description": "List of equations, e.g. ['x+y=3','x-y=1']"
    },
    "variables": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "description": "Variables to solve for, e.g. ['x','y']"
    }
  },
  "required": [
    "equations",
    "variables"
  ],
  "additionalProperties": false
}

Response shape

All tools return { ok: true, result } on success and { ok: false, error } on failure. The result object contains:

FieldTypeDescription
solutionsRecord<string,string>[]Array of solutions; each is a map of variable → expression.

Example

Request

{
  "equations": [
    "x + y = 3",
    "x - y = 1"
  ],
  "variables": [
    "x",
    "y"
  ]
}

Response

{
  "ok": true,
  "result": {
    "solutions": [
      {
        "x": "2",
        "y": "1"
      }
    ]
  }
}

curl

curl -X POST https://tools.aieo.se/api/v1/solve_system \
  -H 'Content-Type: application/json' \
  -d '{"equations":["x + y = 3","x - y = 1"],"variables":["x","y"]}'

MCP call (JSON-RPC)

MCP clients call this tool as tools/call against /api/mcp:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "solve_system",
    "arguments": {
      "equations": [
        "x + y = 3",
        "x - y = 1"
      ],
      "variables": [
        "x",
        "y"
      ]
    }
  }
}

Common errors

  • Number of variables does not match the system.
    Nerdamer throws or returns an empty result.
  • System is inconsistent or under-determined.
    Empty `solutions` array.
  • A required field is missing or has the wrong type.
    Zod validation error, e.g. `Required` or `Expected string, received number`.
  • Nerdamer cannot parse the expression (unbalanced parens, unknown function, stray characters).
    `Unexpected token …` or `… is not a valid expression`.