# SHZ_ATAN2F_TERMS

Source: https://sh4zam.com/api/trig/SHZ_ATAN2F_TERMS/

> Number of terms in the arctangent polynomial used by shz_atan2f()

```c
#define SHZ_ATAN2F_TERMS 5
```

Number of terms in the arctangent polynomial used by `shz_atan2f()`.

## Details

`shz_atan2f()` reduces its arguments to a quotient `r` within `[-1, 1]` and evaluates `atan(r) = r * P(r^2)`. This selects the length of `P`: each additional term is one more multiply-accumulate.

| Terms | Degree | Maximum error (radians) | Cycles (model) |
| --- | --- | --- | --- |
| 2 | 3 | 6.2e-3 | 36 |
| 5 | 9 | 1.4e-5 | 45 |
| 6 | 11 | 2.5e-6 | 46 |
| 7 | 13 | 1.0e-6 | 49 |

Defaults to 5. To change it, define it as 2, 5, 6, or 7 for the entire build (on the compiler's command line), so that every translation unit and the library itself agree.

## Notes

- The cycle counts are estimates from a pipeline model of the SH4 for one call within a loop over an array, with every access a cache hit. They are there to compare the settings with each other and are not measurements taken on a console.

## Availability

- **C++ equivalent:** none (usable from C++ as is)
- **Back-ends:** n/a (not a function)
- **Defined in:** [`sh4zam/shz_trig.h:73`](https://github.com/gyrovorbis/sh4zam/blob/6b22b851ad9ca109049f956dbbbecf7c519c959f/include/sh4zam/shz_trig.h#L73)
- **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros"

## See also

[`shz_atan2f`](https://sh4zam.com/api/trig/shz_atan2f/), [`SHZ_ATAN2F_ERROR_MAX`](https://sh4zam.com/api/trig/SHZ_ATAN2F_ERROR_MAX/)
