VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.5% → 86.1%
Time: 35.5s
Alternatives: 10
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 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.5% 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: 86.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+43} \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\pi \cdot \ell + \frac{\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot {\left(\pi \cdot \ell\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (or (<= (* PI l) -1e+43) (not (<= (* PI l) 5e-5)))
   (+
    (* PI l)
    (/ (sin (* PI l)) (* (pow F 2.0) (+ 1.0 (* -0.5 (pow (* PI l) 2.0))))))
   (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -1e+43) || !((((double) M_PI) * l) <= 5e-5)) {
		tmp = (((double) M_PI) * l) + (sin((((double) M_PI) * l)) / (pow(F, 2.0) * (1.0 + (-0.5 * pow((((double) M_PI) * l), 2.0)))));
	} 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 (((Math.PI * l) <= -1e+43) || !((Math.PI * l) <= 5e-5)) {
		tmp = (Math.PI * l) + (Math.sin((Math.PI * l)) / (Math.pow(F, 2.0) * (1.0 + (-0.5 * Math.pow((Math.PI * l), 2.0)))));
	} else {
		tmp = (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if ((math.pi * l) <= -1e+43) or not ((math.pi * l) <= 5e-5):
		tmp = (math.pi * l) + (math.sin((math.pi * l)) / (math.pow(F, 2.0) * (1.0 + (-0.5 * math.pow((math.pi * l), 2.0)))))
	else:
		tmp = (math.pi * l) - ((math.tan((math.pi * l)) / F) / F)
	return tmp
function code(F, l)
	tmp = 0.0
	if ((Float64(pi * l) <= -1e+43) || !(Float64(pi * l) <= 5e-5))
		tmp = Float64(Float64(pi * l) + Float64(sin(Float64(pi * l)) / Float64((F ^ 2.0) * Float64(1.0 + Float64(-0.5 * (Float64(pi * l) ^ 2.0))))));
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (((pi * l) <= -1e+43) || ~(((pi * l) <= 5e-5)))
		tmp = (pi * l) + (sin((pi * l)) / ((F ^ 2.0) * (1.0 + (-0.5 * ((pi * l) ^ 2.0)))));
	else
		tmp = (pi * l) - ((tan((pi * l)) / F) / F);
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -1e+43], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5e-5]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] + N[(N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / N[(N[Power[F, 2.0], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[Power[N[(Pi * l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+43} \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell + \frac{\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot {\left(\pi \cdot \ell\right)}^{2}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -1.00000000000000001e43 or 5.00000000000000024e-5 < (*.f64 (PI.f64) l)

    1. Initial program 55.8%

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

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

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{-\frac{\tan \left(\pi \cdot \ell\right)}{F}}{-F}} \]
      5. distribute-frac-neg55.8%

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

        \[\leadsto \pi \cdot \ell - \frac{\frac{-\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{-F} \cdot \sqrt{-F}}} \]
      7. sqrt-unprod55.8%

        \[\leadsto \pi \cdot \ell - \frac{\frac{-\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{\left(-F\right) \cdot \left(-F\right)}}} \]
      8. sqr-neg55.8%

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

        \[\leadsto \pi \cdot \ell - \frac{\frac{-\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{\sqrt{F} \cdot \sqrt{F}}} \]
      10. add-sqr-sqrt56.2%

        \[\leadsto \pi \cdot \ell - \frac{\frac{-\tan \left(\pi \cdot \ell\right)}{F}}{\color{blue}{F}} \]
      11. associate-/l/56.2%

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

        \[\leadsto \pi \cdot \ell - \frac{-\color{blue}{\frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F \cdot F} \]
      13. distribute-neg-frac56.2%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{-\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F \cdot F} \]
      14. associate-/l/56.2%

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{-\sin \left(\pi \cdot \ell\right)}{\left(F \cdot F\right) \cdot \cos \left(\pi \cdot \ell\right)}} \]
      15. pow256.2%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{\color{blue}{{F}^{2}} \cdot \cos \left(\pi \cdot \ell\right)} \]
    3. Applied egg-rr56.2%

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \cos \left(\pi \cdot \ell\right)}} \]
    4. Taylor expanded in l around 0 71.0%

      \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \color{blue}{\left(1 + -0.5 \cdot \left({\ell}^{2} \cdot {\pi}^{2}\right)\right)}} \]
    5. Step-by-step derivation
      1. *-commutative71.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\pi}^{2} \cdot {\ell}^{2}\right)}\right)} \]
      2. unpow271.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot \left(\color{blue}{\left(\pi \cdot \pi\right)} \cdot {\ell}^{2}\right)\right)} \]
      3. unpow271.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot \left(\left(\pi \cdot \pi\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)} \]
      4. swap-sqr71.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(\left(\pi \cdot \ell\right) \cdot \left(\pi \cdot \ell\right)\right)}\right)} \]
      5. unpow271.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot \color{blue}{{\left(\pi \cdot \ell\right)}^{2}}\right)} \]
      6. *-commutative71.0%

        \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \left(1 + -0.5 \cdot {\color{blue}{\left(\ell \cdot \pi\right)}}^{2}\right)} \]
    6. Simplified71.0%

      \[\leadsto \pi \cdot \ell - \frac{-\sin \left(\pi \cdot \ell\right)}{{F}^{2} \cdot \color{blue}{\left(1 + -0.5 \cdot {\left(\ell \cdot \pi\right)}^{2}\right)}} \]

    if -1.00000000000000001e43 < (*.f64 (PI.f64) l) < 5.00000000000000024e-5

    1. Initial program 88.9%

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

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

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

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

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

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

Alternative 2: 82.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F} \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (/ (/ (tan (* l (cbrt (pow PI 3.0)))) F) F)))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((tan((l * cbrt(pow(((double) M_PI), 3.0)))) / F) / 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);
}
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(l * cbrt((pi ^ 3.0)))) / F) / F))
end
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}

\\
\pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F}
\end{array}
Derivation
  1. Initial program 73.0%

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

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

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

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

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

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

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

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

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

Alternative 3: 82.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right) \end{array} \]
(FPCore (F l) :precision binary64 (fma PI l (/ (/ (tan (* PI l)) (- F)) F)))
double code(double F, double l) {
	return fma(((double) M_PI), l, ((tan((((double) M_PI) * l)) / -F) / F));
}
function code(F, l)
	return fma(pi, l, Float64(Float64(tan(Float64(pi * l)) / Float64(-F)) / F))
end
code[F_, l_] := N[(Pi * l + N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / (-F)), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)
\end{array}
Derivation
  1. Initial program 73.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, -\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)} \]
    2. neg-mul-173.0%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{-1 \cdot \left(\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)}\right) \]
    3. metadata-eval73.0%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1}{-1}} \cdot \left(\frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)\right)\right) \]
    4. associate-*l/73.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{1}{-1} \cdot \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{F \cdot F}}\right) \]
    5. *-lft-identity73.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{1}{-1} \cdot \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{F \cdot F}\right) \]
    6. times-frac73.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \color{blue}{\frac{1 \cdot \tan \left(\pi \cdot \ell\right)}{-1 \cdot \left(F \cdot F\right)}}\right) \]
    7. *-lft-identity73.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\color{blue}{\tan \left(\pi \cdot \ell\right)}}{-1 \cdot \left(F \cdot F\right)}\right) \]
    8. associate-*l*73.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\tan \left(\pi \cdot \ell\right)}{\color{blue}{\left(-1 \cdot F\right) \cdot F}}\right) \]
    9. neg-mul-173.3%

      \[\leadsto \mathsf{fma}\left(\pi, \ell, \frac{\tan \left(\pi \cdot \ell\right)}{\color{blue}{\left(-F\right)} \cdot F}\right) \]
    10. associate-/r*77.4%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, \ell, \frac{\frac{\tan \left(\pi \cdot \ell\right)}{-F}}{F}\right)} \]
  4. Final simplification77.4%

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

Alternative 4: 75.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -2000000:\\ \;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell + \frac{\pi \cdot \frac{\ell}{F}}{-F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (<= (* PI l) -2000000.0)
   (+ (* PI l) (/ (* l (/ PI F)) F))
   (+ (* PI l) (/ (* PI (/ l F)) (- F)))))
double code(double F, double l) {
	double tmp;
	if ((((double) M_PI) * l) <= -2000000.0) {
		tmp = (((double) M_PI) * l) + ((l * (((double) M_PI) / F)) / F);
	} else {
		tmp = (((double) M_PI) * l) + ((((double) M_PI) * (l / F)) / -F);
	}
	return tmp;
}
public static double code(double F, double l) {
	double tmp;
	if ((Math.PI * l) <= -2000000.0) {
		tmp = (Math.PI * l) + ((l * (Math.PI / F)) / F);
	} else {
		tmp = (Math.PI * l) + ((Math.PI * (l / F)) / -F);
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (math.pi * l) <= -2000000.0:
		tmp = (math.pi * l) + ((l * (math.pi / F)) / F)
	else:
		tmp = (math.pi * l) + ((math.pi * (l / F)) / -F)
	return tmp
function code(F, l)
	tmp = 0.0
	if (Float64(pi * l) <= -2000000.0)
		tmp = Float64(Float64(pi * l) + Float64(Float64(l * Float64(pi / F)) / F));
	else
		tmp = Float64(Float64(pi * l) + Float64(Float64(pi * Float64(l / F)) / Float64(-F)));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((pi * l) <= -2000000.0)
		tmp = (pi * l) + ((l * (pi / F)) / F);
	else
		tmp = (pi * l) + ((pi * (l / F)) / -F);
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[LessEqual[N[(Pi * l), $MachinePrecision], -2000000.0], N[(N[(Pi * l), $MachinePrecision] + N[(N[(l * N[(Pi / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] / (-F)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000:\\
\;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -2e6

    1. Initial program 56.6%

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

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
    3. Applied egg-rr56.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-cube56.8%

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

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}{F}}{F} \]
    6. Step-by-step derivation
      1. rem-cbrt-cube56.6%

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

        \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
      3. add-sqr-sqrt26.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{\sin \left(\pi \cdot \ell\right)} \cdot \sqrt{\sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      4. sqrt-unprod53.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{\sin \left(\pi \cdot \ell\right) \cdot \sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      5. sqr-neg53.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\sqrt{\color{blue}{\left(-\sin \left(\pi \cdot \ell\right)\right) \cdot \left(-\sin \left(\pi \cdot \ell\right)\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      6. sqrt-unprod27.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{-\sin \left(\pi \cdot \ell\right)} \cdot \sqrt{-\sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      7. add-sqr-sqrt52.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{-\sin \left(\pi \cdot \ell\right)}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      8. distribute-neg-frac52.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{-\frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
      9. tan-quot52.0%

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{-1 \cdot \frac{\ell \cdot \pi}{F}}}{F} \]
    9. Step-by-step derivation
      1. mul-1-neg43.9%

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

        \[\leadsto \pi \cdot \ell - \frac{-\color{blue}{\ell \cdot \frac{\pi}{F}}}{F} \]
      3. distribute-rgt-neg-in43.9%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \left(-\frac{\pi}{F}\right)}}{F} \]
      4. distribute-neg-frac43.9%

        \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \color{blue}{\frac{-\pi}{F}}}{F} \]
    10. Simplified43.9%

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

    if -2e6 < (*.f64 (PI.f64) l)

    1. Initial program 78.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -2000000:\\ \;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell + \frac{\pi \cdot \frac{\ell}{F}}{-F}\\ \end{array} \]

Alternative 5: 81.6% accurate, 1.0× speedup?

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

\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) < 0.0

    1. Initial program 27.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (*.f64 F F)

    1. Initial program 86.9%

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

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

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

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

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

Alternative 6: 75.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -2000000:\\ \;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\pi}{\frac{F}{\ell}}}{F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (<= (* PI l) -2000000.0)
   (+ (* PI l) (/ (* l (/ PI F)) F))
   (- (* PI l) (/ (/ PI (/ F l)) F))))
double code(double F, double l) {
	double tmp;
	if ((((double) M_PI) * l) <= -2000000.0) {
		tmp = (((double) M_PI) * l) + ((l * (((double) M_PI) / F)) / F);
	} else {
		tmp = (((double) M_PI) * l) - ((((double) M_PI) / (F / l)) / F);
	}
	return tmp;
}
public static double code(double F, double l) {
	double tmp;
	if ((Math.PI * l) <= -2000000.0) {
		tmp = (Math.PI * l) + ((l * (Math.PI / F)) / F);
	} else {
		tmp = (Math.PI * l) - ((Math.PI / (F / l)) / F);
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (math.pi * l) <= -2000000.0:
		tmp = (math.pi * l) + ((l * (math.pi / F)) / F)
	else:
		tmp = (math.pi * l) - ((math.pi / (F / l)) / F)
	return tmp
function code(F, l)
	tmp = 0.0
	if (Float64(pi * l) <= -2000000.0)
		tmp = Float64(Float64(pi * l) + Float64(Float64(l * Float64(pi / F)) / F));
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(pi / Float64(F / l)) / F));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((pi * l) <= -2000000.0)
		tmp = (pi * l) + ((l * (pi / F)) / F);
	else
		tmp = (pi * l) - ((pi / (F / l)) / F);
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[LessEqual[N[(Pi * l), $MachinePrecision], -2000000.0], N[(N[(Pi * l), $MachinePrecision] + N[(N[(l * N[(Pi / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / N[(F / l), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000:\\
\;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -2e6

    1. Initial program 56.6%

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

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
    3. Applied egg-rr56.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-cube56.8%

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

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\tan \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}{F}}{F} \]
    6. Step-by-step derivation
      1. rem-cbrt-cube56.6%

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

        \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
      3. add-sqr-sqrt26.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{\sin \left(\pi \cdot \ell\right)} \cdot \sqrt{\sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      4. sqrt-unprod53.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{\sin \left(\pi \cdot \ell\right) \cdot \sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      5. sqr-neg53.3%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\sqrt{\color{blue}{\left(-\sin \left(\pi \cdot \ell\right)\right) \cdot \left(-\sin \left(\pi \cdot \ell\right)\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      6. sqrt-unprod27.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{\sqrt{-\sin \left(\pi \cdot \ell\right)} \cdot \sqrt{-\sin \left(\pi \cdot \ell\right)}}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      7. add-sqr-sqrt52.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\frac{\color{blue}{-\sin \left(\pi \cdot \ell\right)}}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
      8. distribute-neg-frac52.0%

        \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{-\frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
      9. tan-quot52.0%

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{-1 \cdot \frac{\ell \cdot \pi}{F}}}{F} \]
    9. Step-by-step derivation
      1. mul-1-neg43.9%

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

        \[\leadsto \pi \cdot \ell - \frac{-\color{blue}{\ell \cdot \frac{\pi}{F}}}{F} \]
      3. distribute-rgt-neg-in43.9%

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \left(-\frac{\pi}{F}\right)}}{F} \]
      4. distribute-neg-frac43.9%

        \[\leadsto \pi \cdot \ell - \frac{\ell \cdot \color{blue}{\frac{-\pi}{F}}}{F} \]
    10. Simplified43.9%

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

    if -2e6 < (*.f64 (PI.f64) l)

    1. Initial program 78.5%

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

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

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\frac{\pi}{\frac{F}{\ell}}}}{F} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -2000000:\\ \;\;\;\;\pi \cdot \ell + \frac{\ell \cdot \frac{\pi}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\pi}{\frac{F}{\ell}}}{F}\\ \end{array} \]

Alternative 7: 82.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F} \end{array} \]
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (tan (* PI l)) F) F)))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((tan((((double) M_PI) * l)) / F) / F);
}
public static double code(double F, double l) {
	return (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
}
def code(F, l):
	return (math.pi * l) - ((math.tan((math.pi * l)) / F) / F)
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F))
end
function tmp = code(F, l)
	tmp = (pi * l) - ((tan((pi * l)) / F) / F);
end
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}

\\
\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}
\end{array}
Derivation
  1. Initial program 73.0%

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

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

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

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

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

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

Alternative 8: 74.7% 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 73.0%

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

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

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

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

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

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

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

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

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

Alternative 9: 74.7% 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 73.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{1} \cdot \ell}{\frac{F}{\pi} \cdot F} \]
    5. *-un-lft-identity64.6%

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

    \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell}{\frac{F}{\pi} \cdot F}} \]
  9. Step-by-step derivation
    1. associate-/l/68.7%

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

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

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

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

Alternative 10: 74.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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