VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.0% → 98.9%
Time: 45.1s
Alternatives: 8
Speedup: 1.0×

Specification

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

\\
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 76.0% 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.9% accurate, 0.1× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := \sin \left(\pi \cdot l\_m\right)\\ t_1 := \cos \left(\pi \cdot l\_m\right)\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l\_m \leq 2000000000:\\ \;\;\;\;\pi \cdot l\_m - \frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan \left(\pi \cdot l\_m\right)\right)\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l\_m - \mathsf{expm1}\left(\frac{-0.5 \cdot \frac{{t\_0}^{2}}{{F}^{2} \cdot {t\_1}^{2}} + \frac{t\_0}{t\_1}}{{F}^{2}}\right)\\ \end{array} \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (let* ((t_0 (sin (* PI l_m))) (t_1 (cos (* PI l_m))))
   (*
    l_s
    (if (<= (* PI l_m) 2000000000.0)
      (- (* PI l_m) (/ (/ (log1p (expm1 (tan (* PI l_m)))) F) F))
      (-
       (* PI l_m)
       (expm1
        (/
         (+
          (* -0.5 (/ (pow t_0 2.0) (* (pow F 2.0) (pow t_1 2.0))))
          (/ t_0 t_1))
         (pow F 2.0))))))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double t_0 = sin((((double) M_PI) * l_m));
	double t_1 = cos((((double) M_PI) * l_m));
	double tmp;
	if ((((double) M_PI) * l_m) <= 2000000000.0) {
		tmp = (((double) M_PI) * l_m) - ((log1p(expm1(tan((((double) M_PI) * l_m)))) / F) / F);
	} else {
		tmp = (((double) M_PI) * l_m) - expm1((((-0.5 * (pow(t_0, 2.0) / (pow(F, 2.0) * pow(t_1, 2.0)))) + (t_0 / t_1)) / pow(F, 2.0)));
	}
	return l_s * tmp;
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double t_0 = Math.sin((Math.PI * l_m));
	double t_1 = Math.cos((Math.PI * l_m));
	double tmp;
	if ((Math.PI * l_m) <= 2000000000.0) {
		tmp = (Math.PI * l_m) - ((Math.log1p(Math.expm1(Math.tan((Math.PI * l_m)))) / F) / F);
	} else {
		tmp = (Math.PI * l_m) - Math.expm1((((-0.5 * (Math.pow(t_0, 2.0) / (Math.pow(F, 2.0) * Math.pow(t_1, 2.0)))) + (t_0 / t_1)) / Math.pow(F, 2.0)));
	}
	return l_s * tmp;
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	t_0 = math.sin((math.pi * l_m))
	t_1 = math.cos((math.pi * l_m))
	tmp = 0
	if (math.pi * l_m) <= 2000000000.0:
		tmp = (math.pi * l_m) - ((math.log1p(math.expm1(math.tan((math.pi * l_m)))) / F) / F)
	else:
		tmp = (math.pi * l_m) - math.expm1((((-0.5 * (math.pow(t_0, 2.0) / (math.pow(F, 2.0) * math.pow(t_1, 2.0)))) + (t_0 / t_1)) / math.pow(F, 2.0)))
	return l_s * tmp
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	t_0 = sin(Float64(pi * l_m))
	t_1 = cos(Float64(pi * l_m))
	tmp = 0.0
	if (Float64(pi * l_m) <= 2000000000.0)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(log1p(expm1(tan(Float64(pi * l_m)))) / F) / F));
	else
		tmp = Float64(Float64(pi * l_m) - expm1(Float64(Float64(Float64(-0.5 * Float64((t_0 ^ 2.0) / Float64((F ^ 2.0) * (t_1 ^ 2.0)))) + Float64(t_0 / t_1)) / (F ^ 2.0))));
	end
	return Float64(l_s * tmp)
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := Block[{t$95$0 = N[Sin[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]}, N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 2000000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Log[1 + N[(Exp[N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(Exp[N[(N[(N[(-0.5 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / N[(N[Power[F, 2.0], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
\begin{array}{l}
t_0 := \sin \left(\pi \cdot l\_m\right)\\
t_1 := \cos \left(\pi \cdot l\_m\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l\_m \leq 2000000000:\\
\;\;\;\;\pi \cdot l\_m - \frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan \left(\pi \cdot l\_m\right)\right)\right)}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot l\_m - \mathsf{expm1}\left(\frac{-0.5 \cdot \frac{{t\_0}^{2}}{{F}^{2} \cdot {t\_1}^{2}} + \frac{t\_0}{t\_1}}{{F}^{2}}\right)\\


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

    1. Initial program 81.5%

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

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

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

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

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

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

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

    if 2e9 < (*.f64 (PI.f64) l)

    1. Initial program 59.0%

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

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

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

        \[\leadsto \pi \cdot \ell - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\right)\right)} \]
      4. div-inv55.8%

        \[\leadsto \pi \cdot \ell - \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{F \cdot F}}\right)\right) \]
      5. pow255.8%

        \[\leadsto \pi \cdot \ell - \mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{{F}^{2}}}\right)\right) \]
      6. pow-flip55.8%

        \[\leadsto \pi \cdot \ell - \mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(\pi \cdot \ell\right) \cdot \color{blue}{{F}^{\left(-2\right)}}\right)\right) \]
      7. metadata-eval55.8%

        \[\leadsto \pi \cdot \ell - \mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(\pi \cdot \ell\right) \cdot {F}^{\color{blue}{-2}}\right)\right) \]
    4. Applied egg-rr55.8%

      \[\leadsto \pi \cdot \ell - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(\pi \cdot \ell\right) \cdot {F}^{-2}\right)\right)} \]
    5. Taylor expanded in F around inf 97.9%

      \[\leadsto \pi \cdot \ell - \mathsf{expm1}\left(\color{blue}{\frac{-0.5 \cdot \frac{{\sin \left(\ell \cdot \pi\right)}^{2}}{{F}^{2} \cdot {\cos \left(\ell \cdot \pi\right)}^{2}} + \frac{\sin \left(\ell \cdot \pi\right)}{\cos \left(\ell \cdot \pi\right)}}{{F}^{2}}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq 2000000000:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan \left(\pi \cdot \ell\right)\right)\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \mathsf{expm1}\left(\frac{-0.5 \cdot \frac{{\sin \left(\pi \cdot \ell\right)}^{2}}{{F}^{2} \cdot {\cos \left(\pi \cdot \ell\right)}^{2}} + \frac{\sin \left(\pi \cdot \ell\right)}{\cos \left(\pi \cdot \ell\right)}}{{F}^{2}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 96.5% accurate, 0.2× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{1}{-1 - {l\_m}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + {l\_m}^{2} \cdot \left(-0.001388888888888889 \cdot \left({l\_m}^{2} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot {\pi}^{4}\right)\right)}}{F}}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (+
   (* PI l_m)
   (/
    (/
     (*
      (sin (* PI l_m))
      (/
       1.0
       (-
        -1.0
        (*
         (pow l_m 2.0)
         (+
          (* -0.5 (pow PI 2.0))
          (*
           (pow l_m 2.0)
           (+
            (* -0.001388888888888889 (* (pow l_m 2.0) (pow PI 6.0)))
            (* 0.041666666666666664 (pow PI 4.0)))))))))
     F)
    F))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) + (((sin((((double) M_PI) * l_m)) * (1.0 / (-1.0 - (pow(l_m, 2.0) * ((-0.5 * pow(((double) M_PI), 2.0)) + (pow(l_m, 2.0) * ((-0.001388888888888889 * (pow(l_m, 2.0) * pow(((double) M_PI), 6.0))) + (0.041666666666666664 * pow(((double) M_PI), 4.0))))))))) / F) / F));
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) + (((Math.sin((Math.PI * l_m)) * (1.0 / (-1.0 - (Math.pow(l_m, 2.0) * ((-0.5 * Math.pow(Math.PI, 2.0)) + (Math.pow(l_m, 2.0) * ((-0.001388888888888889 * (Math.pow(l_m, 2.0) * Math.pow(Math.PI, 6.0))) + (0.041666666666666664 * Math.pow(Math.PI, 4.0))))))))) / F) / F));
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) + (((math.sin((math.pi * l_m)) * (1.0 / (-1.0 - (math.pow(l_m, 2.0) * ((-0.5 * math.pow(math.pi, 2.0)) + (math.pow(l_m, 2.0) * ((-0.001388888888888889 * (math.pow(l_m, 2.0) * math.pow(math.pi, 6.0))) + (0.041666666666666664 * math.pow(math.pi, 4.0))))))))) / F) / F))
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) + Float64(Float64(Float64(sin(Float64(pi * l_m)) * Float64(1.0 / Float64(-1.0 - Float64((l_m ^ 2.0) * Float64(Float64(-0.5 * (pi ^ 2.0)) + Float64((l_m ^ 2.0) * Float64(Float64(-0.001388888888888889 * Float64((l_m ^ 2.0) * (pi ^ 6.0))) + Float64(0.041666666666666664 * (pi ^ 4.0))))))))) / F) / F)))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) + (((sin((pi * l_m)) * (1.0 / (-1.0 - ((l_m ^ 2.0) * ((-0.5 * (pi ^ 2.0)) + ((l_m ^ 2.0) * ((-0.001388888888888889 * ((l_m ^ 2.0) * (pi ^ 6.0))) + (0.041666666666666664 * (pi ^ 4.0))))))))) / F) / F));
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(-1.0 - N[(N[Power[l$95$m, 2.0], $MachinePrecision] * N[(N[(-0.5 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[l$95$m, 2.0], $MachinePrecision] * N[(N[(-0.001388888888888889 * N[(N[Power[l$95$m, 2.0], $MachinePrecision] * N[Power[Pi, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{1}{-1 - {l\_m}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + {l\_m}^{2} \cdot \left(-0.001388888888888889 \cdot \left({l\_m}^{2} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot {\pi}^{4}\right)\right)}}{F}}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
  7. Step-by-step derivation
    1. add-cbrt-cube81.7%

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  8. Applied egg-rr81.7%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  9. Taylor expanded in l around 0 96.1%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{1 + {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + {\ell}^{2} \cdot \left(-0.001388888888888889 \cdot \left({\ell}^{2} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot {\pi}^{4}\right)\right)}}}{F}}{F} \]
  10. Final simplification96.1%

    \[\leadsto \pi \cdot \ell + \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{-1 - {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + {\ell}^{2} \cdot \left(-0.001388888888888889 \cdot \left({\ell}^{2} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot {\pi}^{4}\right)\right)}}{F}}{F} \]
  11. Add Preprocessing

Alternative 3: 95.3% accurate, 0.2× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{1}{-1 - {l\_m}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + 0.041666666666666664 \cdot \left({l\_m}^{2} \cdot {\pi}^{4}\right)\right)}}{F}}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (+
   (* PI l_m)
   (/
    (/
     (*
      (sin (* PI l_m))
      (/
       1.0
       (-
        -1.0
        (*
         (pow l_m 2.0)
         (+
          (* -0.5 (pow PI 2.0))
          (* 0.041666666666666664 (* (pow l_m 2.0) (pow PI 4.0))))))))
     F)
    F))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) + (((sin((((double) M_PI) * l_m)) * (1.0 / (-1.0 - (pow(l_m, 2.0) * ((-0.5 * pow(((double) M_PI), 2.0)) + (0.041666666666666664 * (pow(l_m, 2.0) * pow(((double) M_PI), 4.0)))))))) / F) / F));
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) + (((Math.sin((Math.PI * l_m)) * (1.0 / (-1.0 - (Math.pow(l_m, 2.0) * ((-0.5 * Math.pow(Math.PI, 2.0)) + (0.041666666666666664 * (Math.pow(l_m, 2.0) * Math.pow(Math.PI, 4.0)))))))) / F) / F));
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) + (((math.sin((math.pi * l_m)) * (1.0 / (-1.0 - (math.pow(l_m, 2.0) * ((-0.5 * math.pow(math.pi, 2.0)) + (0.041666666666666664 * (math.pow(l_m, 2.0) * math.pow(math.pi, 4.0)))))))) / F) / F))
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) + Float64(Float64(Float64(sin(Float64(pi * l_m)) * Float64(1.0 / Float64(-1.0 - Float64((l_m ^ 2.0) * Float64(Float64(-0.5 * (pi ^ 2.0)) + Float64(0.041666666666666664 * Float64((l_m ^ 2.0) * (pi ^ 4.0)))))))) / F) / F)))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) + (((sin((pi * l_m)) * (1.0 / (-1.0 - ((l_m ^ 2.0) * ((-0.5 * (pi ^ 2.0)) + (0.041666666666666664 * ((l_m ^ 2.0) * (pi ^ 4.0)))))))) / F) / F));
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(-1.0 - N[(N[Power[l$95$m, 2.0], $MachinePrecision] * N[(N[(-0.5 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[l$95$m, 2.0], $MachinePrecision] * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{1}{-1 - {l\_m}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + 0.041666666666666664 \cdot \left({l\_m}^{2} \cdot {\pi}^{4}\right)\right)}}{F}}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
  7. Step-by-step derivation
    1. add-cbrt-cube81.7%

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  8. Applied egg-rr81.7%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  9. Taylor expanded in l around 0 94.1%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{1 + {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + 0.041666666666666664 \cdot \left({\ell}^{2} \cdot {\pi}^{4}\right)\right)}}}{F}}{F} \]
  10. Final simplification94.1%

    \[\leadsto \pi \cdot \ell + \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{-1 - {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + 0.041666666666666664 \cdot \left({\ell}^{2} \cdot {\pi}^{4}\right)\right)}}{F}}{F} \]
  11. Add Preprocessing

Alternative 4: 91.7% accurate, 0.4× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{-1}{\mathsf{fma}\left(-0.5, {\left(\pi \cdot l\_m\right)}^{2}, 1\right)}}{F}}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (+
   (* PI l_m)
   (/
    (/ (* (sin (* PI l_m)) (/ -1.0 (fma -0.5 (pow (* PI l_m) 2.0) 1.0))) F)
    F))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) + (((sin((((double) M_PI) * l_m)) * (-1.0 / fma(-0.5, pow((((double) M_PI) * l_m), 2.0), 1.0))) / F) / F));
}
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) + Float64(Float64(Float64(sin(Float64(pi * l_m)) * Float64(-1.0 / fma(-0.5, (Float64(pi * l_m) ^ 2.0), 1.0))) / F) / F)))
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(-0.5 * N[Power[N[(Pi * l$95$m), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{-1}{\mathsf{fma}\left(-0.5, {\left(\pi \cdot l\_m\right)}^{2}, 1\right)}}{F}}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
  7. Step-by-step derivation
    1. add-cbrt-cube81.7%

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  8. Applied egg-rr81.7%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \ell\right)}}{F}}{F} \]
  9. Taylor expanded in l around 0 91.2%

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

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

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(-0.5, {\ell}^{2} \cdot {\pi}^{2}, 1\right)}}}{F}}{F} \]
    3. *-commutative91.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, \color{blue}{{\pi}^{2} \cdot {\ell}^{2}}, 1\right)}}{F}}{F} \]
    4. unpow291.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, \color{blue}{\left(\pi \cdot \pi\right)} \cdot {\ell}^{2}, 1\right)}}{F}}{F} \]
    5. unpow291.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, \left(\pi \cdot \pi\right) \cdot \color{blue}{\left(\ell \cdot \ell\right)}, 1\right)}}{F}}{F} \]
    6. swap-sqr91.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, \color{blue}{\left(\pi \cdot \ell\right) \cdot \left(\pi \cdot \ell\right)}, 1\right)}}{F}}{F} \]
    7. unpow291.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, \color{blue}{{\left(\pi \cdot \ell\right)}^{2}}, 1\right)}}{F}}{F} \]
    8. *-commutative91.2%

      \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\mathsf{fma}\left(-0.5, {\color{blue}{\left(\ell \cdot \pi\right)}}^{2}, 1\right)}}{F}}{F} \]
  11. Simplified91.2%

    \[\leadsto \pi \cdot \ell - \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(-0.5, {\left(\ell \cdot \pi\right)}^{2}, 1\right)}}}{F}}{F} \]
  12. Final simplification91.2%

    \[\leadsto \pi \cdot \ell + \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{-1}{\mathsf{fma}\left(-0.5, {\left(\pi \cdot \ell\right)}^{2}, 1\right)}}{F}}{F} \]
  13. Add Preprocessing

Alternative 5: 82.0% accurate, 0.5× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{-1}{\cos \left(\pi \cdot l\_m\right)}}{F}}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (+ (* PI l_m) (/ (/ (* (sin (* PI l_m)) (/ -1.0 (cos (* PI l_m)))) F) F))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) + (((sin((((double) M_PI) * l_m)) * (-1.0 / cos((((double) M_PI) * l_m)))) / F) / F));
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) + (((Math.sin((Math.PI * l_m)) * (-1.0 / Math.cos((Math.PI * l_m)))) / F) / F));
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) + (((math.sin((math.pi * l_m)) * (-1.0 / math.cos((math.pi * l_m)))) / F) / F))
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) + Float64(Float64(Float64(sin(Float64(pi * l_m)) * Float64(-1.0 / cos(Float64(pi * l_m)))) / F) / F)))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) + (((sin((pi * l_m)) * (-1.0 / cos((pi * l_m)))) / F) / F));
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[Cos[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m + \frac{\frac{\sin \left(\pi \cdot l\_m\right) \cdot \frac{-1}{\cos \left(\pi \cdot l\_m\right)}}{F}}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \frac{\frac{\color{blue}{\sin \left(\pi \cdot \ell\right) \cdot \frac{1}{\cos \left(\pi \cdot \ell\right)}}}{F}}{F} \]
  7. Final simplification81.6%

    \[\leadsto \pi \cdot \ell + \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{-1}{\cos \left(\pi \cdot \ell\right)}}{F}}{F} \]
  8. Add Preprocessing

Alternative 6: 82.0% accurate, 1.0× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \begin{array}{l} \mathbf{if}\;\pi \cdot l\_m \leq 2 \cdot 10^{-26}:\\ \;\;\;\;\pi \cdot l\_m - \frac{\frac{l\_m}{F}}{\frac{F}{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot l\_m - \frac{\tan \left(\pi \cdot l\_m\right)}{F \cdot F}\\ \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (*
  l_s
  (if (<= (* PI l_m) 2e-26)
    (- (* PI l_m) (/ (/ l_m F) (/ F PI)))
    (- (* PI l_m) (/ (tan (* PI l_m)) (* F F))))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	double tmp;
	if ((((double) M_PI) * l_m) <= 2e-26) {
		tmp = (((double) M_PI) * l_m) - ((l_m / F) / (F / ((double) M_PI)));
	} else {
		tmp = (((double) M_PI) * l_m) - (tan((((double) M_PI) * l_m)) / (F * F));
	}
	return l_s * tmp;
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	double tmp;
	if ((Math.PI * l_m) <= 2e-26) {
		tmp = (Math.PI * l_m) - ((l_m / F) / (F / Math.PI));
	} else {
		tmp = (Math.PI * l_m) - (Math.tan((Math.PI * l_m)) / (F * F));
	}
	return l_s * tmp;
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	tmp = 0
	if (math.pi * l_m) <= 2e-26:
		tmp = (math.pi * l_m) - ((l_m / F) / (F / math.pi))
	else:
		tmp = (math.pi * l_m) - (math.tan((math.pi * l_m)) / (F * F))
	return l_s * tmp
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	tmp = 0.0
	if (Float64(pi * l_m) <= 2e-26)
		tmp = Float64(Float64(pi * l_m) - Float64(Float64(l_m / F) / Float64(F / pi)));
	else
		tmp = Float64(Float64(pi * l_m) - Float64(tan(Float64(pi * l_m)) / Float64(F * F)));
	end
	return Float64(l_s * tmp)
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp_2 = code(l_s, F, l_m)
	tmp = 0.0;
	if ((pi * l_m) <= 2e-26)
		tmp = (pi * l_m) - ((l_m / F) / (F / pi));
	else
		tmp = (pi * l_m) - (tan((pi * l_m)) / (F * F));
	end
	tmp_2 = l_s * tmp;
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 2e-26], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / F), $MachinePrecision] / N[(F / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l\_m \leq 2 \cdot 10^{-26}:\\
\;\;\;\;\pi \cdot l\_m - \frac{\frac{l\_m}{F}}{\frac{F}{\pi}}\\

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


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

    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. *-commutative81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-26 < (*.f64 (PI.f64) l)

    1. Initial program 63.1%

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

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

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

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

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

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

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

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

Alternative 7: 82.0% accurate, 1.0× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m - \frac{\frac{\tan \left(\pi \cdot l\_m\right)}{F}}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (* l_s (- (* PI l_m) (/ (/ (tan (* PI l_m)) F) F))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) - ((tan((((double) M_PI) * l_m)) / F) / F));
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) - ((Math.tan((Math.PI * l_m)) / F) / F));
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) - ((math.tan((math.pi * l_m)) / F) / F))
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) - Float64(Float64(tan(Float64(pi * l_m)) / F) / F)))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) - ((tan((pi * l_m)) / F) / F));
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m - \frac{\frac{\tan \left(\pi \cdot l\_m\right)}{F}}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

Alternative 8: 75.1% accurate, 10.3× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\pi \cdot l\_m - \frac{l\_m}{F} \cdot \frac{\pi}{F}\right) \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (* l_s (- (* PI l_m) (* (/ l_m F) (/ PI F)))))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
	return l_s * ((((double) M_PI) * l_m) - ((l_m / F) * (((double) M_PI) / F)));
}
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
	return l_s * ((Math.PI * l_m) - ((l_m / F) * (Math.PI / F)));
}
l\_m = math.fabs(l)
l\_s = math.copysign(1.0, l)
def code(l_s, F, l_m):
	return l_s * ((math.pi * l_m) - ((l_m / F) * (math.pi / F)))
l\_m = abs(l)
l\_s = copysign(1.0, l)
function code(l_s, F, l_m)
	return Float64(l_s * Float64(Float64(pi * l_m) - Float64(Float64(l_m / F) * Float64(pi / F))))
end
l\_m = abs(l);
l\_s = sign(l) * abs(1.0);
function tmp = code(l_s, F, l_m)
	tmp = l_s * ((pi * l_m) - ((l_m / F) * (pi / F)));
end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(l$95$m / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
l\_s \cdot \left(\pi \cdot l\_m - \frac{l\_m}{F} \cdot \frac{\pi}{F}\right)
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F} \]
  9. Add Preprocessing

Reproduce

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