VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.3% → 99.2%
Time: 17.2s
Alternatives: 10
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 10 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.3% 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.2% 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 2 \cdot 10^{+14}:\\ \;\;\;\;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) 2e+14)
    (- (* 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)) <= 2e+14) {
		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) <= 2e+14) {
		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) <= 2e+14:
		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) <= 2e+14)
		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) <= 2e+14)
		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], 2e+14], 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 2 \cdot 10^{+14}:\\
\;\;\;\;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) < 2e14

    1. Initial program 79.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-/.f6484.7

        \[\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-*.f6484.7

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

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

    if 2e14 < (*.f64 (PI.f64) l)

    1. Initial program 56.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.f6499.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 2 \cdot 10^{+14}:\\ \;\;\;\;\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: 82.3% accurate, 0.4× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \pi - \tan \left(l\_m \cdot \pi\right) \cdot \frac{1}{F \cdot F}\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+261}:\\ \;\;\;\;l\_m \cdot \pi\\ \mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-233}:\\ \;\;\;\;\frac{\pi}{\left(-F\right) \cdot F} \cdot l\_m\\ \mathbf{else}:\\ \;\;\;\;l\_m \cdot \pi\\ \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 (- (* l_m PI) (* (tan (* l_m PI)) (/ 1.0 (* F F))))))
   (*
    l_s
    (if (<= t_0 -1e+261)
      (* l_m PI)
      (if (<= t_0 -2e-233) (* (/ 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 t_0 = (l_m * ((double) M_PI)) - (tan((l_m * ((double) M_PI))) * (1.0 / (F * F)));
	double tmp;
	if (t_0 <= -1e+261) {
		tmp = l_m * ((double) M_PI);
	} else if (t_0 <= -2e-233) {
		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 t_0 = (l_m * Math.PI) - (Math.tan((l_m * Math.PI)) * (1.0 / (F * F)));
	double tmp;
	if (t_0 <= -1e+261) {
		tmp = l_m * Math.PI;
	} else if (t_0 <= -2e-233) {
		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):
	t_0 = (l_m * math.pi) - (math.tan((l_m * math.pi)) * (1.0 / (F * F)))
	tmp = 0
	if t_0 <= -1e+261:
		tmp = l_m * math.pi
	elif t_0 <= -2e-233:
		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)
	t_0 = Float64(Float64(l_m * pi) - Float64(tan(Float64(l_m * pi)) * Float64(1.0 / Float64(F * F))))
	tmp = 0.0
	if (t_0 <= -1e+261)
		tmp = Float64(l_m * pi);
	elseif (t_0 <= -2e-233)
		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)
	t_0 = (l_m * pi) - (tan((l_m * pi)) * (1.0 / (F * F)));
	tmp = 0.0;
	if (t_0 <= -1e+261)
		tmp = l_m * pi;
	elseif (t_0 <= -2e-233)
		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_] := Block[{t$95$0 = 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]}, N[(l$95$s * If[LessEqual[t$95$0, -1e+261], N[(l$95$m * Pi), $MachinePrecision], If[LessEqual[t$95$0, -2e-233], 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)

\\
\begin{array}{l}
t_0 := l\_m \cdot \pi - \tan \left(l\_m \cdot \pi\right) \cdot \frac{1}{F \cdot F}\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+261}:\\
\;\;\;\;l\_m \cdot \pi\\

\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-233}:\\
\;\;\;\;\frac{\pi}{\left(-F\right) \cdot F} \cdot l\_m\\

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


\end{array}
\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)))) < -9.9999999999999993e260 or -1.99999999999999992e-233 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

    1. Initial program 67.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.f6471.8

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

      \[\leadsto \color{blue}{\pi \cdot \ell} \]

    if -9.9999999999999993e260 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -1.99999999999999992e-233

    1. Initial program 91.2%

      \[\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-/.f6491.2

        \[\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-*.f6491.2

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
    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-*.f6483.6

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

      \[\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 rewrites20.6%

        \[\leadsto \frac{-\pi}{F \cdot F} \cdot \ell \]
    10. Recombined 2 regimes into one program.
    11. Final simplification55.8%

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

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

      1. Initial program 79.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-tan.f64N/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} \]
        4. tan-quotN/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \frac{1}{F \cdot F} \]
        5. clear-numN/A

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{1}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \color{blue}{\frac{\frac{1}{F}}{F}} \]
        9. frac-timesN/A

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\color{blue}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot F}} \]
      4. Applied rewrites84.7%

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

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

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

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{2} \cdot \mathsf{PI}\left(\right) - \frac{-1}{6} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell}, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
        7. distribute-rgt-out--N/A

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\left(\frac{-1}{2} - \frac{-1}{6}\right) \cdot \mathsf{PI}\left(\right)\right)} \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
        10. metadata-evalN/A

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(\frac{-1}{3} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell, \ell, \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{\ell} \cdot F} \]
        13. lower-PI.f6489.8

          \[\leadsto \pi \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot \pi\right) \cdot \ell, \ell, \frac{1}{\color{blue}{\pi}}\right)}{\ell} \cdot F} \]
      7. Applied rewrites89.8%

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

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

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\color{blue}{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \mathsf{PI}\left(\right) - \frac{-1}{6} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}}{\ell} \cdot F} \]
        6. distribute-rgt-out--N/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{2} - \frac{-1}{6}\right)\right)} \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
        7. metadata-evalN/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{3} \cdot \mathsf{PI}\left(\right)\right)} \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
        9. associate-*r*N/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\frac{-1}{3} \cdot \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
        11. associate-*r*N/A

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

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

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

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(\frac{-1}{3} \cdot \ell\right) \cdot \mathsf{PI}\left(\right), \ell, \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{\ell} \cdot F} \]
        16. lower-PI.f6489.8

          \[\leadsto \pi \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot \ell\right) \cdot \pi, \ell, \frac{1}{\color{blue}{\pi}}\right)}{\ell} \cdot F} \]
      10. Applied rewrites89.8%

        \[\leadsto \pi \cdot \ell - \frac{\frac{1}{F}}{\color{blue}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot \ell\right) \cdot \pi, \ell, \frac{1}{\pi}\right)}{\ell}} \cdot F} \]
      11. Step-by-step derivation
        1. Applied rewrites89.8%

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

        if 2e14 < (*.f64 (PI.f64) l)

        1. Initial program 56.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.f6499.7

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

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

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

      Alternative 4: 98.5% accurate, 1.6× 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 2 \cdot 10^{+14}:\\ \;\;\;\;\mathsf{fma}\left(\pi, l\_m, \frac{\frac{-1}{F}}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot l\_m\right) \cdot \pi, l\_m, \frac{1}{\pi}\right)}{l\_m} \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) 2e+14)
          (fma
           PI
           l_m
           (/
            (/ -1.0 F)
            (* (/ (fma (* (* -0.3333333333333333 l_m) PI) l_m (/ 1.0 PI)) 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)) <= 2e+14) {
      		tmp = fma(((double) M_PI), l_m, ((-1.0 / F) / ((fma(((-0.3333333333333333 * l_m) * ((double) M_PI)), l_m, (1.0 / ((double) M_PI))) / l_m) * 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) <= 2e+14)
      		tmp = fma(pi, l_m, Float64(Float64(-1.0 / F) / Float64(Float64(fma(Float64(Float64(-0.3333333333333333 * l_m) * pi), l_m, Float64(1.0 / pi)) / l_m) * 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], 2e+14], N[(Pi * l$95$m + N[(N[(-1.0 / F), $MachinePrecision] / N[(N[(N[(N[(N[(-0.3333333333333333 * l$95$m), $MachinePrecision] * Pi), $MachinePrecision] * l$95$m + N[(1.0 / Pi), $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision] * 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 2 \cdot 10^{+14}:\\
      \;\;\;\;\mathsf{fma}\left(\pi, l\_m, \frac{\frac{-1}{F}}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot l\_m\right) \cdot \pi, l\_m, \frac{1}{\pi}\right)}{l\_m} \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) < 2e14

        1. Initial program 79.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-tan.f64N/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} \]
          4. tan-quotN/A

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \frac{1}{F \cdot F} \]
          5. clear-numN/A

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

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{1}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \color{blue}{\frac{\frac{1}{F}}{F}} \]
          9. frac-timesN/A

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

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

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\color{blue}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot F}} \]
        4. Applied rewrites84.7%

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

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

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

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

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

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{2} \cdot \mathsf{PI}\left(\right) - \frac{-1}{6} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell}, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
          7. distribute-rgt-out--N/A

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\color{blue}{\left(\left(\frac{-1}{2} - \frac{-1}{6}\right) \cdot \mathsf{PI}\left(\right)\right)} \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F} \]
          10. metadata-evalN/A

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(\frac{-1}{3} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell, \ell, \color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{\ell} \cdot F} \]
          13. lower-PI.f6489.8

            \[\leadsto \pi \cdot \ell - \frac{\frac{1}{F}}{\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot \pi\right) \cdot \ell, \ell, \frac{1}{\color{blue}{\pi}}\right)}{\ell} \cdot F} \]
        7. Applied rewrites89.8%

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\frac{\color{blue}{\frac{1}{F}}}{\frac{\mathsf{fma}\left(\left(\frac{-1}{3} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F}\right)\right) \]
          7. associate-/l/N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\color{blue}{\frac{1}{\left(\frac{\mathsf{fma}\left(\left(\frac{-1}{3} \cdot \mathsf{PI}\left(\right)\right) \cdot \ell, \ell, \frac{1}{\mathsf{PI}\left(\right)}\right)}{\ell} \cdot F\right) \cdot F}}\right)\right) \]
        9. Applied rewrites83.0%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{-1}{\frac{\mathsf{fma}\left(\left(\pi \cdot -0.3333333333333333\right) \cdot \ell, \ell, \frac{1}{\pi}\right)}{\ell} \cdot \left(F \cdot F\right)}\right)} \]
        10. Applied rewrites89.8%

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

        if 2e14 < (*.f64 (PI.f64) l)

        1. Initial program 56.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.f6499.7

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

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

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

      Alternative 5: 98.2% 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 100000:\\ \;\;\;\;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) 100000.0)
          (- (* 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)) <= 100000.0) {
      		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) <= 100000.0) {
      		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) <= 100000.0:
      		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) <= 100000.0)
      		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) <= 100000.0)
      		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], 100000.0], 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 100000:\\
      \;\;\;\;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) < 1e5

        1. Initial program 79.5%

          \[\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 \mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\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 - \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{\mathsf{PI}\left(\right) \cdot \ell}{F \cdot F}} \]
          5. lift-*.f64N/A

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

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

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

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

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

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

        1. Initial program 57.2%

          \[\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.f6497.9

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

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

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

      Alternative 6: 98.0% 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 100000:\\ \;\;\;\;\frac{\left(\left(F - \frac{1}{F}\right) \cdot \pi\right) \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) 100000.0)
          (/ (* (* (- F (/ 1.0 F)) PI) 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)) <= 100000.0) {
      		tmp = (((F - (1.0 / F)) * ((double) M_PI)) * 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) <= 100000.0) {
      		tmp = (((F - (1.0 / F)) * Math.PI) * 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) <= 100000.0:
      		tmp = (((F - (1.0 / F)) * math.pi) * 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) <= 100000.0)
      		tmp = Float64(Float64(Float64(Float64(F - Float64(1.0 / F)) * pi) * 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) <= 100000.0)
      		tmp = (((F - (1.0 / F)) * pi) * 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], 100000.0], N[(N[(N[(N[(F - N[(1.0 / F), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] * l$95$m), $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 \cdot \pi \leq 100000:\\
      \;\;\;\;\frac{\left(\left(F - \frac{1}{F}\right) \cdot \pi\right) \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) < 1e5

        1. Initial program 79.5%

          \[\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-/.f6484.7

            \[\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-*.f6484.7

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

          \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \pi\right)}{F}}{F}} \]
        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.4

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

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

            \[\leadsto \frac{\pi \cdot F - \frac{\pi}{F}}{1 \cdot F} \cdot \ell \]
          2. Step-by-step derivation
            1. Applied rewrites72.7%

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

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

            1. Initial program 57.2%

              \[\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.f6497.9

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

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

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

          Alternative 7: 92.5% 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 100000:\\ \;\;\;\;\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) 100000.0)
              (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)) <= 100000.0) {
          		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) <= 100000.0)
          		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], 100000.0], 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 100000:\\
          \;\;\;\;\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) < 1e5

            1. Initial program 79.5%

              \[\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 \mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{neg}\left(\color{blue}{\frac{\mathsf{PI}\left(\right) \cdot \ell}{F \cdot F}}\right)\right) \]
              9. distribute-neg-frac2N/A

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

                \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \frac{\mathsf{PI}\left(\right) \cdot \ell}{\mathsf{neg}\left(\color{blue}{F \cdot F}\right)}\right) \]
              11. distribute-lft-neg-outN/A

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

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

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

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

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

            1. Initial program 57.2%

              \[\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.f6497.9

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \pi \leq 100000:\\ \;\;\;\;\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 8: 92.3% 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 100000:\\ \;\;\;\;l\_m \cdot \pi - \frac{\pi}{F \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) 100000.0)
              (- (* l_m 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)) <= 100000.0) {
          		tmp = (l_m * ((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) <= 100000.0) {
          		tmp = (l_m * 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) <= 100000.0:
          		tmp = (l_m * 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) <= 100000.0)
          		tmp = Float64(Float64(l_m * pi) - Float64(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) <= 100000.0)
          		tmp = (l_m * 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], 100000.0], N[(N[(l$95$m * Pi), $MachinePrecision] - N[(N[(Pi / N[(F * F), $MachinePrecision]), $MachinePrecision] * l$95$m), $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 100000:\\
          \;\;\;\;l\_m \cdot \pi - \frac{\pi}{F \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 (PI.f64) l) < 1e5

            1. Initial program 79.5%

              \[\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 \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\ell \cdot \mathsf{PI}\left(\right)}{{F}^{2}}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

            1. Initial program 57.2%

              \[\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.f6497.9

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

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

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

          Alternative 9: 92.3% 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 100000:\\ \;\;\;\;\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) 100000.0) (* (- 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)) <= 100000.0) {
          		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) <= 100000.0) {
          		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) <= 100000.0:
          		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) <= 100000.0)
          		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) <= 100000.0)
          		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], 100000.0], 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 100000:\\
          \;\;\;\;\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) < 1e5

            1. Initial program 79.5%

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

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

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

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

            1. Initial program 57.2%

              \[\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.f6497.9

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

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

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

          Alternative 10: 73.1% 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.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.f6474.0

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

            \[\leadsto \color{blue}{\pi \cdot \ell} \]
          6. Final simplification74.0%

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

          Reproduce

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