Average Error: 17.1 → 1.6
Time: 16.2s
Precision: binary64
\[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
\[\begin{array}{l} t_0 := {\pi}^{5} \cdot {\ell}^{5}\\ t_1 := \frac{F}{\pi \cdot \ell}\\ t_2 := \left(F \cdot \ell\right) \cdot 0.3333333333333333\\ \mathbf{if}\;F \cdot F \leq 1.1017335510091991 \cdot 10^{-97}:\\ \;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(t_1 - \mathsf{fma}\left(\pi, t_2, \mathsf{log1p}\left(\mathsf{expm1}\left(F \cdot \mathsf{fma}\left(0.0021164021164021165, t_0, 0.022222222222222223 \cdot {\left(\pi \cdot \ell\right)}^{3}\right)\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(t_1 - \mathsf{fma}\left(\pi, t_2, F \cdot \left(0.0021164021164021165 \cdot t_0\right)\right)\right)}\\ \end{array} \]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\begin{array}{l}
t_0 := {\pi}^{5} \cdot {\ell}^{5}\\
t_1 := \frac{F}{\pi \cdot \ell}\\
t_2 := \left(F \cdot \ell\right) \cdot 0.3333333333333333\\
\mathbf{if}\;F \cdot F \leq 1.1017335510091991 \cdot 10^{-97}:\\
\;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(t_1 - \mathsf{fma}\left(\pi, t_2, \mathsf{log1p}\left(\mathsf{expm1}\left(F \cdot \mathsf{fma}\left(0.0021164021164021165, t_0, 0.022222222222222223 \cdot {\left(\pi \cdot \ell\right)}^{3}\right)\right)\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(t_1 - \mathsf{fma}\left(\pi, t_2, F \cdot \left(0.0021164021164021165 \cdot t_0\right)\right)\right)}\\


\end{array}
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (* (pow PI 5.0) (pow l 5.0)))
        (t_1 (/ F (* PI l)))
        (t_2 (* (* F l) 0.3333333333333333)))
   (if (<= (* F F) 1.1017335510091991e-97)
     (-
      (* PI l)
      (/
       1.0
       (*
        F
        (-
         t_1
         (fma
          PI
          t_2
          (log1p
           (expm1
            (*
             F
             (fma
              0.0021164021164021165
              t_0
              (* 0.022222222222222223 (pow (* PI l) 3.0)))))))))))
     (-
      (* PI l)
      (/
       1.0
       (* F (- t_1 (fma PI t_2 (* F (* 0.0021164021164021165 t_0))))))))))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan(((double) M_PI) * l));
}
double code(double F, double l) {
	double t_0 = pow(((double) M_PI), 5.0) * pow(l, 5.0);
	double t_1 = F / (((double) M_PI) * l);
	double t_2 = (F * l) * 0.3333333333333333;
	double tmp;
	if ((F * F) <= 1.1017335510091991e-97) {
		tmp = (((double) M_PI) * l) - (1.0 / (F * (t_1 - fma(((double) M_PI), t_2, log1p(expm1(F * fma(0.0021164021164021165, t_0, (0.022222222222222223 * pow((((double) M_PI) * l), 3.0)))))))));
	} else {
		tmp = (((double) M_PI) * l) - (1.0 / (F * (t_1 - fma(((double) M_PI), t_2, (F * (0.0021164021164021165 * t_0))))));
	}
	return tmp;
}

Error

Bits error versus F

Bits error versus l

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 F F) < 1.1017335510091991e-97

    1. Initial program 43.6

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

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
    4. Applied clear-num_binary6432.4

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}}} \]
    5. Simplified32.4

      \[\leadsto \pi \cdot \ell - \frac{1}{\color{blue}{F \cdot \frac{F}{\tan \left(\pi \cdot \ell\right)}}} \]
    6. Taylor expanded in l around 0 4.8

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \color{blue}{\left(\frac{F}{\pi \cdot \ell} - \left(0.3333333333333333 \cdot \left(\pi \cdot \left(F \cdot \ell\right)\right) + \left(0.0021164021164021165 \cdot \left({\pi}^{5} \cdot \left({\ell}^{5} \cdot F\right)\right) + 0.022222222222222223 \cdot \left({\pi}^{3} \cdot \left({\ell}^{3} \cdot F\right)\right)\right)\right)\right)}} \]
    7. Simplified4.7

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \color{blue}{\left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, F \cdot \left(0.022222222222222223 \cdot \left({\pi}^{3} \cdot {\ell}^{3}\right) + 0.0021164021164021165 \cdot \left({\pi}^{5} \cdot {\ell}^{5}\right)\right)\right)\right)}} \]
    8. Applied log1p-expm1-u_binary643.4

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(F \cdot \left(0.022222222222222223 \cdot \left({\pi}^{3} \cdot {\ell}^{3}\right) + 0.0021164021164021165 \cdot \left({\pi}^{5} \cdot {\ell}^{5}\right)\right)\right)\right)}\right)\right)} \]
    9. Simplified3.4

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(F \cdot \mathsf{fma}\left(0.0021164021164021165, {\pi}^{5} \cdot {\ell}^{5}, 0.022222222222222223 \cdot {\left(\pi \cdot \ell\right)}^{3}\right)\right)}\right)\right)\right)} \]

    if 1.1017335510091991e-97 < (*.f64 F F)

    1. Initial program 0.8

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

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    3. Applied associate-/r*_binary640.8

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
    4. Applied clear-num_binary640.8

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}}} \]
    5. Simplified0.8

      \[\leadsto \pi \cdot \ell - \frac{1}{\color{blue}{F \cdot \frac{F}{\tan \left(\pi \cdot \ell\right)}}} \]
    6. Taylor expanded in l around 0 0.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \color{blue}{\left(\frac{F}{\pi \cdot \ell} - \left(0.3333333333333333 \cdot \left(\pi \cdot \left(F \cdot \ell\right)\right) + \left(0.0021164021164021165 \cdot \left({\pi}^{5} \cdot \left({\ell}^{5} \cdot F\right)\right) + 0.022222222222222223 \cdot \left({\pi}^{3} \cdot \left({\ell}^{3} \cdot F\right)\right)\right)\right)\right)}} \]
    7. Simplified0.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \color{blue}{\left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, F \cdot \left(0.022222222222222223 \cdot \left({\pi}^{3} \cdot {\ell}^{3}\right) + 0.0021164021164021165 \cdot \left({\pi}^{5} \cdot {\ell}^{5}\right)\right)\right)\right)}} \]
    8. Taylor expanded in l around inf 0.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, \color{blue}{0.0021164021164021165 \cdot \left({\pi}^{5} \cdot \left(F \cdot {\ell}^{5}\right)\right)}\right)\right)} \]
    9. Simplified0.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(\ell \cdot F\right) \cdot 0.3333333333333333, \color{blue}{F \cdot \left(0.0021164021164021165 \cdot \left({\pi}^{5} \cdot {\ell}^{5}\right)\right)}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \cdot F \leq 1.1017335510091991 \cdot 10^{-97}:\\ \;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(F \cdot \ell\right) \cdot 0.3333333333333333, \mathsf{log1p}\left(\mathsf{expm1}\left(F \cdot \mathsf{fma}\left(0.0021164021164021165, {\pi}^{5} \cdot {\ell}^{5}, 0.022222222222222223 \cdot {\left(\pi \cdot \ell\right)}^{3}\right)\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot \left(\frac{F}{\pi \cdot \ell} - \mathsf{fma}\left(\pi, \left(F \cdot \ell\right) \cdot 0.3333333333333333, F \cdot \left(0.0021164021164021165 \cdot \left({\pi}^{5} \cdot {\ell}^{5}\right)\right)\right)\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2021280 
(FPCore (F l)
  :name "VandenBroeck and Keller, Equation (6)"
  :precision binary64
  (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))