> For the complete documentation index, see [llms.txt](https://devs.novanet.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devs.novanet.xyz/jolt-atlas-zkml/onnx/tensor-instructions/virtual-instructions/sigmoid.md).

# Sigmoid

The quantized sigmoid function is defined as follows:

$$\sigma\_Q(x) = \dfrac{Q}{1 + 2^{-x}}$$

where $Q$ is the quantization (scaling) factor. We use $2$ instead of $e$ to avoid floating point operations.

### Implementation

| Step | Operation       | Description                                                                          |
| ---- | --------------- | ------------------------------------------------------------------------------------ |
| 1    | VirtualConst(0) | Create constant zero tensor for comparisons                                          |
| 2    | Gte             | Compute `ge0 = (z >= 0)` to track sign of input                                      |
| 3    | Sub             | Compute `neg_z = -z` for absolute value calculation                                  |
| 4    | Select          | Compute `abs_z = select(ge0, z, -z)` (absolute value)                                |
| 5    | VirtualPow2     | Compute \`pow2 = 2^{                                                                 |
| 6    | VirtualConst(Q) | Load quantization constant `Q`                                                       |
| 7    | Mul             | Compute `Q² = Q * Q`                                                                 |
| 8    | Div             | Compute \`div\_Q\_pow = Q / 2^{                                                      |
| 9    | Mul             | Compute \`mul\_Q\_pow = Q \* 2^{                                                     |
| 10   | Select          | Compute `a = select(ge0, div_Q_pow, mul_Q_pow)` (choose branch based on sign of `z`) |
| 11   | Add             | Compute `b = Q + a`                                                                  |
| 12   | Div             | Compute `c = Q² / b` → final quantized sigmoid output `σ_Q(z)`                       |
| 13   | VirtualMove     | Move final tensor `c` to output destination                                          |


---

# 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://devs.novanet.xyz/jolt-atlas-zkml/onnx/tensor-instructions/virtual-instructions/sigmoid.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.
