# How can i calculate terms like atan2?

**URL:** <https://openfhe.discourse.group/t/how-can-i-calculate-terms-like-atan2/1170>\
**Category:** Library Questions\
**Created:** [April 3, 2024, 5:14pm UTC](https://openfhe.discourse.group/t/how-can-i-calculate-terms-like-atan2/1170 "2024-04-03T17:14:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moghit02](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@moghit02](https://openfhe.discourse.group/u/moghit02)\
**Post date:** [April 3, 2024, 5:14pm UTC](https://openfhe.discourse.group/t/how-can-i-calculate-terms-like-atan2/1170/1 "2024-04-03T17:14:15Z")

</div>

Is there a possibility to calculate [atan2](https://en.wikipedia.org/wiki/Atan2)? It tookes two input parameters, therefore I’m struggeling with cc-\>EvalChebyshevFunction

---

<div class="post-metadata">

**Author:** ![dcousins](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/dcousins/32/71_2.png) [@dcousins](https://openfhe.discourse.group/u/dcousins)\
**Post date:** [April 4, 2024, 3:06pm UTC](https://openfhe.discourse.group/t/how-can-i-calculate-terms-like-atan2/1170/2 "2024-04-04T15:06:26Z")

</div>

Hi. I’d recommend you read up on the wikipedia article. in it you see that : ![{extstyle heta =peratorname {atan2} (y,x)=rctan eft(y/xight).}](https://wikimedia.org/api/rest_v1/media/math/render/svg/36cecf46a952d6703ac8fe2feb0c088eb358a086)  
so one might try first the eval division function then an eval chebychev polynomial approximation of atan. However if you read the article you can see there needs to be a correction if x\< 0, so depending on your case this may or may not be sufficient. testing for sign in CKKS requires scheme switching back and forth to BinFHE, which is achievable, but I warn it takes compute time.

In all cases, chebychev is an interpolation function, care must be taken that the inputs are not out of bounds defined as input parameters, as the result will be useless otherwise.  
Dave

---

<div class="post-metadata">

**Author:** ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)\
**Post date:** [April 4, 2024, 3:30pm UTC](https://openfhe.discourse.group/t/how-can-i-calculate-terms-like-atan2/1170/3 "2024-04-04T15:30:17Z")

</div>

OpenFHE only implements a univariate version of Chebyshev polynomial approximation. If you have a multivariate function, you either transform it into an univariate function by some prior pre-processing and use EvalChebyshevFunction, or if that is not possible, you can try to implement your own multivariate polynomial interpolation (significantly more effort).
