Average Error: 16.1 → 8.8
Time: 25.4s
Precision: 64
\[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\]
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \le -599493329059.1592:\\ \;\;\;\;\pi \cdot \ell - \left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\right)\right)\\ \mathbf{elif}\;\pi \cdot \ell \le 8.02415478233444 \cdot 10^{+17}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\ \end{array}\]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \le -599493329059.1592:\\
\;\;\;\;\pi \cdot \ell - \left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\right)\right)\\

\mathbf{elif}\;\pi \cdot \ell \le 8.02415478233444 \cdot 10^{+17}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\

\end{array}
double f(double F, double l) {
        double r362397 = atan2(1.0, 0.0);
        double r362398 = l;
        double r362399 = r362397 * r362398;
        double r362400 = 1.0;
        double r362401 = F;
        double r362402 = r362401 * r362401;
        double r362403 = r362400 / r362402;
        double r362404 = tan(r362399);
        double r362405 = r362403 * r362404;
        double r362406 = r362399 - r362405;
        return r362406;
}

double f(double F, double l) {
        double r362407 = atan2(1.0, 0.0);
        double r362408 = l;
        double r362409 = r362407 * r362408;
        double r362410 = -599493329059.1592;
        bool r362411 = r362409 <= r362410;
        double r362412 = tan(r362409);
        double r362413 = F;
        double r362414 = r362413 * r362413;
        double r362415 = r362412 / r362414;
        double r362416 = /* ERROR: no posit support in C */;
        double r362417 = /* ERROR: no posit support in C */;
        double r362418 = r362409 - r362417;
        double r362419 = 8.02415478233444e+17;
        bool r362420 = r362409 <= r362419;
        double r362421 = log1p(r362409);
        double r362422 = expm1(r362421);
        double r362423 = tan(r362422);
        double r362424 = r362423 / r362413;
        double r362425 = r362424 / r362413;
        double r362426 = r362409 - r362425;
        double r362427 = r362412 / r362413;
        double r362428 = /* ERROR: no posit support in C */;
        double r362429 = /* ERROR: no posit support in C */;
        double r362430 = r362429 / r362413;
        double r362431 = r362409 - r362430;
        double r362432 = r362420 ? r362426 : r362431;
        double r362433 = r362411 ? r362418 : r362432;
        return r362433;
}

Error

Bits error versus F

Bits error versus l

Derivation

  1. Split input into 3 regimes
  2. if (* PI l) < -599493329059.1592

    1. Initial program 23.7

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\]
    2. Simplified23.7

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\]
    3. Using strategy rm
    4. Applied insert-posit1616.1

      \[\leadsto \pi \cdot \ell - \color{blue}{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\right)\right)}\]

    if -599493329059.1592 < (* PI l) < 8.02415478233444e+17

    1. Initial program 8.8

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\]
    2. Simplified8.4

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\]
    3. Using strategy rm
    4. Applied associate-/r*0.7

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}}\]
    5. Using strategy rm
    6. Applied expm1-log1p-u1.6

      \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}}{F}}{F}\]

    if 8.02415478233444e+17 < (* PI l)

    1. Initial program 22.9

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\]
    2. Simplified22.9

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\]
    3. Using strategy rm
    4. Applied associate-/r*22.9

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}}\]
    5. Using strategy rm
    6. Applied insert-posit1615.8

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}}{F}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \le -599493329059.1592:\\ \;\;\;\;\pi \cdot \ell - \left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\right)\right)\\ \mathbf{elif}\;\pi \cdot \ell \le 8.02415478233444 \cdot 10^{+17}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\ \end{array}\]

Reproduce

herbie shell --seed 2019154 +o rules:numerics
(FPCore (F l)
  :name "VandenBroeck and Keller, Equation (6)"
  (- (* PI l) (* (/ 1 (* F F)) (tan (* PI l)))))