Average Error: 16.2 → 2.8
Time: 7.2s
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 := \pi \cdot \ell - \frac{\frac{t_0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(-0.5, {\left(\pi \cdot \ell\right)}^{2}, 1\right) \cdot F\right)\right)}}{F}\\ \mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\pi \cdot \ell \leq 10^{+137}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F \cdot \mathsf{fma}\left(0.041666666666666664, {\ell}^{4} \cdot {\pi}^{4}, \mathsf{fma}\left(-0.5, \ell \cdot \left(\ell \cdot {\pi}^{2}\right), 1\right)\right)}}{F}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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
         (-
          (* PI l)
          (/
           (/ t_0 (log1p (expm1 (* (fma -0.5 (pow (* PI l) 2.0) 1.0) F))))
           F))))
   (if (<= (* PI l) -2e+156)
     t_1
     (if (<= (* PI l) 1e+137)
       (-
        (* PI l)
        (/
         (/
          t_0
          (*
           F
           (fma
            0.041666666666666664
            (* (pow l 4.0) (pow PI 4.0))
            (fma -0.5 (* l (* l (pow PI 2.0))) 1.0))))
         F))
       t_1))))
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 = (((double) M_PI) * l) - ((t_0 / log1p(expm1((fma(-0.5, pow((((double) M_PI) * l), 2.0), 1.0) * F)))) / F);
	double tmp;
	if ((((double) M_PI) * l) <= -2e+156) {
		tmp = t_1;
	} else if ((((double) M_PI) * l) <= 1e+137) {
		tmp = (((double) M_PI) * l) - ((t_0 / (F * fma(0.041666666666666664, (pow(l, 4.0) * pow(((double) M_PI), 4.0)), fma(-0.5, (l * (l * pow(((double) M_PI), 2.0))), 1.0)))) / F);
	} else {
		tmp = t_1;
	}
	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) - Float64(Float64(t_0 / log1p(expm1(Float64(fma(-0.5, (Float64(pi * l) ^ 2.0), 1.0) * F)))) / F))
	tmp = 0.0
	if (Float64(pi * l) <= -2e+156)
		tmp = t_1;
	elseif (Float64(pi * l) <= 1e+137)
		tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / Float64(F * fma(0.041666666666666664, Float64((l ^ 4.0) * (pi ^ 4.0)), fma(-0.5, Float64(l * Float64(l * (pi ^ 2.0))), 1.0)))) / F));
	else
		tmp = t_1;
	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[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / N[Log[1 + N[(Exp[N[(N[(-0.5 * N[Power[N[(Pi * l), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * F), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -2e+156], t$95$1, If[LessEqual[N[(Pi * l), $MachinePrecision], 1e+137], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / N[(F * N[(0.041666666666666664 * N[(N[Power[l, 4.0], $MachinePrecision] * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(l * N[(l * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\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 := \pi \cdot \ell - \frac{\frac{t_0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(-0.5, {\left(\pi \cdot \ell\right)}^{2}, 1\right) \cdot F\right)\right)}}{F}\\
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+156}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -2e156 or 1e137 < (*.f64 (PI.f64) l)

    1. Initial program 19.6

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

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

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

      \[\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 0.7

      \[\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. Simplified0.7

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

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

    if -2e156 < (*.f64 (PI.f64) l) < 1e137

    1. Initial program 14.8

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

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

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

      \[\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.8

      \[\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 + 0.041666666666666664 \cdot \left({\ell}^{4} \cdot {\pi}^{4}\right)\right)\right)} \cdot F}}{F} \]
    6. Simplified3.8

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \pi\right)}{\color{blue}{\mathsf{fma}\left(0.041666666666666664, {\ell}^{4} \cdot {\pi}^{4}, \mathsf{fma}\left(-0.5, \ell \cdot \left(\ell \cdot {\pi}^{2}\right), 1\right)\right)} \cdot F}}{F} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.8

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

Reproduce

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