VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.3% → 80.6%
Time: 24.3s
Alternatives: 8
Speedup: 1.0×

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 8 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: 80.6% accurate, 1.0× speedup?

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

\mathbf{elif}\;F \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\pi \cdot \ell - \frac{F \cdot F}{t_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < 2.25e-197

    1. Initial program 71.7%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
    3. Step-by-step derivation
      1. unpow267.0%

        \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \pi}{\color{blue}{F \cdot F}} \]
      2. times-frac73.7%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
    5. Step-by-step derivation
      1. associate-*r/73.7%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F} \cdot \pi}{F}} \]
      2. clear-num73.7%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{\ell}{F} \cdot \pi}}} \]
      3. *-commutative73.7%

        \[\leadsto \pi \cdot \ell - \frac{1}{\frac{F}{\color{blue}{\pi \cdot \frac{\ell}{F}}}} \]
    6. Applied egg-rr73.7%

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

    if 2.25e-197 < F < 4.99999999999999968e-149

    1. Initial program 18.1%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. inv-pow18.1%

        \[\leadsto \pi \cdot \ell - \color{blue}{{\left(F \cdot F\right)}^{-1}} \cdot \tan \left(\pi \cdot \ell\right) \]
      2. unpow-prod-down18.1%

        \[\leadsto \pi \cdot \ell - \color{blue}{\left({F}^{-1} \cdot {F}^{-1}\right)} \cdot \tan \left(\pi \cdot \ell\right) \]
      3. inv-pow18.1%

        \[\leadsto \pi \cdot \ell - \left(\color{blue}{\frac{1}{F}} \cdot {F}^{-1}\right) \cdot \tan \left(\pi \cdot \ell\right) \]
      4. inv-pow18.1%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\left(\frac{1}{F} \cdot \frac{1}{F}\right)} \cdot \tan \left(\pi \cdot \ell\right) \]
    4. Step-by-step derivation
      1. un-div-inv18.1%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{1}{F}}{F}} \cdot \tan \left(\pi \cdot \ell\right) \]
      2. clear-num18.1%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{1}{F}}}} \cdot \tan \left(\pi \cdot \ell\right) \]
    6. Step-by-step derivation
      1. *-commutative18.1%

        \[\leadsto \pi \cdot \ell - \color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{\frac{F}{\frac{1}{F}}}} \]
      2. associate-/r/18.1%

        \[\leadsto \pi \cdot \ell - \tan \left(\pi \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{F} \cdot \frac{1}{F}\right)} \]
      3. associate-*r*32.9%

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\tan \left(\pi \cdot \ell\right)}{F}} \cdot \frac{1}{F} \]
      5. div-inv32.9%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
      6. clear-num32.9%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}}} \]
      7. unpow-132.9%

        \[\leadsto \pi \cdot \ell - \color{blue}{{\left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)}^{-1}} \]
      8. exp-to-pow9.2%

        \[\leadsto \pi \cdot \ell - \color{blue}{e^{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1}} \]
      9. add-sqr-sqrt9.2%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\sqrt{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1} \cdot \sqrt{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1}}} \]
      10. sqrt-unprod9.2%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\sqrt{\left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1\right) \cdot \left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1\right)}}} \]
      11. *-commutative9.2%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{\left(-1 \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right)} \cdot \left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1\right)}} \]
      12. *-commutative9.2%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\left(-1 \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right) \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right)}}} \]
    7. Applied egg-rr69.8%

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

    if 4.99999999999999968e-149 < F

    1. Initial program 89.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. associate-*l/90.0%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      2. *-lft-identity90.0%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot F} \]
    3. Simplified90.0%

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq 2.25 \cdot 10^{-197}:\\ \;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{\pi \cdot \frac{\ell}{F}}}\\ \mathbf{elif}\;F \leq 5 \cdot 10^{-149}:\\ \;\;\;\;\pi \cdot \ell - \frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\ \end{array} \]

Alternative 2: 81.9% accurate, 0.6× speedup?

\[\begin{array}{l} F = |F|\\ \\ \pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F} \end{array} \]
NOTE: F should be positive before calling this function
(FPCore (F l)
 :precision binary64
 (- (* PI l) (/ (/ (tan (* l (cbrt (pow PI 3.0)))) F) F)))
F = abs(F);
double code(double F, double l) {
	return (((double) M_PI) * l) - ((tan((l * cbrt(pow(((double) M_PI), 3.0)))) / F) / F);
}
F = Math.abs(F);
public static double code(double F, double l) {
	return (Math.PI * l) - ((Math.tan((l * Math.cbrt(Math.pow(Math.PI, 3.0)))) / F) / F);
}
F = abs(F)
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(l * cbrt((pi ^ 3.0)))) / F) / F))
end
NOTE: F should be positive before calling this function
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(l * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F}
\end{array}
Derivation
  1. Initial program 76.2%

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    2. *-un-lft-identity76.2%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  3. Applied egg-rr80.6%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  4. Step-by-step derivation
    1. add-cbrt-cube80.6%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}} \cdot \ell\right)}{F}}{F} \]
    2. pow380.6%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \ell\right)}{F}}{F} \]
  5. Applied egg-rr80.6%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}{F}}{F} \]
  6. Final simplification80.6%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F} \]

Alternative 3: 80.8% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if F < 1.0999999999999999e-165

    1. Initial program 69.1%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
    3. Step-by-step derivation
      1. unpow263.9%

        \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \pi}{\color{blue}{F \cdot F}} \]
      2. times-frac71.6%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
    4. Simplified71.6%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
    5. Step-by-step derivation
      1. associate-*r/71.6%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\ell}{F} \cdot \pi}{F}} \]
      2. clear-num71.6%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1}{\frac{F}{\frac{\ell}{F} \cdot \pi}}} \]
      3. *-commutative71.6%

        \[\leadsto \pi \cdot \ell - \frac{1}{\frac{F}{\color{blue}{\pi \cdot \frac{\ell}{F}}}} \]
    6. Applied egg-rr71.6%

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

    if 1.0999999999999999e-165 < F

    1. Initial program 86.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. associate-*l/86.1%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
      2. *-lft-identity86.1%

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

      \[\leadsto \color{blue}{\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq 1.1 \cdot 10^{-165}:\\ \;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{\pi \cdot \frac{\ell}{F}}}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\ \end{array} \]

Alternative 4: 82.0% accurate, 1.0× speedup?

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

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    2. *-un-lft-identity76.2%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  3. Applied egg-rr80.6%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  4. Final simplification80.6%

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

Alternative 5: 74.9% accurate, 1.5× speedup?

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

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

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
  3. Step-by-step derivation
    1. unpow268.7%

      \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \pi}{\color{blue}{F \cdot F}} \]
    2. times-frac73.1%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
  4. Simplified73.1%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
  5. Final simplification73.1%

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

Alternative 6: 74.9% accurate, 1.5× speedup?

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

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    2. *-un-lft-identity76.2%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  3. Applied egg-rr80.6%

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

    \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \pi}{F}}}{F} \]
  5. Step-by-step derivation
    1. *-commutative73.1%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\pi \cdot \ell}}{F}}{F} \]
    2. associate-*r/73.1%

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \frac{\ell}{F}}}{F} \]
  6. Simplified73.1%

    \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \frac{\ell}{F}}}{F} \]
  7. Final simplification73.1%

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

Alternative 7: 74.9% accurate, 1.5× speedup?

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

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

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
  3. Step-by-step derivation
    1. unpow268.7%

      \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \pi}{\color{blue}{F \cdot F}} \]
    2. times-frac73.1%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
  4. Simplified73.1%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{F} \cdot \frac{\pi}{F}} \]
  5. Step-by-step derivation
    1. *-commutative73.1%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{F} \cdot \frac{\ell}{F}} \]
    2. clear-num73.0%

      \[\leadsto \pi \cdot \ell - \frac{\pi}{F} \cdot \color{blue}{\frac{1}{\frac{F}{\ell}}} \]
    3. un-div-inv73.1%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\pi}{F}}{\frac{F}{\ell}}} \]
  6. Applied egg-rr73.1%

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\pi}{F}}{\frac{F}{\ell}}} \]
  7. Final simplification73.1%

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

Alternative 8: 74.8% accurate, 1.5× speedup?

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

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. associate-*l/76.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}} \]
    2. *-un-lft-identity76.2%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  3. Applied egg-rr80.6%

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

    \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell \cdot \pi}{F}}}{F} \]
  5. Final simplification73.1%

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

Reproduce

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