AI (artificial intelligence) gets engineering calculations right some of the time, and you can't tell which time.
The fix is to have the AI write the calculation report in the .qmd format.
This results in not only increased confidence in results (as calculations are produced deterministically from embedded Python scripts) but also repeatability - you set up the calculation report once, and the AI can easily update the calculation inputs relevant to the specifics of the problem.
Why AI engineering calculations go wrong
With reasoning turned on, leading models are now good at raw arithmetic. The problem is that they are probabilistic: they predict the most likely answer rather than calculate it. In practice that shows up three ways:
-
Same question, different answer: even at temperature 0, AI models don't return the same output every time.
-
More complexity, less accuracy: Apple found that reasoning models' accuracy collapses beyond a certain problem complexity.
-
Wrong answers presented as right: OpenAI says models hallucinate because training rewards confident guessing over admitting uncertainty.
The fix is to give the AI the right context (method, clause and inputs) and to let deterministic code, not the model, produce the numbers. This allows the LLM (large language model) to have a significantly higher chance to predict the correct answer in a more repeatable way.
Options
Some options we can consider to resolve the context and determinism issues are as follows:
- Chatbot with the standard and method attached (e.g. a ChatGPT Project or Custom GPT)
- Context: better. The AI can read the clause and your preferred method.
- Determinism: no. The model still predicts the numbers, so the answer can change between chats.
- Chatbot with a code interpreter
- Context: only what you paste into that chat.
- Determinism: partial. Python computes the numbers, but the code is rewritten fresh each chat, so the method can change.
- Spreadsheet template
- Context: the method is fixed in the cell formulas, but the clause and assumptions are hidden in cells.
- Determinism: yes. Same inputs, same answer. But the working is hard to review.
.qmdcalculation report- Context: the workflow, process, method, clause references and inputs live in the report.
- Determinism: yes. Python computes every number, and the saved code re-runs the same way on the next job.
Recommendation: a .qmd calculation report
A .qmd file is a Quarto document: prose and equations, with the calculation as Python code in between. When Quarto renders it, the code runs and the results are written into the report, for example a PDF or DOCX (Microsoft Word document) file.
That solves each problem above:
- Same question, different answer: the numbers come from saved Python code, not the model, so the same inputs always give the same result.
- More complexity, less accuracy: the method, clauses and inputs are written into the report, so the AI follows a fixed method instead of working it out from scratch each time.
- Wrong answers presented as right: every input, formula and clause is in the document, so mistakes are visible and can be checked.
Each fix comes down to the same two things: the report gives the AI accurate context to work from, and Python, not the model, produces the numbers. Resulting in a much higher likelihood of the correct output being produced.
A domain expert builds the report once with the AI: they choose the method, check the code against the standard and approve it. On the next job, you change the inputs and re-run it. If the code is right, every number is right, and it stays right when the inputs change.
Worked example: ASME B31.3 minimum wall thickness
An NPS (Nominal Pipe Size) 6 carbon steel process line is due for its integrity review. The latest UT (ultrasonic testing) survey found a minimum wall of 5.8 mm. Is it still fit for its 8 MPa (megapascal) design pressure?
ASME (American Society of Mechanical Engineers) B31.3 para. 304.1.2 gives the pressure design thickness of straight pipe, valid for :
Where is the design pressure, the outside diameter, the allowable stress (Table A-1M), the quality factor (Table A-1B), the weld joint strength reduction factor (para. 302.3.5), the coefficient from Table 304.1.1 and the corrosion allowance. The line passes if the measured wall is at least .
The .qmd file
An AI writes the whole report as one file: every input with its source, the method with its clause references, and the Python that computes every number. To run it yourself, save it as calc.qmd, install Quarto and pip install handcalcs, then run quarto render calc.qmd.
---title: "ASME B31.3 minimum wall thickness"subtitle: "NPS 6 carbon steel process line, UT survey 2026"execute:output: asis---```{python}#| include: falsefrom handcalcs.decorator import handcalc# Every input with its unit and source, so the reviewer can check it without asking.inputs = {"P": (8.0, "MPa", "Line list, design pressure"),"T": (150, "°C", "Line list, design temperature"),"D": (168.3, "mm", "NPS 6 outside diameter, ASME B36.10M"),"S": (138.0, "MPa", "B31.3 Table A-1M, A106 Gr B at 150 °C"),"E": (1.0, "", "B31.3 Table A-1B, seamless"),"W": (1.0, "", "B31.3 para. 302.3.5, below 427 °C"),"Y": (0.4, "", "B31.3 Table 304.1.1, ferritic below 482 °C"),"c": (1.5, "mm", "Piping class corrosion allowance"),"t_meas": (5.8, "mm", "UT survey 2026, minimum reading"),}globals().update({name: value for name, (value, unit, source) in inputs.items()})```## Inputs```{python}print("")print("| Input | Value | Unit | Source |")print("|:---|---:|:---|:---|")for name, (value, unit, source) in inputs.items():print(f"| `{name}` | {value} | {unit} | {source} |")print("")```## Pressure design thickness (B31.3 para. 304.1.2)Valid for straight pipe where $t < D/6$.```{python}@handcalc(override="long", jupyter_display=False, precision=2)def _thickness(P=P, D=D, S=S, E=E, W=W, Y=Y, c=c):t = P * D / (2 * (S * E * W + P * Y)) # pressure design thickness, mmt_m = t + c # minimum required thickness, mmreturn locals()_latex, _vars = _thickness()print(_latex)globals().update(_vars)assert t < D / 6, "para. 304.1.2 only applies where t < D/6"```## Result```{python}checks = [("Pressure design thickness, $t$", "304.1.2", f"{t:.2f} mm", f"{t_meas:.2f} mm", t / t_meas),("Minimum required thickness, $t_m = t + c$", "304.1.2", f"{t_m:.2f} mm", f"{t_meas:.2f} mm", t_m / t_meas),]print("")print("| Check | Clause | Required | Actual | Utilisation | Result |")print("|:---|:---|---:|---:|---:|:---|")for check, clause, required, actual, utilisation in checks:result = "PASS" if utilisation <= 1 else "**FAIL**"print(f"| {check} | {clause} | {required} | {actual} | {utilisation:.2f} | {result} |")print("")```
What it renders to
A preview of the report Quarto produces. The Python is hidden, and handcalcs prints each formula with the inputs substituted, so a reviewer can check the working line by line.
ASME B31.3 minimum wall thickness
NPS 6 carbon steel process line, UT survey 2026
Inputs
| Input | Value | Unit | Source |
|---|---|---|---|
P | 8.0 | MPa | Line list, design pressure |
T | 150 | °C | Line list, design temperature |
D | 168.3 | mm | NPS 6 outside diameter, ASME B36.10M |
S | 138.0 | MPa | B31.3 Table A-1M, A106 Gr B at 150 °C |
E | 1.0 | B31.3 Table A-1B, seamless | |
W | 1.0 | B31.3 para. 302.3.5, below 427 °C | |
Y | 0.4 | B31.3 Table 304.1.1, ferritic below 482 °C | |
c | 1.5 | mm | Piping class corrosion allowance |
t_meas | 5.8 | mm | UT survey 2026, minimum reading |
Pressure design thickness (B31.3 para. 304.1.2)
Valid for straight pipe where .
Result
| Check | Clause | Required | Actual | Utilisation | Result |
|---|---|---|---|---|---|
| Pressure design thickness, | 304.1.2 | 4.77 mm | 5.80 mm | 0.82 | PASS |
| Minimum required thickness, | 304.1.2 | 6.27 mm | 5.80 mm | 1.08 | FAIL |
Result
The line still holds its design pressure today: 5.8 mm is above the 4.77 mm pressure design thickness . But it no longer carries the 1.5 mm corrosion allowance, so it is below the B31.3 minimum required thickness of 6.27 mm and needs action.
- Derate: lower the design pressure until is no more than the measured wall (re-run the report with a lower ).
- Replace the corroded spool with new Sch (Schedule) 40 pipe.
- Assess fitness for service to API (American Petroleum Institute) 579-1/ASME FFS-1 (Fitness-For-Service) if the thinning is local, and shorten the inspection interval under API 570.
The report is a design aid. The responsible engineer reviews it, picks the remediation and signs it off.
Change t_meas to 5.6 mm and the report re-renders in seconds with the same checks: the required thickness stays 6.27 mm, the utilisation rises, and the result is still FAIL.
Try it on your next calc
Pantha can run this on your own computer, works with the files where they already live, and shows every step it takes. Contact us for the calc-report skill file and run your first check today.
Try it forFreeEvery new account gets 1M credits.