Home/Tools/definite_integral

Definite integral

Evaluate a definite integral ∫_a^b f(x) dx by computing the antiderivative and applying the bounds.

Endpoint: POST /api/v1/definite_integral

When to use

Evaluate ∫ₐᵇ f(x) dx by computing the antiderivative once and applying the bounds. Bounds may be symbolic (e.g. `pi`, `n`).

Input schema

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

{
  "type": "object",
  "properties": {
    "expression": {
      "type": "string",
      "minLength": 1
    },
    "variable": {
      "type": "string",
      "minLength": 1
    },
    "from": {
      "type": "string",
      "minLength": 1
    },
    "to": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "expression",
    "variable",
    "from",
    "to"
  ],
  "additionalProperties": false
}

Response shape

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

FieldTypeDescription
resultstringResulting expression in nerdamer syntax.

Example

Request

{
  "expression": "sin(x)",
  "variable": "x",
  "from": "0",
  "to": "pi"
}

Response

{
  "ok": true,
  "result": {
    "result": "2"
  }
}

curl

curl -X POST https://tools.aieo.se/api/v1/definite_integral \
  -H 'Content-Type: application/json' \
  -d '{"expression":"sin(x)","variable":"x","from":"0","to":"pi"}'

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": "definite_integral",
    "arguments": {
      "expression": "sin(x)",
      "variable": "x",
      "from": "0",
      "to": "pi"
    }
  }
}

Common errors

  • Antiderivative is unevaluable.
    Bounds substitution leaves a symbolic `integrate(…)` placeholder in the result.
  • Integrand has a singularity inside the interval.
    Result may be `Infinity`, `NaN`, or a wrong finite value — no automatic detection.
  • 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`.