VandenBroeck and Keller, Equation (6)

Percentage Accurate: 75.7% → 95.2%
Time: 25.8s
Alternatives: 5
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
	return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l):
	return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l))))
end
function tmp = code(F, l)
	tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l)));
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]
\begin{array}{l}

\\
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 75.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
	return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l):
	return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l))))
end
function tmp = code(F, l)
	tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l)));
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]
\begin{array}{l}

\\
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\end{array}

Alternative 1: 95.2% accurate, 0.8× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l_m \leq 10^{+16}:\\ \;\;\;\;\pi \cdot l_m - \frac{\frac{\tan \left(\pi \cdot l_m\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 1e+16)
    (- (* PI l_m) (/ (/ (tan (* PI l_m)) F) F))
    (expm1 (log1p (* PI l_m))))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 1e+16) {
		tmp = (((double) M_PI) * l_m) - ((tan((((double) M_PI) * l_m)) / F) / F);
	} else {
		tmp = expm1(log1p((((double) M_PI) * l_m)));
	}
	return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if ((Math.PI * l_m) <= 1e+16) {
		tmp = (Math.PI * l_m) - ((Math.tan((Math.PI * l_m)) / F) / F);
	} else {
		tmp = Math.expm1(Math.log1p((Math.PI * l_m)));
	}
	return l_s * tmp;
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if (math.pi * l_m) <= 1e+16:
		tmp = (math.pi * l_m) - ((math.tan((math.pi * l_m)) / F) / F)
	else:
		tmp = math.expm1(math.log1p((math.pi * l_m)))
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 1e+16)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(tan(Float64(pi * l_m)) / F) / F));
	else
		tmp = expm1(log1p(Float64(pi * l_m)));
	end
	return Float64(l_s * tmp)
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 1e+16], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l_m \leq 10^{+16}:\\
\;\;\;\;\pi \cdot l_m - \frac{\frac{\tan \left(\pi \cdot l_m\right)}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < 1e16

    1. Initial program 79.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. associate-*l/80.8%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      2. *-un-lft-identity80.8%

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
    3. Applied egg-rr87.7%

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

    if 1e16 < (*.f64 (PI.f64) l)

    1. Initial program 59.3%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. fma-neg59.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, -\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)} \]
      2. distribute-lft-neg-in59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\left(-\frac{1}{F \cdot F}\right) \cdot \tan \left(\pi \cdot \ell\right)}\right) \]
      3. sqr-neg59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \left(-\frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}}\right) \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      4. distribute-neg-frac59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{-1}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      5. metadata-eval59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-1}}{\left(-F\right) \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      6. distribute-lft-neg-out59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      7. neg-mul-159.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-1 \cdot \left(F \cdot \left(-F\right)\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      8. associate-/r*59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{-1}{-1}}{F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      9. metadata-eval59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{1}}{F \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      10. associate-*l/59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right) \]
      11. *-lft-identity59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot \left(-F\right)}\right) \]
      12. associate-/l/59.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}}\right) \]
    3. Simplified59.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u54.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)\right)\right)} \]
      2. associate-/l/54.3%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right)\right)\right) \]
      3. associate-/r*54.3%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{-F}}\right)\right)\right) \]
      4. add-sqr-sqrt23.6%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{-F} \cdot \sqrt{-F}}}\right)\right)\right) \]
      5. sqrt-unprod54.2%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{\left(-F\right) \cdot \left(-F\right)}}}\right)\right)\right) \]
      6. sqr-neg54.2%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\sqrt{\color{blue}{F \cdot F}}}\right)\right)\right) \]
      7. sqrt-prod30.6%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{F} \cdot \sqrt{F}}}\right)\right)\right) \]
      8. add-sqr-sqrt54.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{F}}\right)\right)\right) \]
      9. associate-/r*54.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\right)\right)\right) \]
      10. div-inv54.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}}\right)\right)\right) \]
      11. pow254.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{{F}^{2}}}\right)\right)\right) \]
      12. pow-flip54.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{{F}^{\left(-2\right)}}\right)\right)\right) \]
      13. metadata-eval54.1%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{\color{blue}{-2}}\right)\right)\right) \]
    5. Applied egg-rr54.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{-2}\right)\right)\right)} \]
    6. Taylor expanded in F around inf 91.3%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + \ell \cdot \pi\right)}\right) \]
    7. Step-by-step derivation
      1. log1p-def91.3%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
    8. Simplified91.3%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.5%

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

Alternative 2: 94.1% accurate, 0.8× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l_m \leq 10000:\\ \;\;\;\;\mathsf{fma}\left(\pi, l_m, \frac{\frac{-l_m}{\frac{F}{\pi}}}{F}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 10000.0)
    (fma PI l_m (/ (/ (- l_m) (/ F PI)) F))
    (expm1 (log1p (* PI l_m))))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 10000.0) {
		tmp = fma(((double) M_PI), l_m, ((-l_m / (F / ((double) M_PI))) / F));
	} else {
		tmp = expm1(log1p((((double) M_PI) * l_m)));
	}
	return l_s * tmp;
}
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 10000.0)
		tmp = fma(pi, l_m, Float64(Float64(Float64(-l_m) / Float64(F / pi)) / F));
	else
		tmp = expm1(log1p(Float64(pi * l_m)));
	end
	return Float64(l_s * tmp)
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 10000.0], N[(Pi * l$95$m + N[(N[((-l$95$m) / N[(F / Pi), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l_m \leq 10000:\\
\;\;\;\;\mathsf{fma}\left(\pi, l_m, \frac{\frac{-l_m}{\frac{F}{\pi}}}{F}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < 1e4

    1. Initial program 79.3%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. fma-neg79.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, -\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)} \]
      2. distribute-lft-neg-in79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\left(-\frac{1}{F \cdot F}\right) \cdot \tan \left(\pi \cdot \ell\right)}\right) \]
      3. sqr-neg79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \left(-\frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}}\right) \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      4. distribute-neg-frac79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{-1}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      5. metadata-eval79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-1}}{\left(-F\right) \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      6. distribute-lft-neg-out79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      7. neg-mul-179.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-1 \cdot \left(F \cdot \left(-F\right)\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      8. associate-/r*79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{-1}{-1}}{F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      9. metadata-eval79.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{1}}{F \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      10. associate-*l/80.7%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right) \]
      11. *-lft-identity80.7%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot \left(-F\right)}\right) \]
      12. associate-/l/87.7%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}}\right) \]
    3. Simplified87.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)} \]
    4. Taylor expanded in l around 0 80.2%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-1 \cdot \frac{\ell \cdot \pi}{F}}}{F}\right) \]
    5. Step-by-step derivation
      1. mul-1-neg80.2%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-\frac{\ell \cdot \pi}{F}}}{F}\right) \]
      2. associate-/l*80.2%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-\color{blue}{\frac{\ell}{\frac{F}{\pi}}}}{F}\right) \]
    6. Simplified80.2%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-\frac{\ell}{\frac{F}{\pi}}}}{F}\right) \]

    if 1e4 < (*.f64 (PI.f64) l)

    1. Initial program 60.3%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. fma-neg60.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, -\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)} \]
      2. distribute-lft-neg-in60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\left(-\frac{1}{F \cdot F}\right) \cdot \tan \left(\pi \cdot \ell\right)}\right) \]
      3. sqr-neg60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \left(-\frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}}\right) \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      4. distribute-neg-frac60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{-1}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      5. metadata-eval60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-1}}{\left(-F\right) \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      6. distribute-lft-neg-out60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      7. neg-mul-160.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-1 \cdot \left(F \cdot \left(-F\right)\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      8. associate-/r*60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{-1}{-1}}{F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      9. metadata-eval60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{1}}{F \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      10. associate-*l/60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right) \]
      11. *-lft-identity60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot \left(-F\right)}\right) \]
      12. associate-/l/60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}}\right) \]
    3. Simplified60.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u55.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)\right)\right)} \]
      2. associate-/l/55.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right)\right)\right) \]
      3. associate-/r*55.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{-F}}\right)\right)\right) \]
      4. add-sqr-sqrt25.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{-F} \cdot \sqrt{-F}}}\right)\right)\right) \]
      5. sqrt-unprod55.4%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{\left(-F\right) \cdot \left(-F\right)}}}\right)\right)\right) \]
      6. sqr-neg55.4%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\sqrt{\color{blue}{F \cdot F}}}\right)\right)\right) \]
      7. sqrt-prod29.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{F} \cdot \sqrt{F}}}\right)\right)\right) \]
      8. add-sqr-sqrt53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{F}}\right)\right)\right) \]
      9. associate-/r*53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\right)\right)\right) \]
      10. div-inv53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}}\right)\right)\right) \]
      11. pow253.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{{F}^{2}}}\right)\right)\right) \]
      12. pow-flip53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{{F}^{\left(-2\right)}}\right)\right)\right) \]
      13. metadata-eval53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{\color{blue}{-2}}\right)\right)\right) \]
    5. Applied egg-rr53.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{-2}\right)\right)\right)} \]
    6. Taylor expanded in F around inf 89.9%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + \ell \cdot \pi\right)}\right) \]
    7. Step-by-step derivation
      1. log1p-def89.9%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
    8. Simplified89.9%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq 10000:\\ \;\;\;\;\mathsf{fma}\left(\pi, \ell, \frac{\frac{-\ell}{\frac{F}{\pi}}}{F}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\\ \end{array} \]

Alternative 3: 94.1% accurate, 1.0× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \begin{array}{l} \mathbf{if}\;l_m \leq 3400:\\ \;\;\;\;\pi \cdot l_m - \frac{\frac{l_m}{F}}{\frac{F}{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= l_m 3400.0)
    (- (* PI l_m) (/ (/ l_m F) (/ F PI)))
    (expm1 (log1p (* PI l_m))))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if (l_m <= 3400.0) {
		tmp = (((double) M_PI) * l_m) - ((l_m / F) / (F / ((double) M_PI)));
	} else {
		tmp = expm1(log1p((((double) M_PI) * l_m)));
	}
	return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if (l_m <= 3400.0) {
		tmp = (Math.PI * l_m) - ((l_m / F) / (F / Math.PI));
	} else {
		tmp = Math.expm1(Math.log1p((Math.PI * l_m)));
	}
	return l_s * tmp;
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if l_m <= 3400.0:
		tmp = (math.pi * l_m) - ((l_m / F) / (F / math.pi))
	else:
		tmp = math.expm1(math.log1p((math.pi * l_m)))
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (l_m <= 3400.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(l_m / F) / Float64(F / pi)));
	else
		tmp = expm1(log1p(Float64(pi * l_m)));
	end
	return Float64(l_s * tmp)
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[l$95$m, 3400.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / F), $MachinePrecision] / N[(F / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 3400:\\
\;\;\;\;\pi \cdot l_m - \frac{\frac{l_m}{F}}{\frac{F}{\pi}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot l_m\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 3400

    1. Initial program 79.3%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg79.3%

        \[\leadsto \pi \cdot \ell - \frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right) \]
      2. associate-*l/80.7%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\left(-F\right) \cdot \left(-F\right)}} \]
      3. sqr-neg80.7%

        \[\leadsto \pi \cdot \ell - \frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\color{blue}{F \cdot F}} \]
      4. *-lft-identity80.7%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot F} \]
    3. Simplified80.7%

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Step-by-step derivation
      1. *-commutative73.2%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \ell}}{F \cdot F} \]
      2. times-frac80.2%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
    6. Applied egg-rr80.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
    7. Step-by-step derivation
      1. *-commutative80.2%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
      2. clear-num80.1%

        \[\leadsto \pi \cdot \ell - \frac{\ell}{F} \cdot \color{blue}{\frac{1}{\frac{F}{\pi}}} \]
      3. un-div-inv80.2%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F}}{\frac{F}{\pi}}} \]
    8. Applied egg-rr80.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F}}{\frac{F}{\pi}}} \]

    if 3400 < l

    1. Initial program 60.3%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. fma-neg60.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, -\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)} \]
      2. distribute-lft-neg-in60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\left(-\frac{1}{F \cdot F}\right) \cdot \tan \left(\pi \cdot \ell\right)}\right) \]
      3. sqr-neg60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \left(-\frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}}\right) \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      4. distribute-neg-frac60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{-1}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      5. metadata-eval60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{-1}}{\left(-F\right) \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      6. distribute-lft-neg-out60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      7. neg-mul-160.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{-1}{\color{blue}{-1 \cdot \left(F \cdot \left(-F\right)\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      8. associate-/r*60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{-1}{-1}}{F \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      9. metadata-eval60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{1}}{F \cdot \left(-F\right)} \cdot \tan \left(\pi \cdot \ell\right)\right) \]
      10. associate-*l/60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right) \]
      11. *-lft-identity60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot \left(-F\right)}\right) \]
      12. associate-/l/60.3%

        \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}}\right) \]
    3. Simplified60.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u55.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)\right)\right)} \]
      2. associate-/l/55.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot \left(-F\right)}}\right)\right)\right) \]
      3. associate-/r*55.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{-F}}\right)\right)\right) \]
      4. add-sqr-sqrt25.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{-F} \cdot \sqrt{-F}}}\right)\right)\right) \]
      5. sqrt-unprod55.4%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{\left(-F\right) \cdot \left(-F\right)}}}\right)\right)\right) \]
      6. sqr-neg55.4%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\sqrt{\color{blue}{F \cdot F}}}\right)\right)\right) \]
      7. sqrt-prod29.5%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{F} \cdot \sqrt{F}}}\right)\right)\right) \]
      8. add-sqr-sqrt53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{F}}\right)\right)\right) \]
      9. associate-/r*53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}}\right)\right)\right) \]
      10. div-inv53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}}\right)\right)\right) \]
      11. pow253.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{{F}^{2}}}\right)\right)\right) \]
      12. pow-flip53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{{F}^{\left(-2\right)}}\right)\right)\right) \]
      13. metadata-eval53.9%

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{\color{blue}{-2}}\right)\right)\right) \]
    5. Applied egg-rr53.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(\pi, \ell, \tan \left(\pi \cdot \ell\right) \cdot {F}^{-2}\right)\right)\right)} \]
    6. Taylor expanded in F around inf 89.9%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + \ell \cdot \pi\right)}\right) \]
    7. Step-by-step derivation
      1. log1p-def89.9%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
    8. Simplified89.9%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\ell \cdot \pi\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 3400:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\ell}{F}}{\frac{F}{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\\ \end{array} \]

Alternative 4: 74.9% accurate, 1.5× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \left(\pi \cdot l_m - \frac{l_m}{F} \cdot \frac{\pi}{F}\right) \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (* l_s (- (* PI l_m) (* (/ l_m F) (/ PI F)))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) - ((l_m / F) * (((double) M_PI) / F)));
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) - ((l_m / F) * (Math.PI / F)));
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) - ((l_m / F) * (math.pi / F)))
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) - Float64(Float64(l_m / F) * Float64(pi / F))))
end
l_m = abs(l);
l_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) - ((l_m / F) * (pi / F)));
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \left(\pi \cdot l_m - \frac{l_m}{F} \cdot \frac{\pi}{F}\right)
\end{array}
Derivation
  1. Initial program 75.1%

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. sqr-neg75.1%

      \[\leadsto \pi \cdot \ell - \frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\left(-F\right) \cdot \left(-F\right)}} \]
    3. sqr-neg76.2%

      \[\leadsto \pi \cdot \ell - \frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\color{blue}{F \cdot F}} \]
    4. *-lft-identity76.2%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot F} \]
  3. Simplified76.2%

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

    \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
  5. Step-by-step derivation
    1. *-commutative69.0%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \ell}}{F \cdot F} \]
    2. times-frac74.4%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
  6. Applied egg-rr74.4%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
  7. Final simplification74.4%

    \[\leadsto \pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F} \]

Alternative 5: 74.9% accurate, 1.5× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \left(\pi \cdot l_m - \frac{\frac{l_m}{F}}{\frac{F}{\pi}}\right) \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (* l_s (- (* PI l_m) (/ (/ l_m F) (/ F PI)))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) - ((l_m / F) / (F / ((double) M_PI))));
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) - ((l_m / F) / (F / Math.PI)));
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) - ((l_m / F) / (F / math.pi)))
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) - Float64(Float64(l_m / F) / Float64(F / pi))))
end
l_m = abs(l);
l_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) - ((l_m / F) / (F / pi)));
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / F), $MachinePrecision] / N[(F / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \left(\pi \cdot l_m - \frac{\frac{l_m}{F}}{\frac{F}{\pi}}\right)
\end{array}
Derivation
  1. Initial program 75.1%

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. sqr-neg75.1%

      \[\leadsto \pi \cdot \ell - \frac{1}{\color{blue}{\left(-F\right) \cdot \left(-F\right)}} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\left(-F\right) \cdot \left(-F\right)}} \]
    3. sqr-neg76.2%

      \[\leadsto \pi \cdot \ell - \frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{\color{blue}{F \cdot F}} \]
    4. *-lft-identity76.2%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot F} \]
  3. Simplified76.2%

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

    \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
  5. Step-by-step derivation
    1. *-commutative69.0%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \ell}}{F \cdot F} \]
    2. times-frac74.4%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
  6. Applied egg-rr74.4%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
  7. Step-by-step derivation
    1. *-commutative74.4%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
    2. clear-num74.4%

      \[\leadsto \pi \cdot \ell - \frac{\ell}{F} \cdot \color{blue}{\frac{1}{\frac{F}{\pi}}} \]
    3. un-div-inv74.4%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F}}{\frac{F}{\pi}}} \]
  8. Applied egg-rr74.4%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F}}{\frac{F}{\pi}}} \]
  9. Final simplification74.4%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\ell}{F}}{\frac{F}{\pi}} \]

Reproduce

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