VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.7% → 99.0%
Time: 12.2s
Alternatives: 9
Speedup: 1.5×

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 9 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.7% 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 -1 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 40000000000\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) -1e+17) (not (<= (* PI l) 40000000000.0)))
   (* PI l)
   (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -1e+17) || !((((double) M_PI) * l) <= 40000000000.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) <= -1e+17) || !((Math.PI * l) <= 40000000000.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) <= -1e+17) or not ((math.pi * l) <= 40000000000.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) <= -1e+17) || !(Float64(pi * l) <= 40000000000.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) <= -1e+17) || ~(((pi * l) <= 40000000000.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], -1e+17], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 40000000000.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 -1 \cdot 10^{+17} \lor \neg \left(\pi \cdot \ell \leq 40000000000\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) < -1e17 or 4e10 < (*.f64 (PI.f64) l)

    1. Initial program 62.3%

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

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

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

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

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

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

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

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

    if -1e17 < (*.f64 (PI.f64) l) < 4e10

    1. Initial program 85.5%

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

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

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

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

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

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

Alternative 2: 98.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -200000000000 \lor \neg \left(\pi \cdot \ell \leq 40000000000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

    if -2e11 < (*.f64 (PI.f64) l) < 4e10

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 92.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.75e10 or 6.7e10 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

    if -1.75e10 < l < 6.7e10

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\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 (<= l -17500000000.0) (not (<= l 67000000000.0)))
   (* PI l)
   (- (* PI l) (* PI (/ l (* F F))))))
double code(double F, double l) {
	double tmp;
	if ((l <= -17500000000.0) || !(l <= 67000000000.0)) {
		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 ((l <= -17500000000.0) || !(l <= 67000000000.0)) {
		tmp = Math.PI * l;
	} else {
		tmp = (Math.PI * l) - (Math.PI * (l / (F * F)));
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (l <= -17500000000.0) or not (l <= 67000000000.0):
		tmp = math.pi * l
	else:
		tmp = (math.pi * l) - (math.pi * (l / (F * F)))
	return tmp
function code(F, l)
	tmp = 0.0
	if ((l <= -17500000000.0) || !(l <= 67000000000.0))
		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 ((l <= -17500000000.0) || ~((l <= 67000000000.0)))
		tmp = pi * l;
	else
		tmp = (pi * l) - (pi * (l / (F * F)));
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[l, -17500000000.0], N[Not[LessEqual[l, 67000000000.0]], $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}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\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 l < -1.75e10 or 6.7e10 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

    if -1.75e10 < l < 6.7e10

    1. Initial program 85.3%

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

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

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

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

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

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

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

Alternative 5: 98.2% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.75e10 or 6.7e10 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

    if -1.75e10 < l < 6.7e10

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 92.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\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 (<= l -17500000000.0) (not (<= l 67000000000.0)))
   (* PI l)
   (* l (- PI (/ PI (* F F))))))
double code(double F, double l) {
	double tmp;
	if ((l <= -17500000000.0) || !(l <= 67000000000.0)) {
		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 ((l <= -17500000000.0) || !(l <= 67000000000.0)) {
		tmp = Math.PI * l;
	} else {
		tmp = l * (Math.PI - (Math.PI / (F * F)));
	}
	return tmp;
}
def code(F, l):
	tmp = 0
	if (l <= -17500000000.0) or not (l <= 67000000000.0):
		tmp = math.pi * l
	else:
		tmp = l * (math.pi - (math.pi / (F * F)))
	return tmp
function code(F, l)
	tmp = 0.0
	if ((l <= -17500000000.0) || !(l <= 67000000000.0))
		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 ((l <= -17500000000.0) || ~((l <= 67000000000.0)))
		tmp = pi * l;
	else
		tmp = l * (pi - (pi / (F * F)));
	end
	tmp_2 = tmp;
end
code[F_, l_] := If[Or[LessEqual[l, -17500000000.0], N[Not[LessEqual[l, 67000000000.0]], $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}\;\ell \leq -17500000000 \lor \neg \left(\ell \leq 67000000000\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 l < -1.75e10 or 6.7e10 < l

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

    if -1.75e10 < l < 6.7e10

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

Alternative 7: 73.6% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-5} \lor \neg \left(\ell \leq -1.55 \cdot 10^{-109}\right) \land \left(\ell \leq 2.6 \cdot 10^{-126} \lor \neg \left(\ell \leq 3 \cdot 10^{-50}\right)\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.00000000000000008e-5 or -1.55e-109 < l < 2.59999999999999999e-126 or 2.9999999999999999e-50 < l

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

    if -1.00000000000000008e-5 < l < -1.55e-109 or 2.59999999999999999e-126 < l < 2.9999999999999999e-50

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{-5} \lor \neg \left(\ell \leq -1.55 \cdot 10^{-109}\right) \land \left(\ell \leq 2.6 \cdot 10^{-126} \lor \neg \left(\ell \leq 3 \cdot 10^{-50}\right)\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \frac{-\pi}{F \cdot F}\\ \end{array} \]

Alternative 8: 73.6% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7 \cdot 10^{-9} \lor \neg \left(\ell \leq -1.5 \cdot 10^{-109} \lor \neg \left(\ell \leq 1.5 \cdot 10^{-127}\right) \land \ell \leq 2.05 \cdot 10^{-50}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6.9999999999999998e-9 or -1.50000000000000011e-109 < l < 1.50000000000000004e-127 or 2.04999999999999993e-50 < l

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

    if -6.9999999999999998e-9 < l < -1.50000000000000011e-109 or 1.50000000000000004e-127 < l < 2.04999999999999993e-50

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \ell \cdot \left(-\frac{1}{\frac{\color{blue}{{F}^{2}}}{\pi}}\right) \]
      8. associate-/r/70.2%

        \[\leadsto \ell \cdot \left(-\color{blue}{\frac{1}{{F}^{2}} \cdot \pi}\right) \]
      9. /-rgt-identity70.2%

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

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

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

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

        \[\leadsto \ell \cdot \left(-\left(\color{blue}{{F}^{-1}} \cdot \frac{1}{F}\right) \cdot \pi\right) \]
      14. unpow-170.1%

        \[\leadsto \ell \cdot \left(-\left({F}^{-1} \cdot \color{blue}{{F}^{-1}}\right) \cdot \pi\right) \]
      15. pow-sqr70.3%

        \[\leadsto \ell \cdot \left(-\color{blue}{{F}^{\left(2 \cdot -1\right)}} \cdot \pi\right) \]
      16. metadata-eval70.3%

        \[\leadsto \ell \cdot \left(-{F}^{\color{blue}{-2}} \cdot \pi\right) \]
      17. distribute-rgt-neg-in70.3%

        \[\leadsto \ell \cdot \color{blue}{\left({F}^{-2} \cdot \left(-\pi\right)\right)} \]
    9. Simplified70.3%

      \[\leadsto \ell \cdot \color{blue}{\left({F}^{-2} \cdot \left(-\pi\right)\right)} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

        \[\leadsto \ell \cdot \left({F}^{-2} \cdot \color{blue}{\sqrt{\left(-\pi\right) \cdot \left(-\pi\right)}}\right) \]
      3. sqr-neg1.7%

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

        \[\leadsto \ell \cdot \left({F}^{-2} \cdot \color{blue}{\left(\sqrt{\pi} \cdot \sqrt{\pi}\right)}\right) \]
      5. add-sqr-sqrt1.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \ell \cdot \frac{-\frac{\color{blue}{\sqrt{-\pi} \cdot \sqrt{-\pi}}}{-F}}{-F} \]
      15. sqrt-unprod70.4%

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

        \[\leadsto \ell \cdot \frac{-\frac{\sqrt{\color{blue}{\pi \cdot \pi}}}{-F}}{-F} \]
      17. sqrt-unprod69.8%

        \[\leadsto \ell \cdot \frac{-\frac{\color{blue}{\sqrt{\pi} \cdot \sqrt{\pi}}}{-F}}{-F} \]
      18. add-sqr-sqrt70.4%

        \[\leadsto \ell \cdot \frac{-\frac{\color{blue}{\pi}}{-F}}{-F} \]
      19. distribute-frac-neg70.4%

        \[\leadsto \ell \cdot \frac{\color{blue}{\frac{-\pi}{-F}}}{-F} \]
      20. frac-2neg70.4%

        \[\leadsto \ell \cdot \frac{\color{blue}{\frac{\pi}{F}}}{-F} \]
    11. Applied egg-rr70.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7 \cdot 10^{-9} \lor \neg \left(\ell \leq -1.5 \cdot 10^{-109} \lor \neg \left(\ell \leq 1.5 \cdot 10^{-127}\right) \land \ell \leq 2.05 \cdot 10^{-50}\right):\\ \;\;\;\;\pi \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \frac{\frac{\pi}{F}}{-F}\\ \end{array} \]

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\ell \cdot \pi} \]
  8. Final simplification71.7%

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

Reproduce

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