Precomputing chebyshev coefficients

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!

Not sure I fully understand the question, but would EvalChebyshevSeries help? It takes as input Chebyshev coefficients, so you do not need to compute them over and over as in EvalChebyshevFunction.

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

You can use EvalChebyshevCoefficients in openfhe-development/src/core/lib/math/chebyshev.cpp at main · openfheorg/openfhe-development · GitHub.

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.

Ok, thank you EvalChebyshevCoefficients was exactly what I was looking :stuck_out_tongue: Thank you !!