VandenBroeck and Keller, Equation (6)

Percentage Accurate: 75.9% → 96.6%
Time: 16.6s
Alternatives: 7
Speedup: 2.6×

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 7 alternatives:

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

Initial Program: 75.9% 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: 96.6% accurate, 0.7× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -4 \cdot 10^{+22} \lor \neg \left(\pi \cdot \ell \leq 10^{-44}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\pi}{F} \cdot \frac{\ell}{F}\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (if (or (<= (* PI l) -4e+22) (not (<= (* PI l) 1e-44)))
   (* PI l)
   (- (* PI l) (* (/ PI F) (/ l F)))))
F = abs(F);
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -4e+22) || !((((double) M_PI) * l) <= 1e-44)) {
		tmp = ((double) M_PI) * l;
	} else {
		tmp = (((double) M_PI) * l) - ((((double) M_PI) / F) * (l / F));
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double tmp;
	if (((Math.PI * l) <= -4e+22) || !((Math.PI * l) <= 1e-44)) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI * l) - ((Math.PI / F) * (l / F));
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	tmp = 0
	if ((math.pi * l) <= -4e+22) or not ((math.pi * l) <= 1e-44):
		tmp = math.pi * l
	else:
		tmp = (math.pi * l) - ((math.pi / F) * (l / F))
	return tmp
F = abs(F)
function code(F, l)
	tmp = 0.0
	if ((Float64(pi * l) <= -4e+22) || !(Float64(pi * l) <= 1e-44))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(pi / F) * Float64(l / F)));
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (((pi * l) <= -4e+22) || ~(((pi * l) <= 1e-44)))
		tmp = pi * l;
	else
		tmp = (pi * l) - ((pi / F) * (l / F));
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -4e+22], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 1e-44]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] * N[(l / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -4 \cdot 10^{+22} \lor \neg \left(\pi \cdot \ell \leq 10^{-44}\right):\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\pi}{F} \cdot \frac{\ell}{F}\\


\end{array}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -4 \cdot 10^{+22} \lor \neg \left(\pi \cdot \ell \leq 10^{-44}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\pi}{F} \cdot \frac{\ell}{F}\\ \end{array} \]

Alternative 2: 90.4% accurate, 1.5× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-238}:\\ \;\;\;\;\ell \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;\left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (if (<= l -3e+14)
   (* PI l)
   (if (<= l 1.65e-238)
     (* l (* PI (- 1.0 (pow F -2.0))))
     (if (<= l 6.8e-213)
       (* (* PI (/ l F)) (/ -1.0 F))
       (if (<= l 1.95e-44) (* (* PI l) (+ 1.0 (/ -1.0 (* F F)))) (* PI l))))))
F = abs(F);
double code(double F, double l) {
	double tmp;
	if (l <= -3e+14) {
		tmp = ((double) M_PI) * l;
	} else if (l <= 1.65e-238) {
		tmp = l * (((double) M_PI) * (1.0 - pow(F, -2.0)));
	} else if (l <= 6.8e-213) {
		tmp = (((double) M_PI) * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = (((double) M_PI) * l) * (1.0 + (-1.0 / (F * F)));
	} else {
		tmp = ((double) M_PI) * l;
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double tmp;
	if (l <= -3e+14) {
		tmp = Math.PI * l;
	} else if (l <= 1.65e-238) {
		tmp = l * (Math.PI * (1.0 - Math.pow(F, -2.0)));
	} else if (l <= 6.8e-213) {
		tmp = (Math.PI * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = (Math.PI * l) * (1.0 + (-1.0 / (F * F)));
	} else {
		tmp = Math.PI * l;
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	tmp = 0
	if l <= -3e+14:
		tmp = math.pi * l
	elif l <= 1.65e-238:
		tmp = l * (math.pi * (1.0 - math.pow(F, -2.0)))
	elif l <= 6.8e-213:
		tmp = (math.pi * (l / F)) * (-1.0 / F)
	elif l <= 1.95e-44:
		tmp = (math.pi * l) * (1.0 + (-1.0 / (F * F)))
	else:
		tmp = math.pi * l
	return tmp
F = abs(F)
function code(F, l)
	tmp = 0.0
	if (l <= -3e+14)
		tmp = Float64(pi * l);
	elseif (l <= 1.65e-238)
		tmp = Float64(l * Float64(pi * Float64(1.0 - (F ^ -2.0))));
	elseif (l <= 6.8e-213)
		tmp = Float64(Float64(pi * Float64(l / F)) * Float64(-1.0 / F));
	elseif (l <= 1.95e-44)
		tmp = Float64(Float64(pi * l) * Float64(1.0 + Float64(-1.0 / Float64(F * F))));
	else
		tmp = Float64(pi * l);
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (l <= -3e+14)
		tmp = pi * l;
	elseif (l <= 1.65e-238)
		tmp = l * (pi * (1.0 - (F ^ -2.0)));
	elseif (l <= 6.8e-213)
		tmp = (pi * (l / F)) * (-1.0 / F);
	elseif (l <= 1.95e-44)
		tmp = (pi * l) * (1.0 + (-1.0 / (F * F)));
	else
		tmp = pi * l;
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := If[LessEqual[l, -3e+14], N[(Pi * l), $MachinePrecision], If[LessEqual[l, 1.65e-238], N[(l * N[(Pi * N[(1.0 - N[Power[F, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.8e-213], N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e-44], N[(N[(Pi * l), $MachinePrecision] * N[(1.0 + N[(-1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * l), $MachinePrecision]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-238}:\\
\;\;\;\;\ell \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\

\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\
\;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\

\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;\left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Initial program 92.6%

    \[\begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-238}:\\ \;\;\;\;\ell \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;\left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \]

Alternative 3: 90.4% accurate, 2.6× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} t_0 := \ell \cdot \left(\pi \cdot \left(1 + \frac{-1}{F \cdot F}\right)\right)\\ \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-237}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (* l (* PI (+ 1.0 (/ -1.0 (* F F)))))))
   (if (<= l -3e+14)
     (* PI l)
     (if (<= l 3.8e-237)
       t_0
       (if (<= l 6.8e-213)
         (* (* PI (/ l F)) (/ -1.0 F))
         (if (<= l 1.95e-44) t_0 (* PI l)))))))
F = abs(F);
double code(double F, double l) {
	double t_0 = l * (((double) M_PI) * (1.0 + (-1.0 / (F * F))));
	double tmp;
	if (l <= -3e+14) {
		tmp = ((double) M_PI) * l;
	} else if (l <= 3.8e-237) {
		tmp = t_0;
	} else if (l <= 6.8e-213) {
		tmp = (((double) M_PI) * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = t_0;
	} else {
		tmp = ((double) M_PI) * l;
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double t_0 = l * (Math.PI * (1.0 + (-1.0 / (F * F))));
	double tmp;
	if (l <= -3e+14) {
		tmp = Math.PI * l;
	} else if (l <= 3.8e-237) {
		tmp = t_0;
	} else if (l <= 6.8e-213) {
		tmp = (Math.PI * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = t_0;
	} else {
		tmp = Math.PI * l;
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	t_0 = l * (math.pi * (1.0 + (-1.0 / (F * F))))
	tmp = 0
	if l <= -3e+14:
		tmp = math.pi * l
	elif l <= 3.8e-237:
		tmp = t_0
	elif l <= 6.8e-213:
		tmp = (math.pi * (l / F)) * (-1.0 / F)
	elif l <= 1.95e-44:
		tmp = t_0
	else:
		tmp = math.pi * l
	return tmp
F = abs(F)
function code(F, l)
	t_0 = Float64(l * Float64(pi * Float64(1.0 + Float64(-1.0 / Float64(F * F)))))
	tmp = 0.0
	if (l <= -3e+14)
		tmp = Float64(pi * l);
	elseif (l <= 3.8e-237)
		tmp = t_0;
	elseif (l <= 6.8e-213)
		tmp = Float64(Float64(pi * Float64(l / F)) * Float64(-1.0 / F));
	elseif (l <= 1.95e-44)
		tmp = t_0;
	else
		tmp = Float64(pi * l);
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	t_0 = l * (pi * (1.0 + (-1.0 / (F * F))));
	tmp = 0.0;
	if (l <= -3e+14)
		tmp = pi * l;
	elseif (l <= 3.8e-237)
		tmp = t_0;
	elseif (l <= 6.8e-213)
		tmp = (pi * (l / F)) * (-1.0 / F);
	elseif (l <= 1.95e-44)
		tmp = t_0;
	else
		tmp = pi * l;
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[(l * N[(Pi * N[(1.0 + N[(-1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3e+14], N[(Pi * l), $MachinePrecision], If[LessEqual[l, 3.8e-237], t$95$0, If[LessEqual[l, 6.8e-213], N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e-44], t$95$0, N[(Pi * l), $MachinePrecision]]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \ell \cdot \left(\pi \cdot \left(1 + \frac{-1}{F \cdot F}\right)\right)\\
\mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-237}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\
\;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\

\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Initial program 92.6%

    \[\begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-237}:\\ \;\;\;\;\ell \cdot \left(\pi \cdot \left(1 + \frac{-1}{F \cdot F}\right)\right)\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;\ell \cdot \left(\pi \cdot \left(1 + \frac{-1}{F \cdot F}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \]

Alternative 4: 90.5% accurate, 2.6× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} t_0 := \left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\ \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-239}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.6 \cdot 10^{-216}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (* (* PI l) (+ 1.0 (/ -1.0 (* F F))))))
   (if (<= l -3e+14)
     (* PI l)
     (if (<= l 2.2e-239)
       t_0
       (if (<= l 1.6e-216)
         (* (* PI (/ l F)) (/ -1.0 F))
         (if (<= l 1.95e-44) t_0 (* PI l)))))))
F = abs(F);
double code(double F, double l) {
	double t_0 = (((double) M_PI) * l) * (1.0 + (-1.0 / (F * F)));
	double tmp;
	if (l <= -3e+14) {
		tmp = ((double) M_PI) * l;
	} else if (l <= 2.2e-239) {
		tmp = t_0;
	} else if (l <= 1.6e-216) {
		tmp = (((double) M_PI) * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = t_0;
	} else {
		tmp = ((double) M_PI) * l;
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double t_0 = (Math.PI * l) * (1.0 + (-1.0 / (F * F)));
	double tmp;
	if (l <= -3e+14) {
		tmp = Math.PI * l;
	} else if (l <= 2.2e-239) {
		tmp = t_0;
	} else if (l <= 1.6e-216) {
		tmp = (Math.PI * (l / F)) * (-1.0 / F);
	} else if (l <= 1.95e-44) {
		tmp = t_0;
	} else {
		tmp = Math.PI * l;
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	t_0 = (math.pi * l) * (1.0 + (-1.0 / (F * F)))
	tmp = 0
	if l <= -3e+14:
		tmp = math.pi * l
	elif l <= 2.2e-239:
		tmp = t_0
	elif l <= 1.6e-216:
		tmp = (math.pi * (l / F)) * (-1.0 / F)
	elif l <= 1.95e-44:
		tmp = t_0
	else:
		tmp = math.pi * l
	return tmp
F = abs(F)
function code(F, l)
	t_0 = Float64(Float64(pi * l) * Float64(1.0 + Float64(-1.0 / Float64(F * F))))
	tmp = 0.0
	if (l <= -3e+14)
		tmp = Float64(pi * l);
	elseif (l <= 2.2e-239)
		tmp = t_0;
	elseif (l <= 1.6e-216)
		tmp = Float64(Float64(pi * Float64(l / F)) * Float64(-1.0 / F));
	elseif (l <= 1.95e-44)
		tmp = t_0;
	else
		tmp = Float64(pi * l);
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	t_0 = (pi * l) * (1.0 + (-1.0 / (F * F)));
	tmp = 0.0;
	if (l <= -3e+14)
		tmp = pi * l;
	elseif (l <= 2.2e-239)
		tmp = t_0;
	elseif (l <= 1.6e-216)
		tmp = (pi * (l / F)) * (-1.0 / F);
	elseif (l <= 1.95e-44)
		tmp = t_0;
	else
		tmp = pi * l;
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[(N[(Pi * l), $MachinePrecision] * N[(1.0 + N[(-1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3e+14], N[(Pi * l), $MachinePrecision], If[LessEqual[l, 2.2e-239], t$95$0, If[LessEqual[l, 1.6e-216], N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e-44], t$95$0, N[(Pi * l), $MachinePrecision]]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\
\mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-239}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 1.6 \cdot 10^{-216}:\\
\;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\

\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Initial program 92.6%

    \[\begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+14}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-239}:\\ \;\;\;\;\left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\ \mathbf{elif}\;\ell \leq 1.6 \cdot 10^{-216}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-44}:\\ \;\;\;\;\left(\pi \cdot \ell\right) \cdot \left(1 + \frac{-1}{F \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell\\ \end{array} \]

Alternative 5: 74.4% accurate, 2.7× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} \mathbf{if}\;F \leq 2.05 \cdot 10^{-279} \lor \neg \left(F \leq 7.1 \cdot 10^{-236} \lor \neg \left(F \leq 6.6 \cdot 10^{-199}\right) \land F \leq 3.6 \cdot 10^{-106}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (if (or (<= F 2.05e-279)
         (not
          (or (<= F 7.1e-236) (and (not (<= F 6.6e-199)) (<= F 3.6e-106)))))
   (* PI l)
   (* (/ PI F) (/ (- l) F))))
F = abs(F);
double code(double F, double l) {
	double tmp;
	if ((F <= 2.05e-279) || !((F <= 7.1e-236) || (!(F <= 6.6e-199) && (F <= 3.6e-106)))) {
		tmp = ((double) M_PI) * l;
	} else {
		tmp = (((double) M_PI) / F) * (-l / F);
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double tmp;
	if ((F <= 2.05e-279) || !((F <= 7.1e-236) || (!(F <= 6.6e-199) && (F <= 3.6e-106)))) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI / F) * (-l / F);
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	tmp = 0
	if (F <= 2.05e-279) or not ((F <= 7.1e-236) or (not (F <= 6.6e-199) and (F <= 3.6e-106))):
		tmp = math.pi * l
	else:
		tmp = (math.pi / F) * (-l / F)
	return tmp
F = abs(F)
function code(F, l)
	tmp = 0.0
	if ((F <= 2.05e-279) || !((F <= 7.1e-236) || (!(F <= 6.6e-199) && (F <= 3.6e-106))))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi / F) * Float64(Float64(-l) / F));
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((F <= 2.05e-279) || ~(((F <= 7.1e-236) || (~((F <= 6.6e-199)) && (F <= 3.6e-106)))))
		tmp = pi * l;
	else
		tmp = (pi / F) * (-l / F);
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := If[Or[LessEqual[F, 2.05e-279], N[Not[Or[LessEqual[F, 7.1e-236], And[N[Not[LessEqual[F, 6.6e-199]], $MachinePrecision], LessEqual[F, 3.6e-106]]]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi / F), $MachinePrecision] * N[((-l) / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 2.05 \cdot 10^{-279} \lor \neg \left(F \leq 7.1 \cdot 10^{-236} \lor \neg \left(F \leq 6.6 \cdot 10^{-199}\right) \land F \leq 3.6 \cdot 10^{-106}\right):\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{else}:\\
\;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\


\end{array}
\end{array}
Derivation
  1. Initial program 77.3%

    \[\begin{array}{l} \mathbf{if}\;F \leq 2.05 \cdot 10^{-279} \lor \neg \left(F \leq 7.1 \cdot 10^{-236} \lor \neg \left(F \leq 6.6 \cdot 10^{-199}\right) \land F \leq 3.6 \cdot 10^{-106}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \]

Alternative 6: 74.4% accurate, 2.7× speedup?

\[\begin{array}{l} F = |F|\\ \\ \begin{array}{l} \mathbf{if}\;F \leq 1.3 \cdot 10^{-280}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;F \leq 8.5 \cdot 10^{-236}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;F \leq 3.95 \cdot 10^{-199} \lor \neg \left(F \leq 5.8 \cdot 10^{-106}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (if (<= F 1.3e-280)
   (* PI l)
   (if (<= F 8.5e-236)
     (* (* PI (/ l F)) (/ -1.0 F))
     (if (or (<= F 3.95e-199) (not (<= F 5.8e-106)))
       (* PI l)
       (* (/ PI F) (/ (- l) F))))))
F = abs(F);
double code(double F, double l) {
	double tmp;
	if (F <= 1.3e-280) {
		tmp = ((double) M_PI) * l;
	} else if (F <= 8.5e-236) {
		tmp = (((double) M_PI) * (l / F)) * (-1.0 / F);
	} else if ((F <= 3.95e-199) || !(F <= 5.8e-106)) {
		tmp = ((double) M_PI) * l;
	} else {
		tmp = (((double) M_PI) / F) * (-l / F);
	}
	return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
	double tmp;
	if (F <= 1.3e-280) {
		tmp = Math.PI * l;
	} else if (F <= 8.5e-236) {
		tmp = (Math.PI * (l / F)) * (-1.0 / F);
	} else if ((F <= 3.95e-199) || !(F <= 5.8e-106)) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI / F) * (-l / F);
	}
	return tmp;
}
F = abs(F)
def code(F, l):
	tmp = 0
	if F <= 1.3e-280:
		tmp = math.pi * l
	elif F <= 8.5e-236:
		tmp = (math.pi * (l / F)) * (-1.0 / F)
	elif (F <= 3.95e-199) or not (F <= 5.8e-106):
		tmp = math.pi * l
	else:
		tmp = (math.pi / F) * (-l / F)
	return tmp
F = abs(F)
function code(F, l)
	tmp = 0.0
	if (F <= 1.3e-280)
		tmp = Float64(pi * l);
	elseif (F <= 8.5e-236)
		tmp = Float64(Float64(pi * Float64(l / F)) * Float64(-1.0 / F));
	elseif ((F <= 3.95e-199) || !(F <= 5.8e-106))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi / F) * Float64(Float64(-l) / F));
	end
	return tmp
end
F = abs(F)
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (F <= 1.3e-280)
		tmp = pi * l;
	elseif (F <= 8.5e-236)
		tmp = (pi * (l / F)) * (-1.0 / F);
	elseif ((F <= 3.95e-199) || ~((F <= 5.8e-106)))
		tmp = pi * l;
	else
		tmp = (pi / F) * (-l / F);
	end
	tmp_2 = tmp;
end
NOTE: F should be positive before calling this function
code[F_, l_] := If[LessEqual[F, 1.3e-280], N[(Pi * l), $MachinePrecision], If[LessEqual[F, 8.5e-236], N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[F, 3.95e-199], N[Not[LessEqual[F, 5.8e-106]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi / F), $MachinePrecision] * N[((-l) / F), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 1.3 \cdot 10^{-280}:\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{elif}\;F \leq 8.5 \cdot 10^{-236}:\\
\;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\

\mathbf{elif}\;F \leq 3.95 \cdot 10^{-199} \lor \neg \left(F \leq 5.8 \cdot 10^{-106}\right):\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{else}:\\
\;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\


\end{array}
\end{array}
Derivation
  1. Initial program 77.3%

    \[\begin{array}{l} \mathbf{if}\;F \leq 1.3 \cdot 10^{-280}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;F \leq 8.5 \cdot 10^{-236}:\\ \;\;\;\;\left(\pi \cdot \frac{\ell}{F}\right) \cdot \frac{-1}{F}\\ \mathbf{elif}\;F \leq 3.95 \cdot 10^{-199} \lor \neg \left(F \leq 5.8 \cdot 10^{-106}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \]

Alternative 7: 74.4% accurate, 3.0× speedup?

\[\begin{array}{l} F = |F|\\ \\ \pi \cdot \ell \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l) :precision binary64 (* PI l))
F = abs(F);
double code(double F, double l) {
	return ((double) M_PI) * l;
}
F = Math.abs(F);
public static double code(double F, double l) {
	return Math.PI * l;
}
F = abs(F)
def code(F, l):
	return math.pi * l
F = abs(F)
function code(F, l)
	return Float64(pi * l)
end
F = abs(F)
function tmp = code(F, l)
	tmp = pi * l;
end
NOTE: F should be positive before calling this function
code[F_, l_] := N[(Pi * l), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell
\end{array}
Derivation
  1. Initial program 74.7%

    \[\pi \cdot \ell \]

Reproduce

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