Evaluate Wolfram Language code
mathematica_evaluateEvaluate Wolfram Language (Mathematica) code in a persistent local kernel that preserves variables and returns InputForm results, capturing printed output and messages.
Instructions
Evaluate Wolfram Language (Mathematica) code in a persistent local kernel and return the result in InputForm. Variables and function definitions persist between calls. Printed output is captured in "output", and printed messages are listed in "messages". Requires a locally licensed Mathematica or the free Wolfram Engine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Wolfram Language source code to evaluate, e.g. "2+2", "Plot[Sin[x], {x, 0, 2 Pi}]", or a multi-line program. It is parsed with ToExpression, so newline-separated statements are evaluated in order. | |
| timeout_seconds | No | Maximum evaluation time in seconds (default 60). On timeout the evaluation is aborted and the kernel stays usable. |