Average Error: 16.6 → 3.3
Time: 7.1s
Precision: binary64
\[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
\[\begin{array}{l} t_0 := \sin \left(\pi \cdot \ell\right)\\ t_1 := {\left(\pi \cdot \ell\right)}^{2} \cdot -0.5\\ \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+77}:\\ \;\;\;\;\pi \cdot \ell - \frac{\log \left(1 + \mathsf{expm1}\left(\frac{\frac{t_0}{F}}{1 + t_1}\right)\right)}{F}\\ \mathbf{elif}\;\pi \cdot \ell \leq 10^{+68}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F \cdot \mathsf{fma}\left(-0.5, \left(\ell \cdot \ell\right) \cdot {\pi}^{2}, \mathsf{fma}\left(0.041666666666666664, {\left(\pi \cdot \ell\right)}^{4}, \mathsf{fma}\left(-0.001388888888888889, {\left(\pi \cdot \ell\right)}^{6}, 1\right)\right)\right)}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{\mathsf{log1p}\left(\mathsf{expm1}\left(F + F \cdot t_1\right)\right)}}{F}\\ \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (sin (* PI l))) (t_1 (* (pow (* PI l) 2.0) -0.5)))
   (if (<= (* PI l) -5e+77)
     (- (* PI l) (/ (log (+ 1.0 (expm1 (/ (/ t_0 F) (+ 1.0 t_1))))) F))
     (if (<= (* PI l) 1e+68)
       (-
        (* PI l)
        (/
         (/
          t_0
          (*
           F
           (fma
            -0.5
            (* (* l l) (pow PI 2.0))
            (fma
             0.041666666666666664
             (pow (* PI l) 4.0)
             (fma -0.001388888888888889 (pow (* PI l) 6.0) 1.0)))))
         F))
       (- (* PI l) (/ (/ t_0 (log1p (expm1 (+ F (* F t_1))))) F))))))
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 = sin((((double) M_PI) * l));
	double t_1 = pow((((double) M_PI) * l), 2.0) * -0.5;
	double tmp;
	if ((((double) M_PI) * l) <= -5e+77) {
		tmp = (((double) M_PI) * l) - (log((1.0 + expm1(((t_0 / F) / (1.0 + t_1))))) / F);
	} else if ((((double) M_PI) * l) <= 1e+68) {
		tmp = (((double) M_PI) * l) - ((t_0 / (F * fma(-0.5, ((l * l) * pow(((double) M_PI), 2.0)), fma(0.041666666666666664, pow((((double) M_PI) * l), 4.0), fma(-0.001388888888888889, pow((((double) M_PI) * l), 6.0), 1.0))))) / F);
	} else {
		tmp = (((double) M_PI) * l) - ((t_0 / log1p(expm1((F + (F * t_1))))) / F);
	}
	return tmp;
}
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l))))
end
function code(F, l)
	t_0 = sin(Float64(pi * l))
	t_1 = Float64((Float64(pi * l) ^ 2.0) * -0.5)
	tmp = 0.0
	if (Float64(pi * l) <= -5e+77)
		tmp = Float64(Float64(pi * l) - Float64(log(Float64(1.0 + expm1(Float64(Float64(t_0 / F) / Float64(1.0 + t_1))))) / F));
	elseif (Float64(pi * l) <= 1e+68)
		tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / Float64(F * fma(-0.5, Float64(Float64(l * l) * (pi ^ 2.0)), fma(0.041666666666666664, (Float64(pi * l) ^ 4.0), fma(-0.001388888888888889, (Float64(pi * l) ^ 6.0), 1.0))))) / F));
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / log1p(expm1(Float64(F + Float64(F * t_1))))) / F));
	end
	return tmp
end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[F_, l_] := Block[{t$95$0 = N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(Pi * l), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -5e+77], N[(N[(Pi * l), $MachinePrecision] - N[(N[Log[N[(1.0 + N[(Exp[N[(N[(t$95$0 / F), $MachinePrecision] / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 1e+68], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / N[(F * N[(-0.5 * N[(N[(l * l), $MachinePrecision] * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[N[(Pi * l), $MachinePrecision], 4.0], $MachinePrecision] + N[(-0.001388888888888889 * N[Power[N[(Pi * l), $MachinePrecision], 6.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / N[Log[1 + N[(Exp[N[(F + N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]]]]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\begin{array}{l}
t_0 := \sin \left(\pi \cdot \ell\right)\\
t_1 := {\left(\pi \cdot \ell\right)}^{2} \cdot -0.5\\
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+77}:\\
\;\;\;\;\pi \cdot \ell - \frac{\log \left(1 + \mathsf{expm1}\left(\frac{\frac{t_0}{F}}{1 + t_1}\right)\right)}{F}\\

\mathbf{elif}\;\pi \cdot \ell \leq 10^{+68}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F \cdot \mathsf{fma}\left(-0.5, \left(\ell \cdot \ell\right) \cdot {\pi}^{2}, \mathsf{fma}\left(0.041666666666666664, {\left(\pi \cdot \ell\right)}^{4}, \mathsf{fma}\left(-0.001388888888888889, {\left(\pi \cdot \ell\right)}^{6}, 1\right)\right)\right)}}{F}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{\mathsf{log1p}\left(\mathsf{expm1}\left(F + F \cdot t_1\right)\right)}}{F}\\


\end{array}

Error

Derivation

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

    1. Initial program 22.7

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

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    3. Taylor expanded in l around inf 22.7

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot {F}^{2}}} \]
    4. Simplified22.7

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot F}}{F}} \]
    5. Taylor expanded in l around 0 5.1

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\left(-0.5 \cdot \left({\ell}^{2} \cdot {\pi}^{2}\right) + 1\right)} \cdot F}}{F} \]
    6. Simplified5.1

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\mathsf{fma}\left({\pi}^{2}, -0.5 \cdot \left(\ell \cdot \ell\right), 1\right)} \cdot F}}{F} \]
    7. Applied egg-rr3.6

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\log \left(1 + \mathsf{expm1}\left(\frac{\frac{\sin \left(\pi \cdot \ell\right)}{F}}{1 + {\left(\pi \cdot \ell\right)}^{2} \cdot -0.5}\right)\right)}}{F} \]

    if -5.00000000000000004e77 < (*.f64 (PI.f64) l) < 9.99999999999999953e67

    1. Initial program 13.0

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

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    3. Taylor expanded in l around inf 12.6

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot {F}^{2}}} \]
    4. Simplified5.8

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot F}}{F}} \]
    5. Taylor expanded in l around 0 3.3

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\left(-0.5 \cdot \left({\ell}^{2} \cdot {\pi}^{2}\right) + \left(1 + \left(-0.001388888888888889 \cdot \left({\ell}^{6} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot \left({\ell}^{4} \cdot {\pi}^{4}\right)\right)\right)\right)} \cdot F}}{F} \]
    6. Simplified3.3

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\mathsf{fma}\left(-0.5, \left(\ell \cdot \ell\right) \cdot {\pi}^{2}, \mathsf{fma}\left(0.041666666666666664, {\left(\ell \cdot \pi\right)}^{4}, \mathsf{fma}\left(-0.001388888888888889, {\left(\ell \cdot \pi\right)}^{6}, 1\right)\right)\right)} \cdot F}}{F} \]

    if 9.99999999999999953e67 < (*.f64 (PI.f64) l)

    1. Initial program 20.7

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

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    3. Taylor expanded in l around inf 20.7

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot {F}^{2}}} \]
    4. Simplified20.7

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right) \cdot F}}{F}} \]
    5. Taylor expanded in l around 0 5.2

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\left(-0.5 \cdot \left({\ell}^{2} \cdot {\pi}^{2}\right) + 1\right)} \cdot F}}{F} \]
    6. Simplified5.2

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\mathsf{fma}\left({\pi}^{2}, -0.5 \cdot \left(\ell \cdot \ell\right), 1\right)} \cdot F}}{F} \]
    7. Applied egg-rr3.2

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left({\left(\pi \cdot \ell\right)}^{2} \cdot -0.5\right) \cdot F + F\right)\right)}}}{F} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+77}:\\ \;\;\;\;\pi \cdot \ell - \frac{\log \left(1 + \mathsf{expm1}\left(\frac{\frac{\sin \left(\pi \cdot \ell\right)}{F}}{1 + {\left(\pi \cdot \ell\right)}^{2} \cdot -0.5}\right)\right)}{F}\\ \mathbf{elif}\;\pi \cdot \ell \leq 10^{+68}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right)}{F \cdot \mathsf{fma}\left(-0.5, \left(\ell \cdot \ell\right) \cdot {\pi}^{2}, \mathsf{fma}\left(0.041666666666666664, {\left(\pi \cdot \ell\right)}^{4}, \mathsf{fma}\left(-0.001388888888888889, {\left(\pi \cdot \ell\right)}^{6}, 1\right)\right)\right)}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right)}{\mathsf{log1p}\left(\mathsf{expm1}\left(F + F \cdot \left({\left(\pi \cdot \ell\right)}^{2} \cdot -0.5\right)\right)\right)}}{F}\\ \end{array} \]

Reproduce

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