Math & Numbers
用经典四阶 Runge-Kutta(RK4)法求解初值问题 dy/dx = f(x,y)、y(x₀)=y₀:每步计算 k1–k4 四个斜率并加权更新 y_{n+1} = y_n + h/6·(k1+2k2+2k3+k4),全局误差 O(h⁴)——步长减半误差约缩小 16 倍。输出逐步数值表、前几步的 k1–k4 明细与最终估计;可选填精确解 y(x) 显示误差列。示例:dy/dx = y、y(0)=1、h=0.1 时 y(1) ≈ 2.718282,与 e 几乎一致。
用三种语言从你的代码中调用此工具。
curl -X POST 'http://127.0.0.1:3003/zh/api/tools/runge-kutta-rk4-solver' \
-H 'Content-Type: application/json' \
-d '{"fxy":"y","x0":0,"y0":1,"xEnd":1,"steps":10,"exactY":"e^x","decimalPlaces":6}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST http://127.0.0.1:3003/zh/api/tools/runge-kutta-rk4-solver| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| fxy | text | 是 | Right-hand side in terms of x and y (functions: sin, cos, exp, ln, sqrt, …). Write products with *, e.g. x*y. |
| x0 | number | 是 | — |
| y0 | number | 是 | — |
| xEnd | number | 是 | Must be greater than x₀. |
| steps | number | 是 | h = (target x − x₀)/n. More steps → smaller error, O(h⁴) globally. |
| exactY |
将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-runge-kutta-rk4-solver": {
"name": "runge-kutta-rk4-solver",
"description": "用经典四阶 Runge-Kutta(RK4)法求解初值问题 dy/dx = f(x,y)、y(x₀)=y₀:每步计算 k1–k4 四个斜率并加权更新 y_{n+1} = y_n + h/6·(k1+2k2+2k3+k4),全局误差 O(h⁴)——步长减半误差约缩小 16 倍。输出逐步数值表、前几步的 k1–k4 明细与最终估计;可选填精确解 y(x) 显示误差列。示例:dy/dx = y、y(0)=1、h=0.1 时 y(1) ≈ 2.718282,与 e 几乎一致。",
"baseUrl": "http://127.0.0.1:3003/mcp/sse?toolId=runge-kutta-rk4-solver",
"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": "runge-kutta-rk4-solver",
"arguments": {
"fxy": "y",
"x0": 0,
"y0": 1,
"xEnd": 1,
"steps": 10,
"exactY": "e^x",
"decimalPlaces": 6
}
}
}有问题或反馈?请联系 [email protected]
| text |
| 否 |
| Exact solution in x, used to add an error column. Leave empty to skip. |
| decimalPlaces | number | 否 | — |
文本结果
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}