> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/ehs/3.7/model-in-schematic-editor/define-the-solver-settings/how-to-choose-discretization-method-pade5-and-backward-euler.md).

# eHS Solver Discretization Methods

## Overview

There are two types of discretization methods available in Gen5 solver: **Backward Euler** and **PADE5**. Each of them has its own feature in terms of accuracy and stability. These methods are not always fit for a given circuit, so sometimes we have to choose a specific one. Before we make the decision, it is better to know some knowledges behind these methods to help us understand what is happening in the backend.

Keep in mind that all discretization methods are trying to use $$A\_d$$ (usually a rational function) to approximate $$e^{Ah}$$, where $$A$$ is the continuous matrix we are trying to discretize and $$h$$ is the time-step. We know thatcan be expressed as Taylor series in the following form:

$$
e^{Ah} = \sum\_{n=0}^{\infty} \frac{1}{n!} (Ah)^n = I + Ah + \frac{1}{2!}(Ah)^2 + \frac{1}{3!}(Ah)^3 + \dots\\\[8pt]
$$

If the expression of $$A\_d$$ matches the Taylor series till to the $$k$$ th order, then we say $$A\_d$$ is $$k$$ th order accurate and this method is a $$k$$ th order method. For example: if $$A\_d=I+Ah$$ (which is the expression of Forward Euler), it matches the Taylor series till to the first order, then we say the Forward Euler is a first order method.

## **Backward Euler**

Backward Euler is a well-known discretization method that is commonly used in many software packages. The expression of Backward Euler is as follows:

$$
A\_d = \frac{I}{I - Ah} = I + Ah + (Ah)^2 + (Ah)^3 + \dots\\\[8pt]
$$

It can be seen that it matches the Taylor series till to the first order. Therefore, Backward Euler is also a first order method, like Forward Euler. However, the advantage of Backward Euler over Forward Euler is that the former method is more numerical stable than the later method (another topic that will not be covered in this page).

All we have to remember is that in order to find its approximation $$A\_d$$, we need to use the identity matrix $$I$$ and matrix $$Ah$$, which does not pose too much pressure on numerical accuracy when doing matrix inverse. It is not very hard to calculate and not a high order method.

## **PADE5 (ART5) method**

PADE5, as its name implies, is a higher order (5th) method, which means the expression of $$A\_d$$ matches the Taylor series till to the 5th order. In order to do so, we have to introduce more terms in the rational function of $$A\_d$$. We are not going into the details of how we find those terms. All we have to keep in mind is that in order to match the 5th coefficient, 5 parameters have to be introduced. The expression of $$A\_d$$ is shown as follows.

$$
A\_d = \frac{\sum\_{i=0}^{2} c\_i (Ah)^i}{\sum\_{i=0}^{3} c\_i (Ah)^i}\\\[8pt]
$$

We can see that there are 2 terms (except identity matrix) on the numerator and 3 terms (except identity matrix) on the denominator. By suitably choosing those parameters $$c\_i$$, we can make $$A\_d$$ matches the Taylor series till to the 5th order.

On the other hand, the cost to achieving higher order accuracy is that we have to compute higher order of $$(Ah)^i$$, where $$i$$ could be 3. Usually the time-step we are using in our simulation is very small, for example 100 ns. Higher order of time-stepcould be an extremely small value. For example, $$h^3=10^{-21}$$ for $$h=100$$ ns. Let alone the fact that some values in matrix $$A$$ could also be very small. All of those factors add pressure into the numerical accuracy of matrix operations. We may reach the numerical limit of the data format in our computer or FPGA. That’s the reason why PADE5 is more accurate than Backward Euler but less numerical stable.

### **Possible options to improve this behavior**

We can see that the reason why PADE5 is more prone to numerical instability is coming from the numerical computation parts, not the equations or circuit itself. Some options we can consider to resolve this issue could be:

1. **Changing the time-step a little bit**. Sometimes a little change in time-step would affect the numerical results a lot because at some specific time-steps the numerical error will arise, for example, big value eats small value so that small value is totally discarded. Changing time-step will change the numerical pattern of those matrix values so that could be helpful.
2. **Changing the parameters in the circuit**. This option is similar to the first one except the changes are made in the matrix $$A$$.
3. **Using lower order method such Backward Euler**. If none of those options is possible or working, we can use a lower order method instead since lower order method has less pressure on numerical accuracy of computation.

These three options are not mutually exclusive to each other. Sometimes we can combine two or even three of them to achieve numerical stability.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/ehs/3.7/model-in-schematic-editor/define-the-solver-settings/how-to-choose-discretization-method-pade5-and-backward-euler.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
