Math & Numbers
用 Newton-Raphson 迭代 x_{k+1} = x_k − f(x_k)/f'(x_k) 求 f(x) = 0 的根:导数可给定解析表达式(留空则用中心差分数值导数),输出逐步迭代表(x_k 与 f(x_k))、收敛判据(|f| < 容差或 |Δx| < 容差·max(1,|x|))、迭代次数与最终 |f(root)|。经典例:x²−2 从 x₀=1 出发 4 步收敛到 √2 ≈ 1.4142135624;cos(x)−x 收敛到 Dottie 数 0.7390851332。导数为零、步长发散或超出迭代上限会明确报告。
用三种语言从你的代码中调用此工具。
curl -X POST 'http://127.0.0.1:3003/zh/api/tools/newton-raphson-root-finder' \
-H 'Content-Type: application/json' \
-d '{"fxExpr":"x^2 - 2","dfxExpr":"","x0":1,"tolerance":1e-10,"maxIter":50,"decimalPlaces":10}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST http://127.0.0.1:3003/zh/api/tools/newton-raphson-root-finder| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| fxExpr | text | 是 | The function whose root is sought, in the variable x. Supports + - * / ^, parentheses, and functions like exp, sin, cos, sqrt, ln. |
| dfxExpr | text | 否 | Optional analytic derivative; when blank a central difference (h ≈ 1e-7) is used. |
| x0 | number | 否 | Starting point of the iteration. |
| tolerance | number | 否 | Convergence threshold on |f(x)| and on the step size. |
| maxIter | number | 否 |
将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-newton-raphson-root-finder": {
"name": "newton-raphson-root-finder",
"description": "用 Newton-Raphson 迭代 x_{k+1} = x_k − f(x_k)/f'(x_k) 求 f(x) = 0 的根:导数可给定解析表达式(留空则用中心差分数值导数),输出逐步迭代表(x_k 与 f(x_k))、收敛判据(|f| < 容差或 |Δx| < 容差·max(1,|x|))、迭代次数与最终 |f(root)|。经典例:x²−2 从 x₀=1 出发 4 步收敛到 √2 ≈ 1.4142135624;cos(x)−x 收敛到 Dottie 数 0.7390851332。导数为零、步长发散或超出迭代上限会明确报告。",
"baseUrl": "http://127.0.0.1:3003/mcp/sse?toolId=newton-raphson-root-finder",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "newton-raphson-root-finder",
"arguments": {
"fxExpr": "x^2 - 2",
"dfxExpr": "",
"x0": 1,
"tolerance": 1e-10,
"maxIter": 50,
"decimalPlaces": 10
}
}
}有问题或反馈?请联系 [email protected]
| Hard cap on the number of iterations (2–200). |
| decimalPlaces | number | 否 | — |
文本结果
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}