VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.5% → 99.0%
Time: 13.5s
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: 99.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 200000000\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) -2e+17) (not (<= (* PI l) 200000000.0)))
   (* PI l)
   (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -2e+17) || !((((double) M_PI) * l) <= 200000000.0)) {
		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) <= -2e+17) || !((Math.PI * l) <= 200000000.0)) {
		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) <= -2e+17) or not ((math.pi * l) <= 200000000.0):
		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) <= -2e+17) || !(Float64(pi * l) <= 200000000.0))
		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) <= -2e+17) || ~(((pi * l) <= 200000000.0)))
		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], -2e+17], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 200000000.0]], $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 -2 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 200000000\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) < -2e17 or 2e8 < (*.f64 (PI.f64) l)

    1. Initial program 63.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg63.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/63.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-identity63.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 99.6%

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

    if -2e17 < (*.f64 (PI.f64) l) < 2e8

    1. Initial program 86.7%

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

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

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

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

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

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

Alternative 2: 73.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\pi}{F} \cdot \frac{-\ell}{F}\\
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{-60}:\\
\;\;\;\;\pi \cdot \ell\\

\mathbf{elif}\;\pi \cdot \ell \leq -1 \cdot 10^{-181}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-248}:\\
\;\;\;\;\pi \cdot \ell\\

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

\mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-214} \lor \neg \left(\pi \cdot \ell \leq 10^{-112}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (PI.f64) l) < -5.0000000000000001e-60 or -1.00000000000000005e-181 < (*.f64 (PI.f64) l) < 5.0000000000000001e-248 or 5.00000000000000016e-229 < (*.f64 (PI.f64) l) < 4.9999999999999998e-214 or 9.9999999999999995e-113 < (*.f64 (PI.f64) l)

    1. Initial program 73.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg73.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/74.2%

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{{F}^{2}}\right)} \]
    5. Step-by-step derivation
      1. unpow260.7%

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 90.2%

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

    if -5.0000000000000001e-60 < (*.f64 (PI.f64) l) < -1.00000000000000005e-181 or 5.0000000000000001e-248 < (*.f64 (PI.f64) l) < 5.00000000000000016e-229

    1. Initial program 73.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg73.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/80.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Step-by-step derivation
      1. associate-/r*74.1%

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

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

      \[\leadsto \ell \cdot \left(\pi - \color{blue}{\frac{\pi}{F} \cdot \frac{1}{F}}\right) \]
    9. Taylor expanded in F around 0 54.7%

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

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

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

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

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

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

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

    if 4.9999999999999998e-214 < (*.f64 (PI.f64) l) < 9.9999999999999995e-113

    1. Initial program 95.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg95.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/95.0%

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{{F}^{2}}\right)} \]
    5. Step-by-step derivation
      1. unpow294.9%

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Step-by-step derivation
      1. associate-/r*94.9%

        \[\leadsto \ell \cdot \left(\pi - \color{blue}{\frac{\frac{\pi}{F}}{F}}\right) \]
      2. div-inv95.0%

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

      \[\leadsto \ell \cdot \left(\pi - \color{blue}{\frac{\pi}{F} \cdot \frac{1}{F}}\right) \]
    9. Taylor expanded in F around 0 61.9%

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

        \[\leadsto \color{blue}{-\frac{\ell \cdot \pi}{{F}^{2}}} \]
      2. unpow261.9%

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

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

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

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

        \[\leadsto -\color{blue}{\frac{\frac{\ell}{F}}{\frac{F}{\pi}}} \]
      4. associate-/r/66.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{-60}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\pi \cdot \ell \leq -1 \cdot 10^{-181}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-248}:\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-229}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-214} \lor \neg \left(\pi \cdot \ell \leq 10^{-112}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\ell}{F}}{F} \cdot \left(-\pi\right)\\ \end{array} \]

Alternative 3: 92.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -50000000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \pi \cdot \frac{\ell}{F \cdot F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (or (<= (* PI l) -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.0) || !(Float64(pi * l) <= 5e-5))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi * l) - Float64(pi * Float64(l / Float64(F * F))));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (((pi * l) <= -50000000000.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], -50000000000.0], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5e-5]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(Pi * N[(l / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 65.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg65.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/65.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 96.8%

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

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

    1. Initial program 86.7%

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

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

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

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

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

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

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

Alternative 4: 98.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -50000000000 \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) -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.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], -50000000000.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 -50000000000 \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) < -5e10 or 5.00000000000000024e-5 < (*.f64 (PI.f64) l)

    1. Initial program 65.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg65.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/65.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 96.8%

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

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

    1. Initial program 86.7%

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

        \[\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/89.5%

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

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

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

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

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

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

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

        \[\leadsto \pi \cdot \ell - \frac{\tan \left({\color{blue}{\left(e^{\log \left(\pi \cdot \ell\right) \cdot 3}\right)}}^{0.3333333333333333}\right)}{F \cdot F} \]
      5. pow-exp43.1%

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

      \[\leadsto \pi \cdot \ell - \frac{\tan \color{blue}{\left(e^{\left(\log \left(\pi \cdot \ell\right) \cdot 3\right) \cdot 0.3333333333333333}\right)}}{F \cdot F} \]
    6. Taylor expanded in l around 0 88.9%

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

        \[\leadsto \pi \cdot \ell - \frac{\color{blue}{\pi \cdot \ell}}{{F}^{2}} \]
      2. unpow288.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -50000000000 \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 -50000000000 \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) -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.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) <= -50000000000.0) || !(Float64(pi * l) <= 5e-5))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(pi * Float64(l / F)) / F));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if (((pi * l) <= -50000000000.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], -50000000000.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 -50000000000 \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) < -5e10 or 5.00000000000000024e-5 < (*.f64 (PI.f64) l)

    1. Initial program 65.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg65.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/65.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 96.8%

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

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

    1. Initial program 86.7%

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

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

        \[\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}} \]
    4. Taylor expanded in l around 0 99.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -50000000000 \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 6: 92.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 65.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg65.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/65.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 96.8%

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

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

    1. Initial program 86.7%

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

        \[\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/89.5%

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

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

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

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

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

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

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

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

Alternative 7: 73.4% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.3 \cdot 10^{-61} \lor \neg \left(\ell \leq -4 \cdot 10^{-182}\right) \land \left(\ell \leq 3 \cdot 10^{-248} \lor \neg \left(\ell \leq 3.8 \cdot 10^{-227} \lor \neg \left(\ell \leq 5.2 \cdot 10^{-214}\right) \land \ell \leq 3.6 \cdot 10^{-111}\right)\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (if (or (<= l -5.3e-61)
         (and (not (<= l -4e-182))
              (or (<= l 3e-248)
                  (not
                   (or (<= l 3.8e-227)
                       (and (not (<= l 5.2e-214)) (<= l 3.6e-111)))))))
   (* PI l)
   (* (/ PI F) (/ (- l) F))))
double code(double F, double l) {
	double tmp;
	if ((l <= -5.3e-61) || (!(l <= -4e-182) && ((l <= 3e-248) || !((l <= 3.8e-227) || (!(l <= 5.2e-214) && (l <= 3.6e-111)))))) {
		tmp = ((double) M_PI) * l;
	} else {
		tmp = (((double) M_PI) / F) * (-l / F);
	}
	return tmp;
}
public static double code(double F, double l) {
	double tmp;
	if ((l <= -5.3e-61) || (!(l <= -4e-182) && ((l <= 3e-248) || !((l <= 3.8e-227) || (!(l <= 5.2e-214) && (l <= 3.6e-111)))))) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI / F) * (-l / F);
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (l <= -5.3e-61) or (not (l <= -4e-182) and ((l <= 3e-248) or not ((l <= 3.8e-227) or (not (l <= 5.2e-214) and (l <= 3.6e-111))))):
		tmp = math.pi * l
	else:
		tmp = (math.pi / F) * (-l / F)
	return tmp
function code(F, l)
	tmp = 0.0
	if ((l <= -5.3e-61) || (!(l <= -4e-182) && ((l <= 3e-248) || !((l <= 3.8e-227) || (!(l <= 5.2e-214) && (l <= 3.6e-111))))))
		tmp = Float64(pi * l);
	else
		tmp = Float64(Float64(pi / F) * Float64(Float64(-l) / F));
	end
	return tmp
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((l <= -5.3e-61) || (~((l <= -4e-182)) && ((l <= 3e-248) || ~(((l <= 3.8e-227) || (~((l <= 5.2e-214)) && (l <= 3.6e-111)))))))
		tmp = pi * l;
	else
		tmp = (pi / F) * (-l / F);
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[l, -5.3e-61], And[N[Not[LessEqual[l, -4e-182]], $MachinePrecision], Or[LessEqual[l, 3e-248], N[Not[Or[LessEqual[l, 3.8e-227], And[N[Not[LessEqual[l, 5.2e-214]], $MachinePrecision], LessEqual[l, 3.6e-111]]]], $MachinePrecision]]]], N[(Pi * l), $MachinePrecision], N[(N[(Pi / F), $MachinePrecision] * N[((-l) / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.3 \cdot 10^{-61} \lor \neg \left(\ell \leq -4 \cdot 10^{-182}\right) \land \left(\ell \leq 3 \cdot 10^{-248} \lor \neg \left(\ell \leq 3.8 \cdot 10^{-227} \lor \neg \left(\ell \leq 5.2 \cdot 10^{-214}\right) \land \ell \leq 3.6 \cdot 10^{-111}\right)\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -5.3e-61 or -4.0000000000000002e-182 < l < 3.00000000000000014e-248 or 3.8000000000000001e-227 < l < 5.2e-214 or 3.6000000000000001e-111 < l

    1. Initial program 73.9%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg73.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/74.2%

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{{F}^{2}}\right)} \]
    5. Step-by-step derivation
      1. unpow260.7%

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Taylor expanded in F around inf 90.2%

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

    if -5.3e-61 < l < -4.0000000000000002e-182 or 3.00000000000000014e-248 < l < 3.8000000000000001e-227 or 5.2e-214 < l < 3.6000000000000001e-111

    1. Initial program 81.0%

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Step-by-step derivation
      1. sqr-neg81.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/85.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Step-by-step derivation
      1. associate-/r*81.0%

        \[\leadsto \ell \cdot \left(\pi - \color{blue}{\frac{\frac{\pi}{F}}{F}}\right) \]
      2. div-inv81.0%

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

      \[\leadsto \ell \cdot \left(\pi - \color{blue}{\frac{\pi}{F} \cdot \frac{1}{F}}\right) \]
    9. Taylor expanded in F around 0 57.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.3 \cdot 10^{-61} \lor \neg \left(\ell \leq -4 \cdot 10^{-182}\right) \land \left(\ell \leq 3 \cdot 10^{-248} \lor \neg \left(\ell \leq 3.8 \cdot 10^{-227} \lor \neg \left(\ell \leq 5.2 \cdot 10^{-214}\right) \land \ell \leq 3.6 \cdot 10^{-111}\right)\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\ \end{array} \]

Alternative 8: 73.8% 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 75.5%

    \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
  2. Step-by-step derivation
    1. sqr-neg75.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/76.8%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
  7. Taylor expanded in F around inf 76.2%

    \[\leadsto \color{blue}{\ell \cdot \pi} \]
  8. Final simplification76.2%

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

Reproduce

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