# new_walsh_sequence

Source: https://docs.q-ctrl.com/references/qctrl-open-controls/qctrlopencontrols/new_walsh_sequence

```python
qctrlopencontrols.new_walsh_sequence(duration, paley_order, pre_post_rotation=False, name=None)
```

Creates the Walsh sequence.

### Parameters
* **duration** (*float*) – Total duration of the sequence $\tau$ (in seconds).
* **paley_order** (*int*) – The paley order $k$ of the Walsh sequence.
* **pre_post_rotation** (*bool* *,* *optional*) – If `True`, a $X_{\pi/2}$ rotation is added at the
  start and end of the sequence. Defaults to `False`.
* **name** (*string* *,* *optional*) – Name of the sequence. Defaults to `None`.
### Returns
The Walsh sequence.
### Return type
[DynamicDecouplingSequence](https://docs.q-ctrl.com/references/qctrl-open-controls/qctrlopencontrols/DynamicDecouplingSequence.md#qctrlopencontrols.DynamicDecouplingSequence)

## Notes

The Walsh sequence is defined by the switching function $y(t)$ given by a
Walsh function. To define the Walsh sequence, we first introduce the Rademacher
function <sup>[1](#id3)</sup>, which is defined as

$$
R_j(x) := {\mathrm sgn}\left[\sin(2^j \pi x)\right] \;,
\quad\; x \in [0, 1]\;, \; j \geq 0 \;.
$$

The $j$-th Rademacher function $R_j(x)$ is thus a periodic square wave switching
$2^{j-1}$ times between $\pm 1$ over the interval $[0, 1]$. The Walsh
function of Paley order $k$ is denoted ${\mathrm PAL}_k(x)$ and defined as

$$
{\mathrm PAL}_k(x) = \Pi_{j = 1}^m R_j(x)^{b_j} \;, \quad\; x \in [0, 1] \;.
$$

where $(b_m, b_{m-1}, \cdots, b_1)$ is the binary representation of $k$.
That is

$$
k = b_m 2^{m-1} + b_{m-1}2^{m-2} + \cdots + b_12^0 \;,
$$

where $m = m(k)$ indexes the most significant binary bit of $k$.

The $k$-th order Walsh sequence <sup>[2](#id4)</sup> is then defined by

$$
y(t) = {\mathrm PAL}_k(t / \tau) \;
$$

with offset times $\{t_j / \tau\}$ defined at the switching times of the Walsh function.

## References

* <a id='id3'>**[1]**</a> [H. Rademacher, Math. Ann. 87, 112–138 (1922).](https://doi.org/10.1007/BF01458040)
* <a id='id4'>**[2]**</a> [H. Ball and M. J Biercuk, EPJ Quantum Technol. 2, 11 (2015).](https://doi.org/10.1140/epjqt/s40507-015-0022-4)
