# Precomputing chebyshev coefficients

**URL:** <https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022>\
**Category:** Library Questions\
**Tags:** feature-requests\
**Created:** [May 10, 2025, 10:17am UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022 "2025-05-10T10:17:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![narger](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/narger/32/420_2.png) [@narger](https://openfhe.discourse.group/u/narger)\
**Post date:** [May 10, 2025, 10:17am UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022/1 "2025-05-10T10:17:58Z")

</div>

Hello,

I don’t know if already available as feature, but, is it possible to store/save the coefficients of a Chebyshev approximation, given a degree and interval? (assuming CKKS)

Currently, in order to gain some time during the evaluation of a circuit, I precompute the coefficients externally and then I load them in my code, but it would be nice to be able to automatically export them directly in OpenFHE!

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [May 11, 2025, 12:54am UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022/2 "2025-05-11T00:54:45Z")

</div>

Not sure I fully understand the question, but would [`EvalChebyshevSeries`](https://github.com/openfheorg/openfhe-development/blob/v1.2.4/src/pke/include/cryptocontext.h#L2615) help? It takes as input Chebyshev coefficients, so you do not need to compute them over and over as in `EvalChebyshevFunction`.

---

<div class="post-metadata">

**Author:** ![narger](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/narger/32/420_2.png) [@narger](https://openfhe.discourse.group/u/narger)\
**Post date:** [May 11, 2025, 12:11pm UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022/3 "2025-05-11T12:11:35Z")

</div>

Yup, I can use `EvalChebyshevSeries`.

My question was about pre-generating these coefficients…  
For instance, let’s say I need sqrt(x) over [2,3]. It would be useful to have a function that returns the coefficients only of such an approximation that can be stored in e.g., `coeffs.dat`.

In future iterations, instead of computing again the approximation, one could run `EvalChebyshevSeries` and use the values in `coeffs.dat`.

Note that this is exactly what I am doing now, but I pass via python to generate such coefficients

---

<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:** [May 12, 2025, 9:38am UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022/4 "2025-05-12T09:38:09Z")

</div>

You can use `EvalChebyshevCoefficients` in [openfhe-development/src/core/lib/math/chebyshev.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/core/lib/math/chebyshev.cpp).

By the way, you don’t always have to precompute or supply your own coefficients for a function. The coefficients for a function, as well as the encrypted evaluation can be computed on the fly via `EvalChebyshevFunction`, which internally calls the function above. Please see this [example](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/function-evaluation.cpp#L161).

---

<div class="post-metadata">

**Author:** ![narger](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/narger/32/420_2.png) [@narger](https://openfhe.discourse.group/u/narger)\
**Post date:** [May 12, 2025, 9:50am UTC](https://openfhe.discourse.group/t/precomputing-chebyshev-coefficients/2022/5 "2025-05-12T09:50:57Z")

</div>

Ok, thank you `EvalChebyshevCoefficients` was exactly what I was looking 😛 Thank you !!
