VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.3% → 99.2%
Time: 16.4s
Alternatives: 8
Speedup: 2.7×

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

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+16} \lor \neg \left(\pi \cdot \ell \leq 2000000000000\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) < -2e16 or 2e12 < (*.f64 (PI.f64) l)

    1. Initial program 56.4%

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

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

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

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

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

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

      \[\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 -2e16 < (*.f64 (PI.f64) l) < 2e12

    1. Initial program 88.4%

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

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

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

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

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

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

Alternative 2: 93.1% accurate, 0.7× speedup?

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

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


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

    1. Initial program 56.8%

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

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

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

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

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

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

      \[\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 -2e16 < (*.f64 (PI.f64) l) < 5e5

    1. Initial program 88.3%

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

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

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

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

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

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

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

Alternative 3: 98.4% accurate, 0.7× speedup?

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

    1. Initial program 56.8%

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

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

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

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

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

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

      \[\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 -2e16 < (*.f64 (PI.f64) l) < 5e5

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+16} \lor \neg \left(\pi \cdot \ell \leq 500000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.8%

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

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

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

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

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

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

      \[\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 -2e16 < (*.f64 (PI.f64) l) < 5e5

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 92.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+16} \lor \neg \left(\pi \cdot \ell \leq 500000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


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

    1. Initial program 56.8%

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

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

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

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

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

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

      \[\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 -2e16 < (*.f64 (PI.f64) l) < 5e5

    1. Initial program 88.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Step-by-step derivation
      1. sub-neg86.9%

        \[\leadsto \ell \cdot \color{blue}{\left(\pi + \left(-\frac{\pi}{F \cdot F}\right)\right)} \]
      2. distribute-lft-in86.9%

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

        \[\leadsto \color{blue}{\pi \cdot \ell} + \ell \cdot \left(-\frac{\pi}{F \cdot F}\right) \]
      4. div-inv86.8%

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

        \[\leadsto \pi \cdot \ell + \ell \cdot \left(-\pi \cdot \frac{1}{\color{blue}{{F}^{2}}}\right) \]
      6. pow-flip86.9%

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

        \[\leadsto \pi \cdot \ell + \ell \cdot \left(-\pi \cdot {F}^{\color{blue}{-2}}\right) \]
      8. distribute-rgt-neg-in86.9%

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

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

        \[\leadsto \pi \cdot \ell + \color{blue}{\left(\pi \cdot \left(-{F}^{-2}\right)\right) \cdot \ell} \]
      2. distribute-rgt-out86.9%

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

        \[\leadsto \ell \cdot \left(\pi + \color{blue}{\left(-\pi \cdot {F}^{-2}\right)}\right) \]
      4. sub-neg86.9%

        \[\leadsto \ell \cdot \color{blue}{\left(\pi - \pi \cdot {F}^{-2}\right)} \]
      5. *-rgt-identity86.9%

        \[\leadsto \ell \cdot \left(\color{blue}{\pi \cdot 1} - \pi \cdot {F}^{-2}\right) \]
      6. distribute-lft-out--86.9%

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

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

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

Alternative 6: 73.9% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 4 \cdot 10^{-163} \lor \neg \left(F \cdot F \leq 4 \cdot 10^{-16}\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 F F) < 3.99999999999999969e-163 or 3.9999999999999999e-16 < (*.f64 F F)

    1. Initial program 69.8%

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

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

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

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

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

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

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

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

    if 3.99999999999999969e-163 < (*.f64 F F) < 3.9999999999999999e-16

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -\color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
    11. Step-by-step derivation
      1. /-rgt-identity76.1%

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

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

        \[\leadsto -\frac{\frac{\ell}{\frac{1}{\pi}}}{\color{blue}{F \cdot F}} \]
      4. rem-square-sqrt40.7%

        \[\leadsto -\frac{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{1}{\pi}}}{F \cdot F} \]
      5. associate-*r/40.8%

        \[\leadsto -\frac{\color{blue}{\sqrt{\ell} \cdot \frac{\sqrt{\ell}}{\frac{1}{\pi}}}}{F \cdot F} \]
      6. *-commutative40.8%

        \[\leadsto -\frac{\color{blue}{\frac{\sqrt{\ell}}{\frac{1}{\pi}} \cdot \sqrt{\ell}}}{F \cdot F} \]
      7. associate-*r/40.8%

        \[\leadsto -\color{blue}{\frac{\sqrt{\ell}}{\frac{1}{\pi}} \cdot \frac{\sqrt{\ell}}{F \cdot F}} \]
      8. associate-/r/40.8%

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

        \[\leadsto -\left(\color{blue}{\sqrt{\ell}} \cdot \pi\right) \cdot \frac{\sqrt{\ell}}{F \cdot F} \]
      10. *-commutative40.8%

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

        \[\leadsto -\color{blue}{\pi \cdot \left(\sqrt{\ell} \cdot \frac{\sqrt{\ell}}{F \cdot F}\right)} \]
      12. *-commutative40.8%

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

        \[\leadsto -\pi \cdot \color{blue}{\frac{\sqrt{\ell} \cdot \sqrt{\ell}}{F \cdot F}} \]
      14. rem-square-sqrt76.1%

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

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

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

Alternative 7: 93.0% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.7 \cdot 10^{+14} \lor \neg \left(\ell \leq 520000000000\right):\\
\;\;\;\;\pi \cdot \ell\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.7e14 or 5.2e11 < l

    1. Initial program 56.8%

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

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

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

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

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

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

      \[\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 -4.7e14 < l < 5.2e11

    1. Initial program 88.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)} \]
    7. Step-by-step derivation
      1. sub-neg86.9%

        \[\leadsto \ell \cdot \color{blue}{\left(\pi + \left(-\frac{\pi}{F \cdot F}\right)\right)} \]
      2. distribute-lft-in86.9%

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

        \[\leadsto \color{blue}{\pi \cdot \ell} + \ell \cdot \left(-\frac{\pi}{F \cdot F}\right) \]
      4. div-inv86.8%

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

        \[\leadsto \pi \cdot \ell + \ell \cdot \left(-\pi \cdot \frac{1}{\color{blue}{{F}^{2}}}\right) \]
      6. pow-flip86.9%

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

        \[\leadsto \pi \cdot \ell + \ell \cdot \left(-\pi \cdot {F}^{\color{blue}{-2}}\right) \]
      8. distribute-rgt-neg-in86.9%

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

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

        \[\leadsto \pi \cdot \ell + \color{blue}{\left(\pi \cdot \left(-{F}^{-2}\right)\right) \cdot \ell} \]
      2. distribute-rgt-out86.9%

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

        \[\leadsto \ell \cdot \left(\pi + \color{blue}{\left(-\pi \cdot {F}^{-2}\right)}\right) \]
      4. sub-neg86.9%

        \[\leadsto \ell \cdot \color{blue}{\left(\pi - \pi \cdot {F}^{-2}\right)} \]
      5. *-rgt-identity86.9%

        \[\leadsto \ell \cdot \left(\color{blue}{\pi \cdot 1} - \pi \cdot {F}^{-2}\right) \]
      6. distribute-lft-out--86.9%

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

      \[\leadsto \color{blue}{\ell \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)} \]
    11. Taylor expanded in l around 0 86.8%

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

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

        \[\leadsto \color{blue}{\left(1 - \frac{1}{{F}^{2}}\right) \cdot \left(\pi \cdot \ell\right)} \]
      3. sub-neg86.8%

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

        \[\leadsto \left(1 + \color{blue}{\frac{-1}{{F}^{2}}}\right) \cdot \left(\pi \cdot \ell\right) \]
      5. metadata-eval86.8%

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

        \[\leadsto \left(1 + \frac{-1}{\color{blue}{F \cdot F}}\right) \cdot \left(\pi \cdot \ell\right) \]
      7. *-commutative86.8%

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

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

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

Alternative 8: 74.5% accurate, 3.0× speedup?

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

\\
\pi \cdot \ell
\end{array}
Derivation
  1. Initial program 73.5%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\ell \cdot \pi} \]
  8. Final simplification73.9%

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

Reproduce

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