# Instruction Complexity

The complexity of an instruction depends on its type, the input arguments it processes, and the cryptographic parameters influencing its execution. For operations involving encrypted data, the same instruction can have varying complexity based on the input ciphertexts and the cryptographic context.

#### Factors Affecting Instruction Complexity

1. **Input Arguments**\
   The data passed to the instruction, such as ciphertexts, influences complexity.
2. **Cryptographic Parameters**\
   Contextual settings that define the operational environment, including:
   * **Ring Dimension (N):** Determines the size of polynomial arithmetic, affecting computational cost.
   * **Scaling Factor (Δ):** Influences the precision of encrypted computations.
   * **Security Level:** Indicates the cryptographic strength and associated resource requirements.

#### Example: Encrypted Multiplication

For the instruction `fhe.bgv.mult` (multiplication of encrypted values), the complexity is affected by:

* **Ciphertexts:**
  * **Multiplicative Depth (D):** Indicates how many operations have been performed on the ciphertext. Higher depth increases complexity due to relinearization and modulus switching.
* **CryptoContext Parameters:**
  * **Ring Dimension (N):** Governs the cost of polynomial operations.
  * **Scaling Factor (Δ):** Affects the precision and associated computation.

For each instruction there is cost function that evaluates its complexity based on the given input and cryptographic environment.&#x20;


---

# Agent Instructions: 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:

```
GET https://docs.fairmath.xyz/fhe-computer/operating-system/order-book/instruction-complexity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
