# Chebyshev circuit depth

**URL:** <https://openfhe.discourse.group/t/chebyshev-circuit-depth/431>\
**Category:** Library Questions\
**Created:** [March 27, 2023, 10:26am UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431 "2023-03-27T10:26:25Z")\
**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:** [March 27, 2023, 10:26am UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431/1 "2023-03-27T10:26:25Z")

</div>

Hello there, I am trying to evaluate the square root function within a certain interval [a, b] using the EvalChebyshevFunction. My question is, since I am using 8 as a degree, why the ciphertext goes up by 8 levels? Shouldn’t the evaluation be performed with a depth of log(8) = 4?

Thanks!

---

<div class="post-metadata">

**Author:** ![saroja](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@saroja](https://openfhe.discourse.group/u/saroja)\
**Post date:** [March 27, 2023, 2:29pm UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431/2 "2023-03-27T14:29:10Z")

</div>

Can you post your code? It should not be going up by 8 levels for degree 8.

---

<div class="post-metadata">

**Author:** ![iquah](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/iquah/32/8_2.png) [@iquah](https://openfhe.discourse.group/u/iquah)\
**Post date:** [March 27, 2023, 2:47pm UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431/3 "2023-03-27T14:47:09Z")

</div>

To add on to what Saroja said, you can check [OpenFHE - FUNCTION EVALUATION](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/FUNCTION_EVALUATION.md) to read about how this works, and the appropriate depth

---

<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:** [March 27, 2023, 9:48pm UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431/4 "2023-03-27T21:48:35Z")

</div>

Uhm, now I get 5 levels consumed.

```auto
cout << "Level before: " << c->GetLevel() << endl;
auto res = ctx->EvalChebyshevFunction([](double x) -> double { return std::sqrt(x); }, c, 0.337, 3, 8);
cout << "Level after: " << res->GetLevel() <<endl;

```

gives output

```auto
Level before: 25
Level after: 30

```

I am using the default parameters from advanced\_bootstrapping.cpp example, maybe the interval [0.377, 3] is not ok?

---

<div class="post-metadata">

**Author:** ![iquah](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/iquah/32/8_2.png) [@iquah](https://openfhe.discourse.group/u/iquah)\
**Post date:** [March 27, 2023, 10:15pm UTC](https://openfhe.discourse.group/t/chebyshev-circuit-depth/431/5 "2023-03-27T22:15:11Z")

</div>

As Saroja said, please share your code
