VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.4% → 99.4%
Time: 4.1s
Alternatives: 6
Speedup: 2.7×

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}

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 6 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: 76.4% 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: 99.4% accurate, 0.2× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := \pi - \frac{1}{\pi}\\ t_1 := \tan \left(\left(t\_0 \cdot 0.5\right) \cdot l\_m\right)\\ t_2 := \left(\frac{1}{\pi} + \pi\right) \cdot 0.5\\ t_3 := \tan \left(t\_2 \cdot l\_m\right)\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 2.2 \cdot 10^{+15}:\\ \;\;\;\;\pi \cdot l\_m - \frac{\frac{\frac{t\_1 + t\_3}{1 - t\_1 \cdot t\_3}}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_2, l\_m, 0.5 \cdot \left(l\_m \cdot t\_0\right)\right)\\ \end{array} \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (let* ((t_0 (- PI (/ 1.0 PI)))
        (t_1 (tan (* (* t_0 0.5) l_m)))
        (t_2 (* (+ (/ 1.0 PI) PI) 0.5))
        (t_3 (tan (* t_2 l_m))))
   (*
    l_s
    (if (<= l_m 2.2e+15)
      (- (* PI l_m) (/ (/ (/ (+ t_1 t_3) (- 1.0 (* t_1 t_3))) F) F))
      (fma t_2 l_m (* 0.5 (* l_m t_0)))))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double t_0 = ((double) M_PI) - (1.0 / ((double) M_PI));
	double t_1 = tan(((t_0 * 0.5) * l_m));
	double t_2 = ((1.0 / ((double) M_PI)) + ((double) M_PI)) * 0.5;
	double t_3 = tan((t_2 * l_m));
	double tmp;
	if (l_m <= 2.2e+15) {
		tmp = (((double) M_PI) * l_m) - ((((t_1 + t_3) / (1.0 - (t_1 * t_3))) / F) / F);
	} else {
		tmp = fma(t_2, l_m, (0.5 * (l_m * t_0)));
	}
	return l_s * tmp;
}
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	t_0 = Float64(pi - Float64(1.0 / pi))
	t_1 = tan(Float64(Float64(t_0 * 0.5) * l_m))
	t_2 = Float64(Float64(Float64(1.0 / pi) + pi) * 0.5)
	t_3 = tan(Float64(t_2 * l_m))
	tmp = 0.0
	if (l_m <= 2.2e+15)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(Float64(Float64(t_1 + t_3) / Float64(1.0 - Float64(t_1 * t_3))) / F) / F));
	else
		tmp = fma(t_2, l_m, Float64(0.5 * Float64(l_m * t_0)));
	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_] := Block[{t$95$0 = N[(Pi - N[(1.0 / Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Tan[N[(N[(t$95$0 * 0.5), $MachinePrecision] * l$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(1.0 / Pi), $MachinePrecision] + Pi), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[Tan[N[(t$95$2 * l$95$m), $MachinePrecision]], $MachinePrecision]}, N[(l$95$s * If[LessEqual[l$95$m, 2.2e+15], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[(N[(t$95$1 + t$95$3), $MachinePrecision] / N[(1.0 - N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * l$95$m + N[(0.5 * N[(l$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]]]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
\begin{array}{l}
t_0 := \pi - \frac{1}{\pi}\\
t_1 := \tan \left(\left(t\_0 \cdot 0.5\right) \cdot l\_m\right)\\
t_2 := \left(\frac{1}{\pi} + \pi\right) \cdot 0.5\\
t_3 := \tan \left(t\_2 \cdot l\_m\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 2.2 \cdot 10^{+15}:\\
\;\;\;\;\pi \cdot l\_m - \frac{\frac{\frac{t\_1 + t\_3}{1 - t\_1 \cdot t\_3}}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, l\_m, 0.5 \cdot \left(l\_m \cdot t\_0\right)\right)\\


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

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

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

    if 2.2e15 < l

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \left(\left(\pi - \frac{1}{\pi}\right) \cdot 0.5\right) \cdot \ell - \frac{\tan \left(\ell \cdot \pi\right)}{F \cdot F}\right)} \]
    5. Taylor expanded in F around inf

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \color{blue}{\frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \color{blue}{\left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \color{blue}{\left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      4. lower-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{\color{blue}{1}}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      5. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      6. lower-PI.f6474.1

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, 0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right) \]
    7. Applied rewrites74.1%

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \color{blue}{0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.4% 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 2.2 \cdot 10^{+15}:\\ \;\;\;\;\pi \cdot l\_m - \frac{\frac{\tan \left(l\_m \cdot \pi\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, l\_m, 0.5 \cdot \left(l\_m \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right)\\ \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= l_m 2.2e+15)
    (- (* PI l_m) (/ (/ (tan (* l_m PI)) F) F))
    (fma (* (+ (/ 1.0 PI) PI) 0.5) l_m (* 0.5 (* l_m (- PI (/ 1.0 PI))))))))
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 <= 2.2e+15) {
		tmp = (((double) M_PI) * l_m) - ((tan((l_m * ((double) M_PI))) / F) / F);
	} else {
		tmp = fma((((1.0 / ((double) M_PI)) + ((double) M_PI)) * 0.5), l_m, (0.5 * (l_m * (((double) M_PI) - (1.0 / ((double) M_PI))))));
	}
	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 <= 2.2e+15)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(tan(Float64(l_m * pi)) / F) / F));
	else
		tmp = fma(Float64(Float64(Float64(1.0 / pi) + pi) * 0.5), l_m, Float64(0.5 * Float64(l_m * Float64(pi - Float64(1.0 / pi)))));
	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, 2.2e+15], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Tan[N[(l$95$m * Pi), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / Pi), $MachinePrecision] + Pi), $MachinePrecision] * 0.5), $MachinePrecision] * l$95$m + N[(0.5 * N[(l$95$m * N[(Pi - N[(1.0 / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 2.2 \cdot 10^{+15}:\\
\;\;\;\;\pi \cdot l\_m - \frac{\frac{\tan \left(l\_m \cdot \pi\right)}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, l\_m, 0.5 \cdot \left(l\_m \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right)\\


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

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

    if 2.2e15 < l

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \left(\left(\pi - \frac{1}{\pi}\right) \cdot 0.5\right) \cdot \ell - \frac{\tan \left(\ell \cdot \pi\right)}{F \cdot F}\right)} \]
    5. Taylor expanded in F around inf

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \color{blue}{\frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \color{blue}{\left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \color{blue}{\left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      4. lower-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{\color{blue}{1}}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      5. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      6. lower-PI.f6474.1

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, 0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right) \]
    7. Applied rewrites74.1%

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \color{blue}{0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.8% accurate, 1.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}\;l\_m \leq 62000000000000:\\ \;\;\;\;\pi \cdot l\_m - \frac{\pi \cdot \frac{l\_m}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, l\_m, 0.5 \cdot \left(l\_m \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right)\\ \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= l_m 62000000000000.0)
    (- (* PI l_m) (/ (* PI (/ l_m F)) F))
    (fma (* (+ (/ 1.0 PI) PI) 0.5) l_m (* 0.5 (* l_m (- PI (/ 1.0 PI))))))))
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 <= 62000000000000.0) {
		tmp = (((double) M_PI) * l_m) - ((((double) M_PI) * (l_m / F)) / F);
	} else {
		tmp = fma((((1.0 / ((double) M_PI)) + ((double) M_PI)) * 0.5), l_m, (0.5 * (l_m * (((double) M_PI) - (1.0 / ((double) M_PI))))));
	}
	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 <= 62000000000000.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(pi * Float64(l_m / F)) / F));
	else
		tmp = fma(Float64(Float64(Float64(1.0 / pi) + pi) * 0.5), l_m, Float64(0.5 * Float64(l_m * Float64(pi - Float64(1.0 / pi)))));
	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, 62000000000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(Pi * N[(l$95$m / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / Pi), $MachinePrecision] + Pi), $MachinePrecision] * 0.5), $MachinePrecision] * l$95$m + N[(0.5 * N[(l$95$m * N[(Pi - N[(1.0 / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 62000000000000:\\
\;\;\;\;\pi \cdot l\_m - \frac{\pi \cdot \frac{l\_m}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, l\_m, 0.5 \cdot \left(l\_m \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right)\\


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

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \mathsf{PI}\left(\right)}{F}}}{F} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \mathsf{PI}\left(\right)}{\color{blue}{F}}}{F} \]
      2. lower-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \mathsf{PI}\left(\right)}{F}}{F} \]
      3. lower-PI.f6474.6

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{F}}{F} \]
    6. Applied rewrites74.6%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \pi}{F}}}{F} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{\color{blue}{F}}}{F} \]
      2. lift-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{F}}{F} \]
      3. *-commutativeN/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\pi \cdot \ell}{F}}{F} \]
      4. associate-/l*N/A

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \color{blue}{\frac{\ell}{F}}}{F} \]
      5. lower-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \color{blue}{\frac{\ell}{F}}}{F} \]
      6. lower-/.f6474.7

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \frac{\ell}{\color{blue}{F}}}{F} \]
    8. Applied rewrites74.7%

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

    if 6.2e13 < l

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \left(\left(\pi - \frac{1}{\pi}\right) \cdot 0.5\right) \cdot \ell - \frac{\tan \left(\ell \cdot \pi\right)}{F \cdot F}\right)} \]
    5. Taylor expanded in F around inf

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \color{blue}{\frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \color{blue}{\left(\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)\right)}\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \color{blue}{\left(\mathsf{PI}\left(\right) - \frac{1}{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\mathsf{PI}\left(\right) - \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      4. lower-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{\color{blue}{1}}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      5. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot \frac{1}{2}, \ell, \frac{1}{2} \cdot \left(\ell \cdot \left(\pi - \frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}\right)\right)\right) \]
      6. lower-PI.f6474.1

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, 0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)\right) \]
    7. Applied rewrites74.1%

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{\pi} + \pi\right) \cdot 0.5, \ell, \color{blue}{0.5 \cdot \left(\ell \cdot \left(\pi - \frac{1}{\pi}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.8% accurate, 2.7× 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 62000000000000:\\ \;\;\;\;\pi \cdot l\_m - \frac{\pi \cdot \frac{l\_m}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;l\_m \cdot \pi\\ \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= l_m 62000000000000.0)
    (- (* PI l_m) (/ (* PI (/ l_m F)) F))
    (* l_m PI))))
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 <= 62000000000000.0) {
		tmp = (((double) M_PI) * l_m) - ((((double) M_PI) * (l_m / F)) / F);
	} else {
		tmp = l_m * ((double) M_PI);
	}
	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 <= 62000000000000.0) {
		tmp = (Math.PI * l_m) - ((Math.PI * (l_m / F)) / F);
	} else {
		tmp = l_m * Math.PI;
	}
	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 <= 62000000000000.0:
		tmp = (math.pi * l_m) - ((math.pi * (l_m / F)) / F)
	else:
		tmp = l_m * math.pi
	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 <= 62000000000000.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(pi * Float64(l_m / F)) / F));
	else
		tmp = Float64(l_m * pi);
	end
	return Float64(l_s * tmp)
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp_2 = code(l_s, F, l_m)
	tmp = 0.0;
	if (l_m <= 62000000000000.0)
		tmp = (pi * l_m) - ((pi * (l_m / F)) / F);
	else
		tmp = l_m * pi;
	end
	tmp_2 = 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, 62000000000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(Pi * N[(l$95$m / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(l$95$m * Pi), $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 62000000000000:\\
\;\;\;\;\pi \cdot l\_m - \frac{\pi \cdot \frac{l\_m}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;l\_m \cdot \pi\\


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

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \mathsf{PI}\left(\right)}{F}}}{F} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \mathsf{PI}\left(\right)}{\color{blue}{F}}}{F} \]
      2. lower-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \mathsf{PI}\left(\right)}{F}}{F} \]
      3. lower-PI.f6474.6

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{F}}{F} \]
    6. Applied rewrites74.6%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \pi}{F}}}{F} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{\color{blue}{F}}}{F} \]
      2. lift-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\ell \cdot \pi}{F}}{F} \]
      3. *-commutativeN/A

        \[\leadsto \pi \cdot \ell - \frac{\frac{\pi \cdot \ell}{F}}{F} \]
      4. associate-/l*N/A

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \color{blue}{\frac{\ell}{F}}}{F} \]
      5. lower-*.f64N/A

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \color{blue}{\frac{\ell}{F}}}{F} \]
      6. lower-/.f6474.7

        \[\leadsto \pi \cdot \ell - \frac{\pi \cdot \frac{\ell}{\color{blue}{F}}}{F} \]
    8. Applied rewrites74.7%

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

    if 6.2e13 < l

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\ell \cdot \mathsf{PI}\left(\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\mathsf{PI}\left(\right)} \]
      2. lower-PI.f6474.1

        \[\leadsto \ell \cdot \pi \]
    4. Applied rewrites74.1%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.7% accurate, 2.7× 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 62000000000000:\\ \;\;\;\;\frac{l\_m \cdot \left(F \cdot \pi - \frac{\pi}{F}\right)}{F}\\ \mathbf{else}:\\ \;\;\;\;l\_m \cdot \pi\\ \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= l_m 62000000000000.0)
    (/ (* l_m (- (* F PI) (/ PI F))) F)
    (* l_m PI))))
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 <= 62000000000000.0) {
		tmp = (l_m * ((F * ((double) M_PI)) - (((double) M_PI) / F))) / F;
	} else {
		tmp = l_m * ((double) M_PI);
	}
	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 <= 62000000000000.0) {
		tmp = (l_m * ((F * Math.PI) - (Math.PI / F))) / F;
	} else {
		tmp = l_m * Math.PI;
	}
	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 <= 62000000000000.0:
		tmp = (l_m * ((F * math.pi) - (math.pi / F))) / F
	else:
		tmp = l_m * math.pi
	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 <= 62000000000000.0)
		tmp = Float64(Float64(l_m * Float64(Float64(F * pi) - Float64(pi / F))) / F);
	else
		tmp = Float64(l_m * pi);
	end
	return Float64(l_s * tmp)
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp_2 = code(l_s, F, l_m)
	tmp = 0.0;
	if (l_m <= 62000000000000.0)
		tmp = (l_m * ((F * pi) - (pi / F))) / F;
	else
		tmp = l_m * pi;
	end
	tmp_2 = 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, 62000000000000.0], N[(N[(l$95$m * N[(N[(F * Pi), $MachinePrecision] - N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision], N[(l$95$m * Pi), $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 62000000000000:\\
\;\;\;\;\frac{l\_m \cdot \left(F \cdot \pi - \frac{\pi}{F}\right)}{F}\\

\mathbf{else}:\\
\;\;\;\;l\_m \cdot \pi\\


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

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. mult-flip-revN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      7. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{1}{F}} \]
      8. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{F}^{-1}} \]
      9. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({F}^{\left(\frac{-1}{2}\right)} \cdot {F}^{\left(\frac{-1}{2}\right)}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(F \cdot F\right)}^{\left(\frac{-1}{2}\right)}} \]
      11. sqr-abs-revN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot {\color{blue}{\left(\left|F\right| \cdot \left|F\right|\right)}}^{\left(\frac{-1}{2}\right)} \]
      12. unpow-prod-downN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\left({\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\left|F\right|\right)}^{\left(\frac{-1}{2}\right)}\right)} \]
      13. sqr-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{{\left(\left|F\right|\right)}^{-1}} \]
      14. inv-powN/A

        \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \color{blue}{\frac{1}{\left|F\right|}} \]
      15. mult-flipN/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{\left|F\right|}} \]
      16. lower-/.f64N/A

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
    4. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
      2. lift-/.f64N/A

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
      3. sub-to-fractionN/A

        \[\leadsto \color{blue}{\frac{\left(\pi \cdot \ell\right) \cdot F - \frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
      4. mult-flipN/A

        \[\leadsto \color{blue}{\left(\left(\pi \cdot \ell\right) \cdot F - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F}} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\pi \cdot \ell\right) \cdot F - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F}} \]
      6. lower--.f64N/A

        \[\leadsto \color{blue}{\left(\left(\pi \cdot \ell\right) \cdot F - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right)} \cdot \frac{1}{F} \]
      7. *-commutativeN/A

        \[\leadsto \left(\color{blue}{F \cdot \left(\pi \cdot \ell\right)} - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F} \]
      8. lower-*.f64N/A

        \[\leadsto \left(\color{blue}{F \cdot \left(\pi \cdot \ell\right)} - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F} \]
      9. lift-*.f64N/A

        \[\leadsto \left(F \cdot \color{blue}{\left(\pi \cdot \ell\right)} - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F} \]
      10. *-commutativeN/A

        \[\leadsto \left(F \cdot \color{blue}{\left(\ell \cdot \pi\right)} - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F} \]
      11. lift-*.f64N/A

        \[\leadsto \left(F \cdot \color{blue}{\left(\ell \cdot \pi\right)} - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \frac{1}{F} \]
      12. lower-/.f6470.3

        \[\leadsto \left(F \cdot \left(\ell \cdot \pi\right) - \frac{\tan \left(\ell \cdot \pi\right)}{F}\right) \cdot \color{blue}{\frac{1}{F}} \]
    5. Applied rewrites70.3%

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

      \[\leadsto \color{blue}{\frac{\ell \cdot \left(F \cdot \mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F}\right)}{\color{blue}{F}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F} \]
      5. lower-PI.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \pi - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{\ell \cdot \left(F \cdot \pi - \frac{\mathsf{PI}\left(\right)}{F}\right)}{F} \]
      7. lower-PI.f6463.3

        \[\leadsto \frac{\ell \cdot \left(F \cdot \pi - \frac{\pi}{F}\right)}{F} \]
    8. Applied rewrites63.3%

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

    if 6.2e13 < l

    1. Initial program 76.4%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\ell \cdot \mathsf{PI}\left(\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\mathsf{PI}\left(\right)} \]
      2. lower-PI.f6474.1

        \[\leadsto \ell \cdot \pi \]
    4. Applied rewrites74.1%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 74.1% accurate, 13.6× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(l\_m \cdot \pi\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m) :precision binary64 (* l_s (* l_m PI)))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * (l_m * ((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 * (l_m * Math.PI);
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * (l_m * math.pi)
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(l_m * pi))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * (l_m * 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[(l$95$m * Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(l\_m \cdot \pi\right)
\end{array}
Derivation
  1. Initial program 76.4%

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Taylor expanded in F around inf

    \[\leadsto \color{blue}{\ell \cdot \mathsf{PI}\left(\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \ell \cdot \color{blue}{\mathsf{PI}\left(\right)} \]
    2. lower-PI.f6474.1

      \[\leadsto \ell \cdot \pi \]
  4. Applied rewrites74.1%

    \[\leadsto \color{blue}{\ell \cdot \pi} \]
  5. Add Preprocessing

Reproduce

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