VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.4% → 81.2%
Time: 22.5s
Alternatives: 5
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 5 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.4% 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: 81.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
\mathbf{if}\;\pi \cdot \ell - \frac{1}{F \cdot F} \cdot t_0 \leq 5 \cdot 10^{+287}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F}}{F}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 1 (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < 5e287

    1. Initial program 86.8%

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

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

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

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

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

    if 5e287 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 1 (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

    1. Initial program 28.8%

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{{\left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right)}^{-1}} \]
      3. pow-to-exp1.6%

        \[\leadsto \pi \cdot \ell - \color{blue}{e^{\log \left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right) \cdot -1}} \]
      4. diff-log0.0%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\left(\log \left(F \cdot F\right) - \log \tan \left(\pi \cdot \ell\right)\right)} \cdot -1} \]
      5. diff-log1.6%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\log \left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right)} \cdot -1} \]
      6. associate-/l*1.6%

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

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

        \[\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}}} \]
      2. sqrt-unprod1.6%

        \[\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)}}} \]
      3. *-commutative1.6%

        \[\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)}} \]
      4. *-commutative1.6%

        \[\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)}}} \]
      5. swap-sqr1.6%

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

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{1} \cdot \left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right)}} \]
      7. *-un-lft-identity1.6%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)}}} \]
      8. sqrt-unprod0.0%

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

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

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

Alternative 2: 81.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \cdot F \leq 2 \cdot 10^{-305}:\\ \;\;\;\;\pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (<= (* F F) 2e-305)
   (- (* PI l) (* PI (/ (/ l F) F)))
   (- (* PI l) (/ (tan (* PI l)) (* F F)))))
double code(double F, double l) {
	double tmp;
	if ((F * F) <= 2e-305) {
		tmp = (((double) M_PI) * l) - (((double) M_PI) * ((l / F) / F));
	} else {
		tmp = (((double) M_PI) * l) - (tan((((double) M_PI) * l)) / (F * F));
	}
	return tmp;
}
public static double code(double F, double l) {
	double tmp;
	if ((F * F) <= 2e-305) {
		tmp = (Math.PI * l) - (Math.PI * ((l / F) / F));
	} else {
		tmp = (Math.PI * l) - (Math.tan((Math.PI * l)) / (F * F));
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (F * F) <= 2e-305:
		tmp = (math.pi * l) - (math.pi * ((l / F) / F))
	else:
		tmp = (math.pi * l) - (math.tan((math.pi * l)) / (F * F))
	return tmp
function code(F, l)
	tmp = 0.0
	if (Float64(F * F) <= 2e-305)
		tmp = Float64(Float64(pi * l) - Float64(pi * Float64(Float64(l / F) / F)));
	else
		tmp = Float64(Float64(pi * l) - Float64(tan(Float64(pi * l)) / Float64(F * F)));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((F * F) <= 2e-305)
		tmp = (pi * l) - (pi * ((l / F) / F));
	else
		tmp = (pi * l) - (tan((pi * l)) / (F * F));
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 2e-305], N[(N[(Pi * l), $MachinePrecision] - N[(Pi * N[(N[(l / F), $MachinePrecision] / F), $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}

\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 2 \cdot 10^{-305}:\\
\;\;\;\;\pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{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 (*.f64 F F) < 1.99999999999999999e-305

    1. Initial program 30.4%

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

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

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

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

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{1 \cdot \pi}{\frac{F}{\ell} \cdot F}} \]
      3. *-un-lft-identity46.8%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{\frac{F}{\ell} \cdot F}} \]
    7. Step-by-step derivation
      1. clear-num46.7%

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

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

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

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell}{F}}}{F} \cdot \pi \]
    8. Applied egg-rr46.8%

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

    if 1.99999999999999999e-305 < (*.f64 F F)

    1. Initial program 93.2%

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

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

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

      \[\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 simplification82.0%

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

Alternative 3: 80.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan \left(\pi \cdot \ell\right)\\ \mathbf{if}\;F \cdot F \leq 0:\\ \;\;\;\;\pi \cdot \ell - \frac{F \cdot F}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{t_0}{F \cdot F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (tan (* PI l))))
   (if (<= (* F F) 0.0)
     (- (* PI l) (/ (* F F) t_0))
     (- (* PI l) (/ t_0 (* F F))))))
double code(double F, double l) {
	double t_0 = tan((((double) M_PI) * l));
	double tmp;
	if ((F * F) <= 0.0) {
		tmp = (((double) M_PI) * l) - ((F * F) / t_0);
	} else {
		tmp = (((double) M_PI) * l) - (t_0 / (F * F));
	}
	return tmp;
}
public static double code(double F, double l) {
	double t_0 = Math.tan((Math.PI * l));
	double tmp;
	if ((F * F) <= 0.0) {
		tmp = (Math.PI * l) - ((F * F) / t_0);
	} else {
		tmp = (Math.PI * l) - (t_0 / (F * F));
	}
	return tmp;
}
def code(F, l):
	t_0 = math.tan((math.pi * l))
	tmp = 0
	if (F * F) <= 0.0:
		tmp = (math.pi * l) - ((F * F) / t_0)
	else:
		tmp = (math.pi * l) - (t_0 / (F * F))
	return tmp
function code(F, l)
	t_0 = tan(Float64(pi * l))
	tmp = 0.0
	if (Float64(F * F) <= 0.0)
		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
function tmp_2 = code(F, l)
	t_0 = tan((pi * l));
	tmp = 0.0;
	if ((F * F) <= 0.0)
		tmp = (pi * l) - ((F * F) / t_0);
	else
		tmp = (pi * l) - (t_0 / (F * F));
	end
	tmp_2 = tmp;
end
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(F * F), $MachinePrecision], 0.0], 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}

\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
\mathbf{if}\;F \cdot F \leq 0:\\
\;\;\;\;\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 2 regimes
  2. if (*.f64 F F) < 0.0

    1. Initial program 29.0%

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{{\left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right)}^{-1}} \]
      3. pow-to-exp16.0%

        \[\leadsto \pi \cdot \ell - \color{blue}{e^{\log \left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right) \cdot -1}} \]
      4. diff-log14.9%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\left(\log \left(F \cdot F\right) - \log \tan \left(\pi \cdot \ell\right)\right)} \cdot -1} \]
      5. diff-log16.0%

        \[\leadsto \pi \cdot \ell - e^{\color{blue}{\log \left(\frac{F \cdot F}{\tan \left(\pi \cdot \ell\right)}\right)} \cdot -1} \]
      6. associate-/l*21.7%

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

      \[\leadsto \pi \cdot \ell - \color{blue}{e^{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot -1}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt21.5%

        \[\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}}} \]
      2. sqrt-unprod21.7%

        \[\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)}}} \]
      3. *-commutative21.7%

        \[\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)}} \]
      4. *-commutative21.7%

        \[\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)}}} \]
      5. swap-sqr21.7%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{\left(-1 \cdot -1\right) \cdot \left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right)}}} \]
      6. metadata-eval21.7%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{1} \cdot \left(\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)\right)}} \]
      7. *-un-lft-identity21.7%

        \[\leadsto \pi \cdot \ell - e^{\sqrt{\color{blue}{\log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right) \cdot \log \left(\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}\right)}}} \]
      8. sqrt-unprod0.0%

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

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

    if 0.0 < (*.f64 F F)

    1. Initial program 92.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \cdot F \leq 0:\\ \;\;\;\;\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 4: 75.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F} \end{array} \]
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ l F) (/ PI F))))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / F));
}
public static double code(double F, double l) {
	return (Math.PI * l) - ((l / F) * (Math.PI / F));
}
def code(F, l):
	return (math.pi * l) - ((l / F) * (math.pi / F))
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / F)))
end
function tmp = code(F, l)
	tmp = (pi * l) - ((l / F) * (pi / F));
end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}
\end{array}
Derivation
  1. Initial program 78.0%

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

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

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

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

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

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

Alternative 5: 75.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{F} \end{array} \]
(FPCore (F l) :precision binary64 (- (* PI l) (* PI (/ (/ l F) F))))
double code(double F, double l) {
	return (((double) M_PI) * l) - (((double) M_PI) * ((l / F) / F));
}
public static double code(double F, double l) {
	return (Math.PI * l) - (Math.PI * ((l / F) / F));
}
def code(F, l):
	return (math.pi * l) - (math.pi * ((l / F) / F))
function code(F, l)
	return Float64(Float64(pi * l) - Float64(pi * Float64(Float64(l / F) / F)))
end
function tmp = code(F, l)
	tmp = (pi * l) - (pi * ((l / F) / F));
end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(Pi * N[(N[(l / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{F}
\end{array}
Derivation
  1. Initial program 78.0%

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

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\pi}{\frac{F}{\ell} \cdot F}} \]
  7. Step-by-step derivation
    1. clear-num76.6%

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\ell}{F}}}{F} \cdot \pi \]
  8. Applied egg-rr76.7%

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

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

Reproduce

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