# Eval chebyshev poly without range

**URL:** <https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176>\
**Category:** Library Questions\
**Created:** [September 16, 2025, 12:08pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176 "2025-09-16T12:08:03Z")\
**Posts on this page:** 8\
**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:** [September 16, 2025, 12:08pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/1 "2025-09-16T12:08:03Z")

</div>

Hello,

I have some polynomials under Chebyshev basis that I found via some techniques in a python code. Now I would like to use these polynomials under CKKS, and I was thinking of using the EvalChebyshevSeries ([openfhe-development/src/pke/include/cryptocontext.h at aa8a86e1143f1e47d4354bdd757080e903ba5875 · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/aa8a86e1143f1e47d4354bdd757080e903ba5875/src/pke/include/cryptocontext.h#L2823)) function.

I was wondering if there is a way to eval a polynomial under chebyshev basis without performing a linear transformation 1+2(x-a)/(b-a), or in general without taking into account any range.

For instance, there is the ‘classical’ EvalPoly function that takes as input ciphertext+coefficients. For chebyshev basis, there is no such thing, as EvalChebyshevSeries takes as input ciphertext+coefficients+[a,b] range. Is there a specific reason for that?

Thank you!

---

<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:** [September 16, 2025, 2:05pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/2 "2025-09-16T14:05:57Z")

</div>

The [Chebyshev interpolation](https://en.wikipedia.org/wiki/Chebyshev_polynomials) is designed to work when the input is in the range [-1,1]. When the input is in a range [a,b], it first need to be scaled to [-1,1]. If you want to supply your own coefficients for the Chebyshev basis (this is defined over [-1,1]) just give as arguments a=-1, b=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:** [September 16, 2025, 2:19pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/3 "2025-09-16T14:19:36Z")

</div>

Ok thank you, my doubt was w.r.t. the function itself. I know that such range is used to compute the coefficients (e.g., in EvalChebyshevFunction) but once these coefficients are computed, what is the role of a,b ?

In other words, once I have the set of coeffs, why should I use different values from a=-1 and b=1? What is the use case?

---

<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:** [September 16, 2025, 2:32pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/4 "2025-09-16T14:32:35Z")

</div>

Computing the coefficients only describes the function, presumably you also need to evaluate the interpolation over an input of interest. Therefore, you need to ensure that the input is in the right range when you compute the interpolation, which means scaling it from [a,b] to [-1,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:** [September 19, 2025, 7:47am UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/5 "2025-09-19T07:47:50Z")

</div>

Got it, thanks 🙂

I am trying to port a Julia code (in plaintext) to a CKKS circuit. Unluckily I got stuck at the evaluation of some Chebyshev polynomials. I defined a minimal example to replicate the issue I am encountering as follows (hope is not a dumb error by my side:p)

Julia code:

```Julia
using Polynomials 

 # This defines 1*T_0(x) + 2*T_1(x) + 3*T_2(x)
poly = ChebyshevT([1, 2, 3]) 

# Evaluates the polynomial in x=0.1
poly(0.1)

→ ans: -1.74

poly(0.2)
→ ans: -1.3599999999999999

```

On the other hand, if I try to evaluate the same polynomial under CKKS, I obtain the following

C++ code:

```c++
CCParams<CryptoContextCKKSRNS> parameters;

parameters.SetSecretKeyDist(SPARSE_TERNARY);
parameters.SetSecurityLevel(lbcrypto::HEStd_NotSet);
parameters.SetRingDim(1 << 12);
parameters.SetBatchSize(2);
parameters.SetScalingModSize(59);
parameters.SetFirstModSize(60);
parameters.SetScalingTechnique(FLEXIBLEAUTO);
parameters.SetMultiplicativeDepth(12);

context = GenCryptoContext(parameters);
context->Enable(PKE);
context->Enable(KEYSWITCH);
context->Enable(LEVELEDSHE);
context->Enable(ADVANCEDSHE);
    
context->EvalMultKeyGen(context->KeyGen().secretKey);

Plaintext p = context->MakeCKKSPackedPlaintext({0.1, 0.2}, 1, 0, nullptr, 2);
Ciphertext<DCRTPoly> c;

c = context->Encrypt(p, key_pair.publicKey);
c = context->EvalChebyshevSeries(c, {1, 2, 3}, -1, 1);

Plaintext result;
context->Decrypt(key_pair.secretKey, c, &result);
vector<double> v = result->GetRealPackedValue();

cout << v[0] << ", " << v[1] << endl;

→ ans: -1.66346, -0.726544 

```

Maybe something regarding the range [-1, 1]? I am not sure…

Thanks!

---

<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:** [September 19, 2025, 1:36pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/6 "2025-09-19T13:36:52Z")

</div>

You should first do some sanity checks to ensure that the basis polynomials are defined in the same way in your Julia code and in the OpenFHE implementation. It’s a good idea to check the code and comments, but a simple way to check would be to also evaluate only T\_0(x), only T\_1(x) etc.

It is common for the zero-th basis coefficient to be written as a\_0/2. So I tried EvalChebyshevSeries(c, \{2, 2, 3\}, -1, 1) instead of EvalChebyshevSeries(c, \{1, 2, 3\}, -1, 1); and I got -1.74, -1.36.

---

<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:** [September 19, 2025, 4:23pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/7 "2025-09-19T16:23:00Z")

</div>

Thank you!! Indeed by using a\_0 \cdot 2 I was able to obtain the result. Did not know about the common practice of writing a\_0 as a\_0 / 2… I wonder if it could be helpful to state that in the documentation of that (public) function (i.e., in [here](https://github.com/openfheorg/openfhe-development/blob/aa8a86e1143f1e47d4354bdd757080e903ba5875/src/pke/include/schemebase/base-advancedshe.h#L296))

---

<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:** [September 19, 2025, 5:08pm UTC](https://openfhe.discourse.group/t/eval-chebyshev-poly-without-range/2176/8 "2025-09-19T17:08:00Z")

</div>

The [link](https://www.gnu.org/software/gsl/doc/html/cheb.html) in the readme for function evaluation in OpenFHE FUNCTION\_EVALUATION.md shows the convention used. Moreover, this is described for the method of computing the Chebyshev coefficients for a function in [chebyshev.h](https://github.com/openfheorg/openfhe-development/blob/aa8a86e1143f1e47d4354bdd757080e903ba5875/src/core/include/math/chebyshev.h#L53).
