Average Error: 16.0 → 9.2
Time: 30.2s
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 -77749059035.10175:\\ \;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\ \mathbf{elif}\;\pi \cdot \ell \le 2.2961577739006424 \cdot 10^{-14}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{1}{\frac{F}{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}}}{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 -77749059035.10175:\\
\;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\

\mathbf{elif}\;\pi \cdot \ell \le 2.2961577739006424 \cdot 10^{-14}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{1}{\frac{F}{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}}}{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 r421254 = atan2(1.0, 0.0);
        double r421255 = l;
        double r421256 = r421254 * r421255;
        double r421257 = 1.0;
        double r421258 = F;
        double r421259 = r421258 * r421258;
        double r421260 = r421257 / r421259;
        double r421261 = tan(r421256);
        double r421262 = r421260 * r421261;
        double r421263 = r421256 - r421262;
        return r421263;
}

double f(double F, double l) {
        double r421264 = atan2(1.0, 0.0);
        double r421265 = l;
        double r421266 = r421264 * r421265;
        double r421267 = -77749059035.10175;
        bool r421268 = r421266 <= r421267;
        double r421269 = tan(r421266);
        double r421270 = F;
        double r421271 = r421269 / r421270;
        double r421272 = /* ERROR: no posit support in C */;
        double r421273 = /* ERROR: no posit support in C */;
        double r421274 = r421273 / r421270;
        double r421275 = r421266 - r421274;
        double r421276 = 2.2961577739006424e-14;
        bool r421277 = r421266 <= r421276;
        double r421278 = 1.0;
        double r421279 = log1p(r421266);
        double r421280 = expm1(r421279);
        double r421281 = tan(r421280);
        double r421282 = r421270 / r421281;
        double r421283 = r421278 / r421282;
        double r421284 = r421283 / r421270;
        double r421285 = r421266 - r421284;
        double r421286 = r421277 ? r421285 : r421275;
        double r421287 = r421268 ? r421275 : r421286;
        return r421287;
}

Error

Bits error versus F

Bits error versus l

Derivation

  1. Split input into 2 regimes
  2. if (* PI l) < -77749059035.10175 or 2.2961577739006424e-14 < (* PI l)

    1. Initial program 22.6

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

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

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

    if -77749059035.10175 < (* PI l) < 2.2961577739006424e-14

    1. Initial program 8.5

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{1}{\frac{F}{\tan \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}}}}{F}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \le -77749059035.10175:\\ \;\;\;\;\pi \cdot \ell - \frac{\left(\left(\frac{\tan \left(\pi \cdot \ell\right)}{F}\right)\right)}{F}\\ \mathbf{elif}\;\pi \cdot \ell \le 2.2961577739006424 \cdot 10^{-14}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{1}{\frac{F}{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}}}{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 2019144 +o rules:numerics
(FPCore (F l)
  :name "VandenBroeck and Keller, Equation (6)"
  (- (* PI l) (* (/ 1 (* F F)) (tan (* PI l)))))