VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.5% → 98.5%
Time: 14.8s
Alternatives: 8
Speedup: 0.8×

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.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: 98.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\pi \cdot \ell\\ \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) -5e+17) (not (<= (* PI l) 5e-5)))
   (* PI l)
   (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -5e+17) || !((((double) M_PI) * l) <= 5e-5)) {
		tmp = ((double) M_PI) * l;
	} 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) <= -5e+17) || !((Math.PI * l) <= 5e-5)) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if ((math.pi * l) <= -5e+17) or not ((math.pi * l) <= 5e-5):
		tmp = math.pi * l
	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) <= -5e+17) || !(Float64(pi * l) <= 5e-5))
		tmp = Float64(pi * l);
	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) <= -5e+17) || ~(((pi * l) <= 5e-5)))
		tmp = pi * l;
	else
		tmp = (pi * l) - ((tan((pi * l)) / F) / F);
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e+17], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5e-5]], $MachinePrecision]], N[(Pi * l), $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 -5 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell\\

\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) < -5e17 or 5.00000000000000024e-5 < (*.f64 (PI.f64) l)

    1. Initial program 54.9%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 99.7%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.8%

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

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

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

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

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

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

Alternative 2: 74.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{-15} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-167} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-202}\right) \land \left(\pi \cdot \ell \leq -1 \cdot 10^{-288} \lor \neg \left(\pi \cdot \ell \leq 10^{-235}\right) \land \pi \cdot \ell \leq 5 \cdot 10^{-45}\right)\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi \cdot \frac{\ell}{F}}{-F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (or (<= (* PI l) -5e-15)
         (not
          (or (<= (* PI l) -2e-167)
              (and (not (<= (* PI l) -2e-202))
                   (or (<= (* PI l) -1e-288)
                       (and (not (<= (* PI l) 1e-235))
                            (<= (* PI l) 5e-45)))))))
   (* PI l)
   (/ (* PI (/ l F)) (- F))))
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -5e-15) || !(((((double) M_PI) * l) <= -2e-167) || (!((((double) M_PI) * l) <= -2e-202) && (((((double) M_PI) * l) <= -1e-288) || (!((((double) M_PI) * l) <= 1e-235) && ((((double) M_PI) * l) <= 5e-45)))))) {
		tmp = ((double) M_PI) * l;
	} else {
		tmp = (((double) M_PI) * (l / F)) / -F;
	}
	return tmp;
}
public static double code(double F, double l) {
	double tmp;
	if (((Math.PI * l) <= -5e-15) || !(((Math.PI * l) <= -2e-167) || (!((Math.PI * l) <= -2e-202) && (((Math.PI * l) <= -1e-288) || (!((Math.PI * l) <= 1e-235) && ((Math.PI * l) <= 5e-45)))))) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI * (l / F)) / -F;
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if ((math.pi * l) <= -5e-15) or not (((math.pi * l) <= -2e-167) or (not ((math.pi * l) <= -2e-202) and (((math.pi * l) <= -1e-288) or (not ((math.pi * l) <= 1e-235) and ((math.pi * l) <= 5e-45))))):
		tmp = math.pi * l
	else:
		tmp = (math.pi * (l / F)) / -F
	return tmp
function code(F, l)
	tmp = 0.0
	if ((Float64(pi * l) <= -5e-15) || !((Float64(pi * l) <= -2e-167) || (!(Float64(pi * l) <= -2e-202) && ((Float64(pi * l) <= -1e-288) || (!(Float64(pi * l) <= 1e-235) && (Float64(pi * l) <= 5e-45))))))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi * Float64(l / F)) / Float64(-F));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (((pi * l) <= -5e-15) || ~((((pi * l) <= -2e-167) || (~(((pi * l) <= -2e-202)) && (((pi * l) <= -1e-288) || (~(((pi * l) <= 1e-235)) && ((pi * l) <= 5e-45)))))))
		tmp = pi * l;
	else
		tmp = (pi * (l / F)) / -F;
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e-15], N[Not[Or[LessEqual[N[(Pi * l), $MachinePrecision], -2e-167], And[N[Not[LessEqual[N[(Pi * l), $MachinePrecision], -2e-202]], $MachinePrecision], Or[LessEqual[N[(Pi * l), $MachinePrecision], -1e-288], And[N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 1e-235]], $MachinePrecision], LessEqual[N[(Pi * l), $MachinePrecision], 5e-45]]]]]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] / (-F)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{-15} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-167} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-202}\right) \land \left(\pi \cdot \ell \leq -1 \cdot 10^{-288} \lor \neg \left(\pi \cdot \ell \leq 10^{-235}\right) \land \pi \cdot \ell \leq 5 \cdot 10^{-45}\right)\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -4.99999999999999999e-15 or -2e-167 < (*.f64 (PI.f64) l) < -2.0000000000000001e-202 or -1.00000000000000006e-288 < (*.f64 (PI.f64) l) < 9.9999999999999996e-236 or 4.99999999999999976e-45 < (*.f64 (PI.f64) l)

    1. Initial program 65.1%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 91.2%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

    if -4.99999999999999999e-15 < (*.f64 (PI.f64) l) < -2e-167 or -2.0000000000000001e-202 < (*.f64 (PI.f64) l) < -1.00000000000000006e-288 or 9.9999999999999996e-236 < (*.f64 (PI.f64) l) < 4.99999999999999976e-45

    1. Initial program 89.4%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around 0 53.7%

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

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

        \[\leadsto -\color{blue}{\ell \cdot \frac{\pi}{{F}^{2}}} \]
      3. distribute-rgt-neg-in52.8%

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

        \[\leadsto \ell \cdot \color{blue}{\frac{-\pi}{{F}^{2}}} \]
    7. Simplified52.8%

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

        \[\leadsto \color{blue}{\frac{\ell \cdot \left(-\pi\right)}{{F}^{2}}} \]
      2. unpow253.7%

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

        \[\leadsto \color{blue}{\frac{\ell}{F} \cdot \frac{-\pi}{F}} \]
      4. add-sqr-sqrt0.0%

        \[\leadsto \frac{\ell}{F} \cdot \frac{\color{blue}{\sqrt{-\pi} \cdot \sqrt{-\pi}}}{F} \]
      5. sqrt-unprod2.6%

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

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

        \[\leadsto \frac{\ell}{F} \cdot \frac{\color{blue}{\sqrt{\pi} \cdot \sqrt{\pi}}}{F} \]
      8. add-sqr-sqrt2.6%

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

        \[\leadsto \color{blue}{\frac{\ell \cdot \pi}{F \cdot F}} \]
      10. associate-/l/2.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{-15} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-167} \lor \neg \left(\pi \cdot \ell \leq -2 \cdot 10^{-202}\right) \land \left(\pi \cdot \ell \leq -1 \cdot 10^{-288} \lor \neg \left(\pi \cdot \ell \leq 10^{-235}\right) \land \pi \cdot \ell \leq 5 \cdot 10^{-45}\right)\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi \cdot \frac{\ell}{F}}{-F}\\ \end{array} \]

Alternative 3: 98.2% accurate, 0.7× speedup?

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

\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 or 5.00000000000000024e-5 < (*.f64 (PI.f64) l)

    1. Initial program 56.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 97.5%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 97.5%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 97.5%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 97.5%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

Alternative 7: 92.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\ell \cdot \pi}}{F \cdot F} \]
    5. Taylor expanded in F around inf 97.5%

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \ell \cdot \pi - \color{blue}{\frac{\frac{\ell}{F}}{F} \cdot \pi} \]
      3. distribute-rgt-out--99.3%

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

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

        \[\leadsto \pi \cdot \left(\ell - \frac{\ell}{\color{blue}{{F}^{2}}}\right) \]
    10. Applied egg-rr90.8%

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

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

Alternative 8: 73.9% accurate, 3.0× speedup?

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

\\
\pi \cdot \ell
\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. sqr-neg73.0%

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

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

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

      \[\leadsto \pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{\color{blue}{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. Taylor expanded in F around inf 74.1%

    \[\leadsto \color{blue}{\ell \cdot \pi} \]
  6. Final simplification74.1%

    \[\leadsto \pi \cdot \ell \]

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