> For the complete documentation index, see [llms.txt](https://docs.nexus.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexus.xyz/math-engine/math-engine.md).

# Overview

The Math Engine derives the Exchange's mathematics directly from its own implementation, rather than describing it by hand: every expression on these pages is extracted from the Exchange's source code, adversarially checked against it and its own test suite, and versioned with a changelog whenever the underlying mathematics genuinely changes.

## Pages

* [`engine.md`](/math-engine/engine.md) — the engine itself, formalized: how expressions are derived and verified, what each stage guarantees, and what is not yet verified.
* [`global.md`](/math-engine/global.md) — the global state-space model composed across all systems.
* [`system.md`](/math-engine/system.md) — the cross-model relationship graph: how expressions in one system feed, bound, or trigger expressions in another.
* [`closed-loop.md`](/math-engine/closed-loop.md) — the oracle-endogenous closed loop.
* [`funding-rate.md`](/math-engine/funding-rate.md), [`margin-math.md`](/math-engine/margin-math.md), [`liquidation-engine.md`](/math-engine/liquidation-engine.md), [`oracle.md`](/math-engine/oracle.md), [`order-book.md`](/math-engine/order-book.md), [`position-tracker.md`](/math-engine/position-tracker.md), [`insurance-fund.md`](/math-engine/insurance-fund.md), [`settlement.md`](/math-engine/settlement.md) — per-system derived mathematics: expressions, invariants, and citations into the source.
* [`performance.md`](/math-engine/performance.md) — analytical performance/scaling model fitted to benchmark data.

## How this is produced

Each expression is derived from the Exchange's implementation, then checked by an independent adversarial pass whose only goal is to try to disprove it against the code and the code's own tests. See [`engine.md`](/math-engine/engine.md) for the full trust model and its known limits.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexus.xyz/math-engine/math-engine.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
