VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.2% → 98.8%
Time: 15.2s
Alternatives: 10
Speedup: 1.5×

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.2% 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: 98.8% accurate, 0.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}\;\pi \cdot l_m \leq 1000000:\\ \;\;\;\;\mathsf{fma}\left(\pi, l_m, \frac{\frac{\tan \left(\pi \cdot l_m\right)}{-F}}{F}\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l_m\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 1000000.0)
    (fma PI l_m (/ (/ (tan (* PI l_m)) (- F)) F))
    (* PI l_m))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 1000000.0) {
		tmp = fma(((double) M_PI), l_m, ((tan((((double) M_PI) * l_m)) / -F) / F));
	} else {
		tmp = ((double) M_PI) * l_m;
	}
	return l_s * tmp;
}
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 1000000.0)
		tmp = fma(pi, l_m, Float64(Float64(tan(Float64(pi * l_m)) / Float64(-F)) / F));
	else
		tmp = Float64(pi * l_m);
	end
	return Float64(l_s * tmp)
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 1000000.0], N[(Pi * l$95$m + N[(N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / (-F)), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 98.8% accurate, 0.8× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l_m \leq 1000000:\\ \;\;\;\;\pi \cdot l_m - \frac{\frac{\tan \left(\pi \cdot l_m\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l_m\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 1000000.0)
    (- (* PI l_m) (/ (/ (tan (* PI l_m)) F) F))
    (* PI l_m))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 1000000.0) {
		tmp = (((double) M_PI) * l_m) - ((tan((((double) M_PI) * l_m)) / F) / F);
	} else {
		tmp = ((double) M_PI) * l_m;
	}
	return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if ((Math.PI * l_m) <= 1000000.0) {
		tmp = (Math.PI * l_m) - ((Math.tan((Math.PI * l_m)) / F) / F);
	} else {
		tmp = Math.PI * l_m;
	}
	return l_s * tmp;
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if (math.pi * l_m) <= 1000000.0:
		tmp = (math.pi * l_m) - ((math.tan((math.pi * l_m)) / F) / F)
	else:
		tmp = math.pi * l_m
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 1000000.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(tan(Float64(pi * l_m)) / F) / F));
	else
		tmp = Float64(pi * l_m);
	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 ((pi * l_m) <= 1000000.0)
		tmp = (pi * l_m) - ((tan((pi * l_m)) / F) / F);
	else
		tmp = pi * l_m;
	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[(Pi * l$95$m), $MachinePrecision], 1000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 98.4% accurate, 0.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ l_s = \mathsf{copysign}\left(1, \ell\right) \\ l_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l_m \leq 400000:\\ \;\;\;\;\pi \cdot l_m - \frac{\frac{l_m}{\frac{F}{\pi}}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l_m\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 400000.0)
    (- (* PI l_m) (/ (/ l_m (/ F PI)) F))
    (* PI l_m))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 400000.0) {
		tmp = (((double) M_PI) * l_m) - ((l_m / (F / ((double) M_PI))) / F);
	} else {
		tmp = ((double) M_PI) * l_m;
	}
	return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if ((Math.PI * l_m) <= 400000.0) {
		tmp = (Math.PI * l_m) - ((l_m / (F / Math.PI)) / F);
	} else {
		tmp = Math.PI * l_m;
	}
	return l_s * tmp;
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if (math.pi * l_m) <= 400000.0:
		tmp = (math.pi * l_m) - ((l_m / (F / math.pi)) / F)
	else:
		tmp = math.pi * l_m
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 400000.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(l_m / Float64(F / pi)) / F));
	else
		tmp = Float64(pi * l_m);
	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 ((pi * l_m) <= 400000.0)
		tmp = (pi * l_m) - ((l_m / (F / pi)) / F);
	else
		tmp = pi * l_m;
	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[(Pi * l$95$m), $MachinePrecision], 400000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / N[(F / Pi), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

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

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 71.4% 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 \leq 2.65 \cdot 10^{-188} \lor \neg \left(l_m \leq 9 \cdot 10^{-76}\right):\\ \;\;\;\;\pi \cdot l_m\\ \mathbf{else}:\\ \;\;\;\;l_m \cdot \frac{-\pi}{{F}^{2}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (or (<= l_m 2.65e-188) (not (<= l_m 9e-76)))
    (* PI l_m)
    (* l_m (/ (- PI) (pow F 2.0))))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((l_m <= 2.65e-188) || !(l_m <= 9e-76)) {
		tmp = ((double) M_PI) * l_m;
	} else {
		tmp = l_m * (-((double) M_PI) / pow(F, 2.0));
	}
	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 <= 2.65e-188) || !(l_m <= 9e-76)) {
		tmp = Math.PI * l_m;
	} else {
		tmp = l_m * (-Math.PI / Math.pow(F, 2.0));
	}
	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 <= 2.65e-188) or not (l_m <= 9e-76):
		tmp = math.pi * l_m
	else:
		tmp = l_m * (-math.pi / math.pow(F, 2.0))
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if ((l_m <= 2.65e-188) || !(l_m <= 9e-76))
		tmp = Float64(pi * l_m);
	else
		tmp = Float64(l_m * Float64(Float64(-pi) / (F ^ 2.0)));
	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 <= 2.65e-188) || ~((l_m <= 9e-76)))
		tmp = pi * l_m;
	else
		tmp = l_m * (-pi / (F ^ 2.0));
	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[Or[LessEqual[l$95$m, 2.65e-188], N[Not[LessEqual[l$95$m, 9e-76]], $MachinePrecision]], N[(Pi * l$95$m), $MachinePrecision], N[(l$95$m * N[((-Pi) / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 2.65 \cdot 10^{-188} \lor \neg \left(l_m \leq 9 \cdot 10^{-76}\right):\\
\;\;\;\;\pi \cdot l_m\\

\mathbf{else}:\\
\;\;\;\;l_m \cdot \frac{-\pi}{{F}^{2}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 71.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 \leq 1.3 \cdot 10^{-188} \lor \neg \left(l_m \leq 4.8 \cdot 10^{-74}\right):\\ \;\;\;\;\pi \cdot l_m\\ \mathbf{else}:\\ \;\;\;\;\frac{l_m}{{F}^{2}} \cdot \left(-\pi\right)\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (or (<= l_m 1.3e-188) (not (<= l_m 4.8e-74)))
    (* PI l_m)
    (* (/ l_m (pow F 2.0)) (- PI)))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((l_m <= 1.3e-188) || !(l_m <= 4.8e-74)) {
		tmp = ((double) M_PI) * l_m;
	} else {
		tmp = (l_m / pow(F, 2.0)) * -((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 <= 1.3e-188) || !(l_m <= 4.8e-74)) {
		tmp = Math.PI * l_m;
	} else {
		tmp = (l_m / Math.pow(F, 2.0)) * -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 <= 1.3e-188) or not (l_m <= 4.8e-74):
		tmp = math.pi * l_m
	else:
		tmp = (l_m / math.pow(F, 2.0)) * -math.pi
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if ((l_m <= 1.3e-188) || !(l_m <= 4.8e-74))
		tmp = Float64(pi * l_m);
	else
		tmp = Float64(Float64(l_m / (F ^ 2.0)) * Float64(-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 <= 1.3e-188) || ~((l_m <= 4.8e-74)))
		tmp = pi * l_m;
	else
		tmp = (l_m / (F ^ 2.0)) * -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[Or[LessEqual[l$95$m, 1.3e-188], N[Not[LessEqual[l$95$m, 4.8e-74]], $MachinePrecision]], N[(Pi * l$95$m), $MachinePrecision], N[(N[(l$95$m / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision] * (-Pi)), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 1.3 \cdot 10^{-188} \lor \neg \left(l_m \leq 4.8 \cdot 10^{-74}\right):\\
\;\;\;\;\pi \cdot l_m\\

\mathbf{else}:\\
\;\;\;\;\frac{l_m}{{F}^{2}} \cdot \left(-\pi\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 71.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 \leq 2 \cdot 10^{-188} \lor \neg \left(l_m \leq 7.2 \cdot 10^{-74}\right):\\ \;\;\;\;\pi \cdot l_m\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi \cdot \left(-l_m\right)}{{F}^{2}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (or (<= l_m 2e-188) (not (<= l_m 7.2e-74)))
    (* PI l_m)
    (/ (* PI (- l_m)) (pow F 2.0)))))
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 <= 2e-188) || !(l_m <= 7.2e-74)) {
		tmp = ((double) M_PI) * l_m;
	} else {
		tmp = (((double) M_PI) * -l_m) / pow(F, 2.0);
	}
	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 <= 2e-188) || !(l_m <= 7.2e-74)) {
		tmp = Math.PI * l_m;
	} else {
		tmp = (Math.PI * -l_m) / Math.pow(F, 2.0);
	}
	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 <= 2e-188) or not (l_m <= 7.2e-74):
		tmp = math.pi * l_m
	else:
		tmp = (math.pi * -l_m) / math.pow(F, 2.0)
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if ((l_m <= 2e-188) || !(l_m <= 7.2e-74))
		tmp = Float64(pi * l_m);
	else
		tmp = Float64(Float64(pi * Float64(-l_m)) / (F ^ 2.0));
	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 <= 2e-188) || ~((l_m <= 7.2e-74)))
		tmp = pi * l_m;
	else
		tmp = (pi * -l_m) / (F ^ 2.0);
	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[Or[LessEqual[l$95$m, 2e-188], N[Not[LessEqual[l$95$m, 7.2e-74]], $MachinePrecision]], N[(Pi * l$95$m), $MachinePrecision], N[(N[(Pi * (-l$95$m)), $MachinePrecision] / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 2 \cdot 10^{-188} \lor \neg \left(l_m \leq 7.2 \cdot 10^{-74}\right):\\
\;\;\;\;\pi \cdot l_m\\

\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot \left(-l_m\right)}{{F}^{2}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 92.1% 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 \leq 90000:\\ \;\;\;\;l_m \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l_m\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
 :precision binary64
 (* l_s (if (<= l_m 90000.0) (* l_m (* PI (- 1.0 (pow F -2.0)))) (* PI l_m))))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if (l_m <= 90000.0) {
		tmp = l_m * (((double) M_PI) * (1.0 - pow(F, -2.0)));
	} else {
		tmp = ((double) M_PI) * l_m;
	}
	return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if (l_m <= 90000.0) {
		tmp = l_m * (Math.PI * (1.0 - Math.pow(F, -2.0)));
	} else {
		tmp = Math.PI * l_m;
	}
	return l_s * tmp;
}
l_m = math.fabs(l)
l_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if l_m <= 90000.0:
		tmp = l_m * (math.pi * (1.0 - math.pow(F, -2.0)))
	else:
		tmp = math.pi * l_m
	return l_s * tmp
l_m = abs(l)
l_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (l_m <= 90000.0)
		tmp = Float64(l_m * Float64(pi * Float64(1.0 - (F ^ -2.0))));
	else
		tmp = Float64(pi * l_m);
	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 <= 90000.0)
		tmp = l_m * (pi * (1.0 - (F ^ -2.0)));
	else
		tmp = pi * l_m;
	end
	tmp_2 = l_s * tmp;
end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[l$95$m, 90000.0], N[(l$95$m * N[(Pi * N[(1.0 - N[Power[F, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)

\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 90000:\\
\;\;\;\;l_m \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 73.0% accurate, 3.0× speedup?

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

\\
l_s \cdot \left(\pi \cdot l_m\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

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