# Adjusting Parameters for "Approximation Error Too High" Error

**URL:** <https://openfhe.discourse.group/t/adjusting-parameters-for-approximation-error-too-high-error/1872>\
**Category:** Library Questions\
**Created:** [February 12, 2025, 7:39pm UTC](https://openfhe.discourse.group/t/adjusting-parameters-for-approximation-error-too-high-error/1872 "2025-02-12T19:39:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lawrenceklim](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@lawrenceklim](https://openfhe.discourse.group/u/lawrenceklim)\
**Post date:** [February 12, 2025, 7:39pm UTC](https://openfhe.discourse.group/t/adjusting-parameters-for-approximation-error-too-high-error/1872/1 "2025-02-12T19:39:01Z")

</div>

I’m doing some more complex FHE calculations with CKKS, and I sometimes get this error:

```auto
openfhe-development-1.2.3/src/pke/lib/encoding/ckkspackedencoding.cpp:l.541:Decode(): The decryption failed because the approximation error is too high. Check the parameters. 

```

My question is, what parameters can I change to make this error go away?

For example, if I have

```auto
    int ring_dim = 1 << 16;
    int num_slots = ring_dim / 2;

    // Set up encryption parameters for CKKS
    CCParams<CryptoContextCKKSRNS> parameters;
    parameters.SetSecurityLevel(HEStd_NotSet);
    parameters.SetMultiplicativeDepth(20);
    parameters.SetScalingModSize(40);
    parameters.SetRingDim(ring_dim);
    parameters.SetBatchSize(num_slots);

```

what else could I try increasing (and how)? I’ve also dabbled with modifying the scale parameter, but that hasn’t worked for me either.

---

<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:** [February 12, 2025, 8:51pm UTC](https://openfhe.discourse.group/t/adjusting-parameters-for-approximation-error-too-high-error/1872/2 "2025-02-12T20:51:19Z")

</div>

Increase the `firstModSize` to the max (set it to 60).  
Use `FLEXIBLEAUTOEXT` `ScalingTechnique`.  
Increase a bit the multiplicative depth (keep adding 1).

Make sure your computation does not grow too large or vanishes too small.

Note that, you can always decrypt and check before any homomorphic computation to see where the code fails.

---

<div class="post-metadata">

**Author:** ![lawrenceklim](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@lawrenceklim](https://openfhe.discourse.group/u/lawrenceklim)\
**Post date:** [February 12, 2025, 9:33pm UTC](https://openfhe.discourse.group/t/adjusting-parameters-for-approximation-error-too-high-error/1872/3 "2025-02-12T21:33:59Z")

</div>

Thank you for the response. Will do.
