VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.5% → 99.4%
Time: 16.3s
Alternatives: 9
Speedup: 3.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}

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 9 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.5% 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.9× 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;l\_m \cdot \pi - \frac{\frac{\tan \left(l\_m \cdot \pi\right)}{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 PI) 1e+16)
    (- (* l_m PI) (/ (/ (tan (* l_m 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 * ((double) M_PI)) <= 1e+16) {
		tmp = (l_m * ((double) M_PI)) - ((tan((l_m * ((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 * Math.PI) <= 1e+16) {
		tmp = (l_m * Math.PI) - ((Math.tan((l_m * 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 * math.pi) <= 1e+16:
		tmp = (l_m * math.pi) - ((math.tan((l_m * 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 (Float64(l_m * pi) <= 1e+16)
		tmp = Float64(Float64(l_m * pi) - Float64(Float64(tan(Float64(l_m * 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 * pi) <= 1e+16)
		tmp = (l_m * pi) - ((tan((l_m * 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[(N[Tan[N[(l$95$m * Pi), $MachinePrecision]], $MachinePrecision] / F), $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 \cdot \pi \leq 10^{+16}:\\
\;\;\;\;l\_m \cdot \pi - \frac{\frac{\tan \left(l\_m \cdot \pi\right)}{F}}{F}\\

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


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

    1. Initial program 78.6%

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
      4. un-div-invN/A

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
      8. lower-/.f6485.9

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
      11. lower-*.f6485.9

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

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

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

    1. Initial program 61.8%

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

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

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

        \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
      3. lower-PI.f6499.5

        \[\leadsto \color{blue}{\pi} \cdot \ell \]
    5. Applied rewrites99.5%

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

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

Alternative 2: 83.6% 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}\;l\_m \cdot \pi - \tan \left(l\_m \cdot \pi\right) \cdot \frac{1}{F \cdot F} \leq -4 \cdot 10^{-287}:\\ \;\;\;\;\frac{\pi}{\left(-F\right) \cdot F} \cdot l\_m\\ \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 PI) (* (tan (* l_m PI)) (/ 1.0 (* F F)))) -4e-287)
    (* (/ PI (* (- F) F)) l_m)
    (* 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 * ((double) M_PI)) - (tan((l_m * ((double) M_PI))) * (1.0 / (F * F)))) <= -4e-287) {
		tmp = (((double) M_PI) / (-F * F)) * l_m;
	} 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 * Math.PI) - (Math.tan((l_m * Math.PI)) * (1.0 / (F * F)))) <= -4e-287) {
		tmp = (Math.PI / (-F * F)) * l_m;
	} 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 * math.pi) - (math.tan((l_m * math.pi)) * (1.0 / (F * F)))) <= -4e-287:
		tmp = (math.pi / (-F * F)) * l_m
	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 (Float64(Float64(l_m * pi) - Float64(tan(Float64(l_m * pi)) * Float64(1.0 / Float64(F * F)))) <= -4e-287)
		tmp = Float64(Float64(pi / Float64(Float64(-F) * F)) * l_m);
	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 * pi) - (tan((l_m * pi)) * (1.0 / (F * F)))) <= -4e-287)
		tmp = (pi / (-F * F)) * l_m;
	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[N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[Tan[N[(l$95$m * Pi), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-287], N[(N[(Pi / N[((-F) * F), $MachinePrecision]), $MachinePrecision] * l$95$m), $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 \cdot \pi - \tan \left(l\_m \cdot \pi\right) \cdot \frac{1}{F \cdot F} \leq -4 \cdot 10^{-287}:\\
\;\;\;\;\frac{\pi}{\left(-F\right) \cdot F} \cdot l\_m\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -4.00000000000000009e-287

    1. Initial program 72.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. rem-square-sqrtN/A

        \[\leadsto \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      2. sqrt-unprodN/A

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

        \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      4. add-sqr-sqrtN/A

        \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      5. associate-*r*N/A

        \[\leadsto \sqrt{\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{\mathsf{PI}\left(\right)}}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      6. sqrt-prodN/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\sqrt{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      15. lower-sqrt.f6472.6

        \[\leadsto \left(\sqrt{\sqrt{\pi} \cdot \pi} \cdot \sqrt{\color{blue}{\sqrt{\pi}}}\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    4. Applied rewrites72.6%

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

      \[\leadsto \color{blue}{\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right) \cdot \ell} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) + \left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)\right)\right)} \cdot \ell \]
      3. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) + -1 \cdot \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right) \cdot \ell} \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{PI}\left(\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)\right)}\right) \cdot \ell \]
      6. sub-negN/A

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

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

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

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

        \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}}\right) \cdot \ell \]
      11. unpow2N/A

        \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}}\right) \cdot \ell \]
      12. lower-*.f6467.7

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

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

      \[\leadsto \left(-1 \cdot \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right) \cdot \ell \]
    9. Step-by-step derivation
      1. Applied rewrites27.8%

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

      if -4.00000000000000009e-287 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

      1. Initial program 75.6%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6475.7

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites75.7%

        \[\leadsto \color{blue}{\pi \cdot \ell} \]
    10. Recombined 2 regimes into one program.
    11. Final simplification53.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi - \tan \left(\ell \cdot \pi\right) \cdot \frac{1}{F \cdot F} \leq -4 \cdot 10^{-287}:\\ \;\;\;\;\frac{\pi}{\left(-F\right) \cdot F} \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
    12. Add Preprocessing

    Alternative 3: 98.6% 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;l\_m \cdot \pi - \frac{\frac{\mathsf{fma}\left(0.3333333333333333 \cdot \left(l\_m \cdot l\_m\right), \left(\pi \cdot \pi\right) \cdot \pi, \pi\right) \cdot 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 PI) 1e+16)
        (-
         (* l_m PI)
         (/
          (/
           (* (fma (* 0.3333333333333333 (* l_m l_m)) (* (* PI PI) PI) 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 * ((double) M_PI)) <= 1e+16) {
    		tmp = (l_m * ((double) M_PI)) - (((fma((0.3333333333333333 * (l_m * l_m)), ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)), ((double) M_PI)) * l_m) / F) / F);
    	} else {
    		tmp = l_m * ((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 (Float64(l_m * pi) <= 1e+16)
    		tmp = Float64(Float64(l_m * pi) - Float64(Float64(Float64(fma(Float64(0.3333333333333333 * Float64(l_m * l_m)), Float64(Float64(pi * pi) * pi), pi) * l_m) / F) / F));
    	else
    		tmp = Float64(l_m * 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[(N[(N[(N[(0.3333333333333333 * N[(l$95$m * l$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision] + Pi), $MachinePrecision] * l$95$m), $MachinePrecision] / F), $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 \cdot \pi \leq 10^{+16}:\\
    \;\;\;\;l\_m \cdot \pi - \frac{\frac{\mathsf{fma}\left(0.3333333333333333 \cdot \left(l\_m \cdot l\_m\right), \left(\pi \cdot \pi\right) \cdot \pi, \pi\right) \cdot l\_m}{F}}{F}\\
    
    \mathbf{else}:\\
    \;\;\;\;l\_m \cdot \pi\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 1e16

      1. Initial program 78.6%

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
        4. un-div-invN/A

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
        8. lower-/.f6485.9

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
        11. lower-*.f6485.9

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\color{blue}{\ell \cdot \left(\mathsf{PI}\left(\right) + {\ell}^{2} \cdot \left(\frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3} - \frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}}{F}}{F} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\color{blue}{\left(\mathsf{PI}\left(\right) + {\ell}^{2} \cdot \left(\frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3} - \frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) \cdot \ell}}{F}}{F} \]
      7. Applied rewrites76.1%

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

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

      1. Initial program 61.8%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6499.5

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites99.5%

        \[\leadsto \color{blue}{\pi \cdot \ell} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification82.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\ell \cdot \pi - \frac{\frac{\mathsf{fma}\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right), \left(\pi \cdot \pi\right) \cdot \pi, \pi\right) \cdot \ell}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 98.6% accurate, 2.9× 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;l\_m \cdot \pi - \frac{\frac{l\_m \cdot \pi}{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 PI) 1e+16) (- (* l_m PI) (/ (/ (* l_m 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 * ((double) M_PI)) <= 1e+16) {
    		tmp = (l_m * ((double) M_PI)) - (((l_m * ((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 * Math.PI) <= 1e+16) {
    		tmp = (l_m * Math.PI) - (((l_m * 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 * math.pi) <= 1e+16:
    		tmp = (l_m * math.pi) - (((l_m * 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 (Float64(l_m * pi) <= 1e+16)
    		tmp = Float64(Float64(l_m * pi) - Float64(Float64(Float64(l_m * 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 * pi) <= 1e+16)
    		tmp = (l_m * pi) - (((l_m * 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[(N[(l$95$m * Pi), $MachinePrecision] / F), $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 \cdot \pi \leq 10^{+16}:\\
    \;\;\;\;l\_m \cdot \pi - \frac{\frac{l\_m \cdot \pi}{F}}{F}\\
    
    \mathbf{else}:\\
    \;\;\;\;l\_m \cdot \pi\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 1e16

      1. Initial program 78.6%

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
        4. un-div-invN/A

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
        8. lower-/.f6485.9

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
        11. lower-*.f6485.9

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{F}}{F} \]
        3. lower-PI.f6481.4

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

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

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

      1. Initial program 61.8%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6499.5

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites99.5%

        \[\leadsto \color{blue}{\pi \cdot \ell} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification85.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\ell \cdot \pi - \frac{\frac{\ell \cdot \pi}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
    5. Add Preprocessing

    Alternative 5: 98.6% accurate, 2.9× 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;l\_m \cdot \pi - \frac{\frac{\pi}{F} \cdot l\_m}{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 PI) 1e+16) (- (* l_m PI) (/ (* (/ PI F) l_m) 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 * ((double) M_PI)) <= 1e+16) {
    		tmp = (l_m * ((double) M_PI)) - (((((double) M_PI) / F) * l_m) / 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 * Math.PI) <= 1e+16) {
    		tmp = (l_m * Math.PI) - (((Math.PI / F) * l_m) / 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 * math.pi) <= 1e+16:
    		tmp = (l_m * math.pi) - (((math.pi / F) * l_m) / 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 (Float64(l_m * pi) <= 1e+16)
    		tmp = Float64(Float64(l_m * pi) - Float64(Float64(Float64(pi / F) * l_m) / 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 * pi) <= 1e+16)
    		tmp = (l_m * pi) - (((pi / F) * l_m) / 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[(N[(Pi / F), $MachinePrecision] * l$95$m), $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 \cdot \pi \leq 10^{+16}:\\
    \;\;\;\;l\_m \cdot \pi - \frac{\frac{\pi}{F} \cdot l\_m}{F}\\
    
    \mathbf{else}:\\
    \;\;\;\;l\_m \cdot \pi\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 1e16

      1. Initial program 78.6%

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
        4. un-div-invN/A

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
        8. lower-/.f6485.9

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
        11. lower-*.f6485.9

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

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

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\mathsf{PI}\left(\right)}{F}} \cdot \ell}{F} \]
        5. lower-PI.f6481.9

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

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

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

      1. Initial program 61.8%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6499.5

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites99.5%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\ell \cdot \pi - \frac{\frac{\pi}{F} \cdot \ell}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 93.0% accurate, 3.3× 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(\pi, l\_m, \frac{l\_m \cdot \pi}{\left(-F\right) \cdot F}\right)\\ \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 PI) 1e+16)
        (fma PI l_m (/ (* l_m 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 * ((double) M_PI)) <= 1e+16) {
    		tmp = fma(((double) M_PI), l_m, ((l_m * ((double) M_PI)) / (-F * F)));
    	} else {
    		tmp = l_m * ((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 (Float64(l_m * pi) <= 1e+16)
    		tmp = fma(pi, l_m, Float64(Float64(l_m * pi) / Float64(Float64(-F) * F)));
    	else
    		tmp = Float64(l_m * 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(Pi * l$95$m + N[(N[(l$95$m * Pi), $MachinePrecision] / N[((-F) * F), $MachinePrecision]), $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 \cdot \pi \leq 10^{+16}:\\
    \;\;\;\;\mathsf{fma}\left(\pi, l\_m, \frac{l\_m \cdot \pi}{\left(-F\right) \cdot F}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;l\_m \cdot \pi\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 1e16

      1. Initial program 78.6%

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \color{blue}{\frac{1}{F \cdot F}} \]
        4. un-div-invN/A

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
        8. lower-/.f6485.9

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
        11. lower-*.f6485.9

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}}{F} \]
        4. associate-/l/N/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{\color{blue}{F \cdot F}} \]
        6. div-invN/A

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

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

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \]
        13. sub-negN/A

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell + \left(\mathsf{neg}\left(\frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)\right)\right)} \]
        14. lift-*.f64N/A

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} + \left(\mathsf{neg}\left(\frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)\right)\right) \]
        15. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)\right)\right)} \]
        16. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\color{blue}{\frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}\right)\right) \]
        17. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \frac{1}{F \cdot F}}\right)\right) \]
      6. Applied rewrites78.9%

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

        \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \frac{\color{blue}{\ell \cdot \mathsf{PI}\left(\right)}}{\left(\mathsf{neg}\left(F\right)\right) \cdot F}\right) \]
      8. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{\left(\mathsf{neg}\left(F\right)\right) \cdot F}\right) \]
        3. lower-PI.f6474.4

          \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\pi} \cdot \ell}{\left(-F\right) \cdot F}\right) \]
      9. Applied rewrites74.4%

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

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

      1. Initial program 61.8%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6499.5

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites99.5%

        \[\leadsto \color{blue}{\pi \cdot \ell} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification80.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(\pi, \ell, \frac{\ell \cdot \pi}{\left(-F\right) \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 92.6% accurate, 3.5× 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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(\pi, \frac{-1}{F \cdot F}, \pi\right) \cdot l\_m\\ \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 PI) 1e+16) (* (fma PI (/ -1.0 (* F F)) PI) l_m) (* 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 * ((double) M_PI)) <= 1e+16) {
    		tmp = fma(((double) M_PI), (-1.0 / (F * F)), ((double) M_PI)) * l_m;
    	} else {
    		tmp = l_m * ((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 (Float64(l_m * pi) <= 1e+16)
    		tmp = Float64(fma(pi, Float64(-1.0 / Float64(F * F)), pi) * l_m);
    	else
    		tmp = Float64(l_m * 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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(Pi * N[(-1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision] + Pi), $MachinePrecision] * l$95$m), $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 \cdot \pi \leq 10^{+16}:\\
    \;\;\;\;\mathsf{fma}\left(\pi, \frac{-1}{F \cdot F}, \pi\right) \cdot l\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;l\_m \cdot \pi\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 1e16

      1. Initial program 78.6%

        \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. rem-square-sqrtN/A

          \[\leadsto \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        2. sqrt-unprodN/A

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

          \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        4. add-sqr-sqrtN/A

          \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        5. associate-*r*N/A

          \[\leadsto \sqrt{\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{\mathsf{PI}\left(\right)}}} \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        6. sqrt-prodN/A

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sqrt{\sqrt{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        15. lower-sqrt.f6478.3

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

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

        \[\leadsto \color{blue}{\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right) \cdot \ell} \]
        2. sub-negN/A

          \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) + \left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)\right)\right)} \cdot \ell \]
        3. mul-1-negN/A

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

          \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) + -1 \cdot \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right) \cdot \ell} \]
        5. mul-1-negN/A

          \[\leadsto \left(\mathsf{PI}\left(\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)\right)}\right) \cdot \ell \]
        6. sub-negN/A

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

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

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

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

          \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}}\right) \cdot \ell \]
        11. unpow2N/A

          \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}}\right) \cdot \ell \]
        12. lower-*.f6474.7

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

        \[\leadsto \color{blue}{\left(\pi - \frac{\pi}{F \cdot F}\right) \cdot \ell} \]
      8. Step-by-step derivation
        1. Applied rewrites74.7%

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

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

        1. Initial program 61.8%

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

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

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

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. lower-PI.f6499.5

            \[\leadsto \color{blue}{\pi} \cdot \ell \]
        5. Applied rewrites99.5%

          \[\leadsto \color{blue}{\pi \cdot \ell} \]
      9. Recombined 2 regimes into one program.
      10. Final simplification80.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(\pi, \frac{-1}{F \cdot F}, \pi\right) \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
      11. Add Preprocessing

      Alternative 8: 92.7% accurate, 3.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 \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\left(\pi - \frac{\pi}{F \cdot F}\right) \cdot l\_m\\ \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 PI) 1e+16) (* (- PI (/ PI (* F F))) l_m) (* 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 * ((double) M_PI)) <= 1e+16) {
      		tmp = (((double) M_PI) - (((double) M_PI) / (F * F))) * l_m;
      	} 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 * Math.PI) <= 1e+16) {
      		tmp = (Math.PI - (Math.PI / (F * F))) * l_m;
      	} 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 * math.pi) <= 1e+16:
      		tmp = (math.pi - (math.pi / (F * F))) * l_m
      	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 (Float64(l_m * pi) <= 1e+16)
      		tmp = Float64(Float64(pi - Float64(pi / Float64(F * F))) * l_m);
      	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 * pi) <= 1e+16)
      		tmp = (pi - (pi / (F * F))) * l_m;
      	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[N[(l$95$m * Pi), $MachinePrecision], 1e+16], N[(N[(Pi - N[(Pi / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l$95$m), $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 \cdot \pi \leq 10^{+16}:\\
      \;\;\;\;\left(\pi - \frac{\pi}{F \cdot F}\right) \cdot l\_m\\
      
      \mathbf{else}:\\
      \;\;\;\;l\_m \cdot \pi\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (PI.f64) l) < 1e16

        1. Initial program 78.6%

          \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
        2. Add Preprocessing
        3. Taylor expanded in l around 0

          \[\leadsto \color{blue}{\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

            \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}}\right) \cdot \ell \]
          7. unpow2N/A

            \[\leadsto \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}}\right) \cdot \ell \]
          8. lower-*.f6474.7

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

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

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

        1. Initial program 61.8%

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

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

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

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. lower-PI.f6499.5

            \[\leadsto \color{blue}{\pi} \cdot \ell \]
        5. Applied rewrites99.5%

          \[\leadsto \color{blue}{\pi \cdot \ell} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification80.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 10^{+16}:\\ \;\;\;\;\left(\pi - \frac{\pi}{F \cdot F}\right) \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
      5. Add Preprocessing

      Alternative 9: 73.6% accurate, 22.5× 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 74.4%

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

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

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

          \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
        3. lower-PI.f6472.7

          \[\leadsto \color{blue}{\pi} \cdot \ell \]
      5. Applied rewrites72.7%

        \[\leadsto \color{blue}{\pi \cdot \ell} \]
      6. Final simplification72.7%

        \[\leadsto \ell \cdot \pi \]
      7. Add Preprocessing

      Reproduce

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