Average Error: 14.9 → 1.3
Time: 21.9s
Precision: 64
\[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
\[{e}^{\left(\left|m - n\right| - \mathsf{fma}\left(\frac{n + m}{2} - M, \frac{n + m}{2} - M, \ell\right)\right)}\]
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
{e}^{\left(\left|m - n\right| - \mathsf{fma}\left(\frac{n + m}{2} - M, \frac{n + m}{2} - M, \ell\right)\right)}
double f(double K, double m, double n, double M, double l) {
        double r2999445 = K;
        double r2999446 = m;
        double r2999447 = n;
        double r2999448 = r2999446 + r2999447;
        double r2999449 = r2999445 * r2999448;
        double r2999450 = 2.0;
        double r2999451 = r2999449 / r2999450;
        double r2999452 = M;
        double r2999453 = r2999451 - r2999452;
        double r2999454 = cos(r2999453);
        double r2999455 = r2999448 / r2999450;
        double r2999456 = r2999455 - r2999452;
        double r2999457 = pow(r2999456, r2999450);
        double r2999458 = -r2999457;
        double r2999459 = l;
        double r2999460 = r2999446 - r2999447;
        double r2999461 = fabs(r2999460);
        double r2999462 = r2999459 - r2999461;
        double r2999463 = r2999458 - r2999462;
        double r2999464 = exp(r2999463);
        double r2999465 = r2999454 * r2999464;
        return r2999465;
}

double f(double __attribute__((unused)) K, double m, double n, double M, double l) {
        double r2999466 = exp(1.0);
        double r2999467 = m;
        double r2999468 = n;
        double r2999469 = r2999467 - r2999468;
        double r2999470 = fabs(r2999469);
        double r2999471 = r2999468 + r2999467;
        double r2999472 = 2.0;
        double r2999473 = r2999471 / r2999472;
        double r2999474 = M;
        double r2999475 = r2999473 - r2999474;
        double r2999476 = l;
        double r2999477 = fma(r2999475, r2999475, r2999476);
        double r2999478 = r2999470 - r2999477;
        double r2999479 = pow(r2999466, r2999478);
        return r2999479;
}

Error

Bits error versus K

Bits error versus m

Bits error versus n

Bits error versus M

Bits error versus l

Derivation

  1. Initial program 14.9

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
  2. Simplified14.9

    \[\leadsto \color{blue}{\cos \left(K \cdot \frac{m + n}{2} - M\right) \cdot e^{\left|m - n\right| - \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)}}\]
  3. Taylor expanded around 0 1.3

    \[\leadsto \color{blue}{1} \cdot e^{\left|m - n\right| - \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity1.3

    \[\leadsto 1 \cdot e^{\left|m - n\right| - \color{blue}{1 \cdot \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)}}\]
  6. Applied *-un-lft-identity1.3

    \[\leadsto 1 \cdot e^{\color{blue}{1 \cdot \left|m - n\right|} - 1 \cdot \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)}\]
  7. Applied distribute-lft-out--1.3

    \[\leadsto 1 \cdot e^{\color{blue}{1 \cdot \left(\left|m - n\right| - \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)\right)}}\]
  8. Applied exp-prod1.3

    \[\leadsto 1 \cdot \color{blue}{{\left(e^{1}\right)}^{\left(\left|m - n\right| - \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)\right)}}\]
  9. Simplified1.3

    \[\leadsto 1 \cdot {\color{blue}{e}}^{\left(\left|m - n\right| - \mathsf{fma}\left(\frac{m + n}{2} - M, \frac{m + n}{2} - M, \ell\right)\right)}\]
  10. Final simplification1.3

    \[\leadsto {e}^{\left(\left|m - n\right| - \mathsf{fma}\left(\frac{n + m}{2} - M, \frac{n + m}{2} - M, \ell\right)\right)}\]

Reproduce

herbie shell --seed 2019143 +o rules:numerics
(FPCore (K m n M l)
  :name "Maksimov and Kolovsky, Equation (32)"
  (* (cos (- (/ (* K (+ m n)) 2) M)) (exp (- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n)))))))