Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3

Percentage Accurate: 50.9% → 79.0%
Time: 10.2s
Alternatives: 7
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot 4\right) \cdot y\\ \frac{x \cdot x - t_0}{x \cdot x + t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = (y * 4.0d0) * y
    code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y):
	t_0 = (y * 4.0) * y
	return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y)
	t_0 = Float64(Float64(y * 4.0) * y)
	return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
end
function tmp = code(x, y)
	t_0 = (y * 4.0) * y;
	tmp = ((x * x) - t_0) / ((x * x) + t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\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 7 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: 50.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot 4\right) \cdot y\\ \frac{x \cdot x - t_0}{x \cdot x + t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = (y * 4.0d0) * y
    code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y):
	t_0 = (y * 4.0) * y
	return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y)
	t_0 = Float64(Float64(y * 4.0) * y)
	return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
end
function tmp = code(x, y)
	t_0 = (y * 4.0) * y;
	tmp = ((x * x) - t_0) / ((x * x) + t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}

Alternative 1: 79.0% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\ \;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;{\left(\frac{{x}^{2} + {y}^{2} \cdot 4}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* x x) 4e-108)
   (log1p (+ (* 0.5 (* (pow (/ x y) 2.0) (exp -1.0))) (expm1 -1.0)))
   (if (<= (* x x) 5e+69)
     (pow
      (/ (+ (pow x 2.0) (* (pow y 2.0) 4.0)) (fma y (* y -4.0) (pow x 2.0)))
      -1.0)
     (+ 1.0 (/ -8.0 (* (/ x y) (/ x y)))))))
double code(double x, double y) {
	double tmp;
	if ((x * x) <= 4e-108) {
		tmp = log1p(((0.5 * (pow((x / y), 2.0) * exp(-1.0))) + expm1(-1.0)));
	} else if ((x * x) <= 5e+69) {
		tmp = pow(((pow(x, 2.0) + (pow(y, 2.0) * 4.0)) / fma(y, (y * -4.0), pow(x, 2.0))), -1.0);
	} else {
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(x * x) <= 4e-108)
		tmp = log1p(Float64(Float64(0.5 * Float64((Float64(x / y) ^ 2.0) * exp(-1.0))) + expm1(-1.0)));
	elseif (Float64(x * x) <= 5e+69)
		tmp = Float64(Float64((x ^ 2.0) + Float64((y ^ 2.0) * 4.0)) / fma(y, Float64(y * -4.0), (x ^ 2.0))) ^ -1.0;
	else
		tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) * Float64(x / y))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e-108], N[Log[1 + N[(N[(0.5 * N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] * N[Exp[-1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(Exp[-1.0] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+69], N[Power[N[(N[(N[Power[x, 2.0], $MachinePrecision] + N[(N[Power[y, 2.0], $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / N[(y * N[(y * -4.0), $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\
\;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\
\;\;\;\;{\left(\frac{{x}^{2} + {y}^{2} \cdot 4}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 4.00000000000000016e-108

    1. Initial program 60.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num60.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow60.4%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative60.4%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative60.4%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*60.4%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def60.4%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr60.4%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in x around 0 62.5%

      \[\leadsto {\color{blue}{\left(\left(-0.5 \cdot \frac{{x}^{2}}{{y}^{2}} + -0.125 \cdot \frac{{x}^{4}}{{y}^{4}}\right) - 1\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate--l+62.5%

        \[\leadsto {\color{blue}{\left(-0.5 \cdot \frac{{x}^{2}}{{y}^{2}} + \left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}}^{-1} \]
      2. *-commutative62.5%

        \[\leadsto {\left(\color{blue}{\frac{{x}^{2}}{{y}^{2}} \cdot -0.5} + \left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      3. fma-def62.5%

        \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(\frac{{x}^{2}}{{y}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}}^{-1} \]
      4. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\frac{\color{blue}{x \cdot x}}{{y}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      5. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\frac{x \cdot x}{\color{blue}{y \cdot y}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      6. times-frac62.5%

        \[\leadsto {\left(\mathsf{fma}\left(\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      7. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\color{blue}{{\left(\frac{x}{y}\right)}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      8. fma-neg62.5%

        \[\leadsto {\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \color{blue}{\mathsf{fma}\left(-0.125, \frac{{x}^{4}}{{y}^{4}}, -1\right)}\right)\right)}^{-1} \]
    7. Simplified87.5%

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)\right)}}^{-1} \]
    8. Step-by-step derivation
      1. log1p-expm1-u87.5%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)\right)}^{-1}\right)\right)} \]
      2. unpow-187.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)}}\right)\right) \]
    9. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)}\right)\right)} \]
    10. Taylor expanded in x around 0 80.0%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(e^{-1} + 0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}}\right) - 1}\right) \]
    11. Step-by-step derivation
      1. +-commutative80.0%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}} + e^{-1}\right)} - 1\right) \]
      2. associate--l+80.0%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}} + \left(e^{-1} - 1\right)}\right) \]
      3. associate-/l*80.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \color{blue}{\frac{{x}^{2}}{\frac{{y}^{2}}{e^{-1}}}} + \left(e^{-1} - 1\right)\right) \]
      4. associate-/r/80.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \color{blue}{\left(\frac{{x}^{2}}{{y}^{2}} \cdot e^{-1}\right)} + \left(e^{-1} - 1\right)\right) \]
      5. unpow280.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\frac{\color{blue}{x \cdot x}}{{y}^{2}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      6. unpow280.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\frac{x \cdot x}{\color{blue}{y \cdot y}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      7. times-frac88.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      8. unpow288.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\color{blue}{{\left(\frac{x}{y}\right)}^{2}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      9. expm1-def88.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \color{blue}{\mathsf{expm1}\left(-1\right)}\right) \]
    12. Simplified88.9%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)}\right) \]

    if 4.00000000000000016e-108 < (*.f64 x x) < 5.00000000000000036e69

    1. Initial program 86.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num86.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow86.0%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative86.0%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative86.0%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*86.0%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def86.0%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow286.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow286.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval86.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow286.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr86.0%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. fma-udef86.0%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot {y}^{2} + {x}^{2}}}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1} \]
      2. +-commutative86.0%

        \[\leadsto {\left(\frac{\color{blue}{{x}^{2} + 4 \cdot {y}^{2}}}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1} \]
      3. *-commutative86.0%

        \[\leadsto {\left(\frac{{x}^{2} + \color{blue}{{y}^{2} \cdot 4}}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1} \]
    6. Applied egg-rr86.0%

      \[\leadsto {\left(\frac{\color{blue}{{x}^{2} + {y}^{2} \cdot 4}}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1} \]

    if 5.00000000000000036e69 < (*.f64 x x)

    1. Initial program 26.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num26.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow26.8%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*26.8%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def26.8%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr26.8%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in y around 0 77.2%

      \[\leadsto {\color{blue}{\left(1 + 8 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8 \cdot {y}^{2}}{{x}^{2}}}\right)}^{-1} \]
      2. associate-/l*77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8}{\frac{{x}^{2}}{{y}^{2}}}}\right)}^{-1} \]
      3. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}}\right)}^{-1} \]
      4. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}}\right)}^{-1} \]
      5. times-frac82.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}\right)}^{-1} \]
      6. unpow282.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}\right)}^{-1} \]
    7. Simplified82.6%

      \[\leadsto {\color{blue}{\left(1 + \frac{8}{{\left(\frac{x}{y}\right)}^{2}}\right)}}^{-1} \]
    8. Taylor expanded in x around inf 77.2%

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8 \cdot {y}^{2}}{{x}^{2}}} \]
      2. associate-/l*77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8}{\frac{{x}^{2}}{{y}^{2}}}} \]
      3. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}} \]
      4. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}} \]
      5. times-frac83.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
      6. unpow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}} \]
    10. Simplified83.0%

      \[\leadsto \color{blue}{1 + \frac{-8}{{\left(\frac{x}{y}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. pow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
    12. Applied egg-rr83.0%

      \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\ \;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;{\left(\frac{{x}^{2} + {y}^{2} \cdot 4}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.0% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\ \;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0))))
   (if (<= (* x x) 4e-108)
     (log1p (+ (* 0.5 (* (pow (/ x y) 2.0) (exp -1.0))) (expm1 -1.0)))
     (if (<= (* x x) 5e+69)
       (/ (- (* x x) t_0) (+ (* x x) t_0))
       (+ 1.0 (/ -8.0 (* (/ x y) (/ x y))))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if ((x * x) <= 4e-108) {
		tmp = log1p(((0.5 * (pow((x / y), 2.0) * exp(-1.0))) + expm1(-1.0)));
	} else if ((x * x) <= 5e+69) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if ((x * x) <= 4e-108) {
		tmp = Math.log1p(((0.5 * (Math.pow((x / y), 2.0) * Math.exp(-1.0))) + Math.expm1(-1.0)));
	} else if ((x * x) <= 5e+69) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	}
	return tmp;
}
def code(x, y):
	t_0 = y * (y * 4.0)
	tmp = 0
	if (x * x) <= 4e-108:
		tmp = math.log1p(((0.5 * (math.pow((x / y), 2.0) * math.exp(-1.0))) + math.expm1(-1.0)))
	elif (x * x) <= 5e+69:
		tmp = ((x * x) - t_0) / ((x * x) + t_0)
	else:
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)))
	return tmp
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 4e-108)
		tmp = log1p(Float64(Float64(0.5 * Float64((Float64(x / y) ^ 2.0) * exp(-1.0))) + expm1(-1.0)));
	elseif (Float64(x * x) <= 5e+69)
		tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0));
	else
		tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) * Float64(x / y))));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 4e-108], N[Log[1 + N[(N[(0.5 * N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] * N[Exp[-1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(Exp[-1.0] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+69], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\
\;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 4.00000000000000016e-108

    1. Initial program 60.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num60.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow60.4%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative60.4%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative60.4%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*60.4%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def60.4%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval60.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow260.4%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr60.4%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in x around 0 62.5%

      \[\leadsto {\color{blue}{\left(\left(-0.5 \cdot \frac{{x}^{2}}{{y}^{2}} + -0.125 \cdot \frac{{x}^{4}}{{y}^{4}}\right) - 1\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate--l+62.5%

        \[\leadsto {\color{blue}{\left(-0.5 \cdot \frac{{x}^{2}}{{y}^{2}} + \left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}}^{-1} \]
      2. *-commutative62.5%

        \[\leadsto {\left(\color{blue}{\frac{{x}^{2}}{{y}^{2}} \cdot -0.5} + \left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      3. fma-def62.5%

        \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(\frac{{x}^{2}}{{y}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}}^{-1} \]
      4. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\frac{\color{blue}{x \cdot x}}{{y}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      5. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\frac{x \cdot x}{\color{blue}{y \cdot y}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      6. times-frac62.5%

        \[\leadsto {\left(\mathsf{fma}\left(\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      7. unpow262.5%

        \[\leadsto {\left(\mathsf{fma}\left(\color{blue}{{\left(\frac{x}{y}\right)}^{2}}, -0.5, -0.125 \cdot \frac{{x}^{4}}{{y}^{4}} - 1\right)\right)}^{-1} \]
      8. fma-neg62.5%

        \[\leadsto {\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \color{blue}{\mathsf{fma}\left(-0.125, \frac{{x}^{4}}{{y}^{4}}, -1\right)}\right)\right)}^{-1} \]
    7. Simplified87.5%

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)\right)}}^{-1} \]
    8. Step-by-step derivation
      1. log1p-expm1-u87.5%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)\right)}^{-1}\right)\right)} \]
      2. unpow-187.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)}}\right)\right) \]
    9. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, -0.5, \mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, -1\right)\right)}\right)\right)} \]
    10. Taylor expanded in x around 0 80.0%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(e^{-1} + 0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}}\right) - 1}\right) \]
    11. Step-by-step derivation
      1. +-commutative80.0%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}} + e^{-1}\right)} - 1\right) \]
      2. associate--l+80.0%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{0.5 \cdot \frac{{x}^{2} \cdot e^{-1}}{{y}^{2}} + \left(e^{-1} - 1\right)}\right) \]
      3. associate-/l*80.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \color{blue}{\frac{{x}^{2}}{\frac{{y}^{2}}{e^{-1}}}} + \left(e^{-1} - 1\right)\right) \]
      4. associate-/r/80.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \color{blue}{\left(\frac{{x}^{2}}{{y}^{2}} \cdot e^{-1}\right)} + \left(e^{-1} - 1\right)\right) \]
      5. unpow280.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\frac{\color{blue}{x \cdot x}}{{y}^{2}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      6. unpow280.0%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\frac{x \cdot x}{\color{blue}{y \cdot y}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      7. times-frac88.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      8. unpow288.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left(\color{blue}{{\left(\frac{x}{y}\right)}^{2}} \cdot e^{-1}\right) + \left(e^{-1} - 1\right)\right) \]
      9. expm1-def88.9%

        \[\leadsto \mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \color{blue}{\mathsf{expm1}\left(-1\right)}\right) \]
    12. Simplified88.9%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)}\right) \]

    if 4.00000000000000016e-108 < (*.f64 x x) < 5.00000000000000036e69

    1. Initial program 86.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing

    if 5.00000000000000036e69 < (*.f64 x x)

    1. Initial program 26.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num26.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow26.8%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*26.8%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def26.8%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr26.8%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in y around 0 77.2%

      \[\leadsto {\color{blue}{\left(1 + 8 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8 \cdot {y}^{2}}{{x}^{2}}}\right)}^{-1} \]
      2. associate-/l*77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8}{\frac{{x}^{2}}{{y}^{2}}}}\right)}^{-1} \]
      3. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}}\right)}^{-1} \]
      4. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}}\right)}^{-1} \]
      5. times-frac82.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}\right)}^{-1} \]
      6. unpow282.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}\right)}^{-1} \]
    7. Simplified82.6%

      \[\leadsto {\color{blue}{\left(1 + \frac{8}{{\left(\frac{x}{y}\right)}^{2}}\right)}}^{-1} \]
    8. Taylor expanded in x around inf 77.2%

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8 \cdot {y}^{2}}{{x}^{2}}} \]
      2. associate-/l*77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8}{\frac{{x}^{2}}{{y}^{2}}}} \]
      3. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}} \]
      4. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}} \]
      5. times-frac83.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
      6. unpow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}} \]
    10. Simplified83.0%

      \[\leadsto \color{blue}{1 + \frac{-8}{{\left(\frac{x}{y}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. pow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
    12. Applied egg-rr83.0%

      \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-108}:\\ \;\;\;\;\mathsf{log1p}\left(0.5 \cdot \left({\left(\frac{x}{y}\right)}^{2} \cdot e^{-1}\right) + \mathsf{expm1}\left(-1\right)\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 79.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-276}:\\ \;\;\;\;-1 + 0.5 \cdot t_1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{t_1}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0))) (t_1 (* (/ x y) (/ x y))))
   (if (<= (* x x) 2e-276)
     (+ -1.0 (* 0.5 t_1))
     (if (<= (* x x) 5e+69)
       (/ (- (* x x) t_0) (+ (* x x) t_0))
       (+ 1.0 (/ -8.0 t_1))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = (x / y) * (x / y);
	double tmp;
	if ((x * x) <= 2e-276) {
		tmp = -1.0 + (0.5 * t_1);
	} else if ((x * x) <= 5e+69) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (-8.0 / t_1);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y * (y * 4.0d0)
    t_1 = (x / y) * (x / y)
    if ((x * x) <= 2d-276) then
        tmp = (-1.0d0) + (0.5d0 * t_1)
    else if ((x * x) <= 5d+69) then
        tmp = ((x * x) - t_0) / ((x * x) + t_0)
    else
        tmp = 1.0d0 + ((-8.0d0) / t_1)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = (x / y) * (x / y);
	double tmp;
	if ((x * x) <= 2e-276) {
		tmp = -1.0 + (0.5 * t_1);
	} else if ((x * x) <= 5e+69) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (-8.0 / t_1);
	}
	return tmp;
}
def code(x, y):
	t_0 = y * (y * 4.0)
	t_1 = (x / y) * (x / y)
	tmp = 0
	if (x * x) <= 2e-276:
		tmp = -1.0 + (0.5 * t_1)
	elif (x * x) <= 5e+69:
		tmp = ((x * x) - t_0) / ((x * x) + t_0)
	else:
		tmp = 1.0 + (-8.0 / t_1)
	return tmp
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(x / y) * Float64(x / y))
	tmp = 0.0
	if (Float64(x * x) <= 2e-276)
		tmp = Float64(-1.0 + Float64(0.5 * t_1));
	elseif (Float64(x * x) <= 5e+69)
		tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0));
	else
		tmp = Float64(1.0 + Float64(-8.0 / t_1));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y * (y * 4.0);
	t_1 = (x / y) * (x / y);
	tmp = 0.0;
	if ((x * x) <= 2e-276)
		tmp = -1.0 + (0.5 * t_1);
	elseif ((x * x) <= 5e+69)
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	else
		tmp = 1.0 + (-8.0 / t_1);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-276], N[(-1.0 + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+69], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-276}:\\
\;\;\;\;-1 + 0.5 \cdot t_1\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{t_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 2e-276

    1. Initial program 54.3%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 82.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    4. Step-by-step derivation
      1. unpow282.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow282.9%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{y \cdot y}} - 1 \]
      3. times-frac94.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
    5. Applied egg-rr94.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]

    if 2e-276 < (*.f64 x x) < 5.00000000000000036e69

    1. Initial program 81.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing

    if 5.00000000000000036e69 < (*.f64 x x)

    1. Initial program 26.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num26.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow26.8%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative26.8%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*26.8%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def26.8%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval26.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow226.8%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr26.8%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in y around 0 77.2%

      \[\leadsto {\color{blue}{\left(1 + 8 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8 \cdot {y}^{2}}{{x}^{2}}}\right)}^{-1} \]
      2. associate-/l*77.2%

        \[\leadsto {\left(1 + \color{blue}{\frac{8}{\frac{{x}^{2}}{{y}^{2}}}}\right)}^{-1} \]
      3. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}}\right)}^{-1} \]
      4. unpow277.2%

        \[\leadsto {\left(1 + \frac{8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}}\right)}^{-1} \]
      5. times-frac82.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}\right)}^{-1} \]
      6. unpow282.6%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}\right)}^{-1} \]
    7. Simplified82.6%

      \[\leadsto {\color{blue}{\left(1 + \frac{8}{{\left(\frac{x}{y}\right)}^{2}}\right)}}^{-1} \]
    8. Taylor expanded in x around inf 77.2%

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8 \cdot {y}^{2}}{{x}^{2}}} \]
      2. associate-/l*77.2%

        \[\leadsto 1 + \color{blue}{\frac{-8}{\frac{{x}^{2}}{{y}^{2}}}} \]
      3. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}} \]
      4. unpow277.2%

        \[\leadsto 1 + \frac{-8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}} \]
      5. times-frac83.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
      6. unpow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}} \]
    10. Simplified83.0%

      \[\leadsto \color{blue}{1 + \frac{-8}{{\left(\frac{x}{y}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. pow283.0%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
    12. Applied egg-rr83.0%

      \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-276}:\\ \;\;\;\;-1 + 0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+69}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 61.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 3.3 \lor \neg \left(x \leq 2.15 \cdot 10^{+20}\right):\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x 1.1e-39)
   -1.0
   (if (or (<= x 3.3) (not (<= x 2.15e+20)))
     (+ 1.0 (/ -8.0 (* (/ x y) (/ x y))))
     -1.0)))
double code(double x, double y) {
	double tmp;
	if (x <= 1.1e-39) {
		tmp = -1.0;
	} else if ((x <= 3.3) || !(x <= 2.15e+20)) {
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 1.1d-39) then
        tmp = -1.0d0
    else if ((x <= 3.3d0) .or. (.not. (x <= 2.15d+20))) then
        tmp = 1.0d0 + ((-8.0d0) / ((x / y) * (x / y)))
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 1.1e-39) {
		tmp = -1.0;
	} else if ((x <= 3.3) || !(x <= 2.15e+20)) {
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 1.1e-39:
		tmp = -1.0
	elif (x <= 3.3) or not (x <= 2.15e+20):
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)))
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 1.1e-39)
		tmp = -1.0;
	elseif ((x <= 3.3) || !(x <= 2.15e+20))
		tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) * Float64(x / y))));
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 1.1e-39)
		tmp = -1.0;
	elseif ((x <= 3.3) || ~((x <= 2.15e+20)))
		tmp = 1.0 + (-8.0 / ((x / y) * (x / y)));
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 1.1e-39], -1.0, If[Or[LessEqual[x, 3.3], N[Not[LessEqual[x, 2.15e+20]], $MachinePrecision]], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{-39}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 3.3 \lor \neg \left(x \leq 2.15 \cdot 10^{+20}\right):\\
\;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.1e-39 or 3.2999999999999998 < x < 2.15e20

    1. Initial program 55.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 62.4%

      \[\leadsto \color{blue}{-1} \]

    if 1.1e-39 < x < 3.2999999999999998 or 2.15e20 < x

    1. Initial program 36.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num36.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow36.1%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative36.1%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative36.1%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*36.1%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def36.1%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr36.1%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in y around 0 74.1%

      \[\leadsto {\color{blue}{\left(1 + 8 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/74.1%

        \[\leadsto {\left(1 + \color{blue}{\frac{8 \cdot {y}^{2}}{{x}^{2}}}\right)}^{-1} \]
      2. associate-/l*74.1%

        \[\leadsto {\left(1 + \color{blue}{\frac{8}{\frac{{x}^{2}}{{y}^{2}}}}\right)}^{-1} \]
      3. unpow274.1%

        \[\leadsto {\left(1 + \frac{8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}}\right)}^{-1} \]
      4. unpow274.1%

        \[\leadsto {\left(1 + \frac{8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}}\right)}^{-1} \]
      5. times-frac79.7%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}\right)}^{-1} \]
      6. unpow279.7%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}\right)}^{-1} \]
    7. Simplified79.7%

      \[\leadsto {\color{blue}{\left(1 + \frac{8}{{\left(\frac{x}{y}\right)}^{2}}\right)}}^{-1} \]
    8. Taylor expanded in x around inf 74.2%

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/74.2%

        \[\leadsto 1 + \color{blue}{\frac{-8 \cdot {y}^{2}}{{x}^{2}}} \]
      2. associate-/l*74.2%

        \[\leadsto 1 + \color{blue}{\frac{-8}{\frac{{x}^{2}}{{y}^{2}}}} \]
      3. unpow274.2%

        \[\leadsto 1 + \frac{-8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}} \]
      4. unpow274.2%

        \[\leadsto 1 + \frac{-8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}} \]
      5. times-frac80.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
      6. unpow280.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}} \]
    10. Simplified80.2%

      \[\leadsto \color{blue}{1 + \frac{-8}{{\left(\frac{x}{y}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. pow280.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
    12. Applied egg-rr80.2%

      \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 3.3 \lor \neg \left(x \leq 2.15 \cdot 10^{+20}\right):\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 62.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq 8 \cdot 10^{-39} \lor \neg \left(x \leq 0.92\right) \land x \leq 2.2 \cdot 10^{+23}:\\ \;\;\;\;-1 + 0.5 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{t_0}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (/ x y) (/ x y))))
   (if (or (<= x 8e-39) (and (not (<= x 0.92)) (<= x 2.2e+23)))
     (+ -1.0 (* 0.5 t_0))
     (+ 1.0 (/ -8.0 t_0)))))
double code(double x, double y) {
	double t_0 = (x / y) * (x / y);
	double tmp;
	if ((x <= 8e-39) || (!(x <= 0.92) && (x <= 2.2e+23))) {
		tmp = -1.0 + (0.5 * t_0);
	} else {
		tmp = 1.0 + (-8.0 / t_0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x / y) * (x / y)
    if ((x <= 8d-39) .or. (.not. (x <= 0.92d0)) .and. (x <= 2.2d+23)) then
        tmp = (-1.0d0) + (0.5d0 * t_0)
    else
        tmp = 1.0d0 + ((-8.0d0) / t_0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x / y) * (x / y);
	double tmp;
	if ((x <= 8e-39) || (!(x <= 0.92) && (x <= 2.2e+23))) {
		tmp = -1.0 + (0.5 * t_0);
	} else {
		tmp = 1.0 + (-8.0 / t_0);
	}
	return tmp;
}
def code(x, y):
	t_0 = (x / y) * (x / y)
	tmp = 0
	if (x <= 8e-39) or (not (x <= 0.92) and (x <= 2.2e+23)):
		tmp = -1.0 + (0.5 * t_0)
	else:
		tmp = 1.0 + (-8.0 / t_0)
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x / y) * Float64(x / y))
	tmp = 0.0
	if ((x <= 8e-39) || (!(x <= 0.92) && (x <= 2.2e+23)))
		tmp = Float64(-1.0 + Float64(0.5 * t_0));
	else
		tmp = Float64(1.0 + Float64(-8.0 / t_0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x / y) * (x / y);
	tmp = 0.0;
	if ((x <= 8e-39) || (~((x <= 0.92)) && (x <= 2.2e+23)))
		tmp = -1.0 + (0.5 * t_0);
	else
		tmp = 1.0 + (-8.0 / t_0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, 8e-39], And[N[Not[LessEqual[x, 0.92]], $MachinePrecision], LessEqual[x, 2.2e+23]]], N[(-1.0 + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq 8 \cdot 10^{-39} \lor \neg \left(x \leq 0.92\right) \land x \leq 2.2 \cdot 10^{+23}:\\
\;\;\;\;-1 + 0.5 \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 7.99999999999999943e-39 or 0.92000000000000004 < x < 2.20000000000000008e23

    1. Initial program 55.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 57.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    4. Step-by-step derivation
      1. unpow257.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow257.9%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{y \cdot y}} - 1 \]
      3. times-frac63.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
    5. Applied egg-rr63.7%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]

    if 7.99999999999999943e-39 < x < 0.92000000000000004 or 2.20000000000000008e23 < x

    1. Initial program 36.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num36.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}} \]
      2. inv-pow36.1%

        \[\leadsto \color{blue}{{\left(\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1}} \]
      3. +-commutative36.1%

        \[\leadsto {\left(\frac{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      4. *-commutative36.1%

        \[\leadsto {\left(\frac{\color{blue}{\left(4 \cdot y\right)} \cdot y + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      5. associate-*l*36.1%

        \[\leadsto {\left(\frac{\color{blue}{4 \cdot \left(y \cdot y\right)} + x \cdot x}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      6. fma-def36.1%

        \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(4, y \cdot y, x \cdot x\right)}}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      7. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, \color{blue}{{y}^{2}}, x \cdot x\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      8. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, \color{blue}{{x}^{2}}\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}\right)}^{-1} \]
      9. sub-neg36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{x \cdot x + \left(-\left(y \cdot 4\right) \cdot y\right)}}\right)}^{-1} \]
      10. +-commutative36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      11. *-commutative36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      12. distribute-rgt-neg-in36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{y \cdot \left(-y \cdot 4\right)} + x \cdot x}\right)}^{-1} \]
      13. fma-def36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      14. distribute-rgt-neg-in36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      15. metadata-eval36.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot \color{blue}{-4}, x \cdot x\right)}\right)}^{-1} \]
      16. pow236.1%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, \color{blue}{{x}^{2}}\right)}\right)}^{-1} \]
    4. Applied egg-rr36.1%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(4, {y}^{2}, {x}^{2}\right)}{\mathsf{fma}\left(y, y \cdot -4, {x}^{2}\right)}\right)}^{-1}} \]
    5. Taylor expanded in y around 0 74.1%

      \[\leadsto {\color{blue}{\left(1 + 8 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/74.1%

        \[\leadsto {\left(1 + \color{blue}{\frac{8 \cdot {y}^{2}}{{x}^{2}}}\right)}^{-1} \]
      2. associate-/l*74.1%

        \[\leadsto {\left(1 + \color{blue}{\frac{8}{\frac{{x}^{2}}{{y}^{2}}}}\right)}^{-1} \]
      3. unpow274.1%

        \[\leadsto {\left(1 + \frac{8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}}\right)}^{-1} \]
      4. unpow274.1%

        \[\leadsto {\left(1 + \frac{8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}}\right)}^{-1} \]
      5. times-frac79.7%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}\right)}^{-1} \]
      6. unpow279.7%

        \[\leadsto {\left(1 + \frac{8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}\right)}^{-1} \]
    7. Simplified79.7%

      \[\leadsto {\color{blue}{\left(1 + \frac{8}{{\left(\frac{x}{y}\right)}^{2}}\right)}}^{-1} \]
    8. Taylor expanded in x around inf 74.2%

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/74.2%

        \[\leadsto 1 + \color{blue}{\frac{-8 \cdot {y}^{2}}{{x}^{2}}} \]
      2. associate-/l*74.2%

        \[\leadsto 1 + \color{blue}{\frac{-8}{\frac{{x}^{2}}{{y}^{2}}}} \]
      3. unpow274.2%

        \[\leadsto 1 + \frac{-8}{\frac{\color{blue}{x \cdot x}}{{y}^{2}}} \]
      4. unpow274.2%

        \[\leadsto 1 + \frac{-8}{\frac{x \cdot x}{\color{blue}{y \cdot y}}} \]
      5. times-frac80.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
      6. unpow280.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}} \]
    10. Simplified80.2%

      \[\leadsto \color{blue}{1 + \frac{-8}{{\left(\frac{x}{y}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. pow280.2%

        \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
    12. Applied egg-rr80.2%

      \[\leadsto 1 + \frac{-8}{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{-39} \lor \neg \left(x \leq 0.92\right) \land x \leq 2.2 \cdot 10^{+23}:\\ \;\;\;\;-1 + 0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-8}{\frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-42}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 0.05:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+20}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x 4e-42) -1.0 (if (<= x 0.05) 1.0 (if (<= x 2e+20) -1.0 1.0))))
double code(double x, double y) {
	double tmp;
	if (x <= 4e-42) {
		tmp = -1.0;
	} else if (x <= 0.05) {
		tmp = 1.0;
	} else if (x <= 2e+20) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 4d-42) then
        tmp = -1.0d0
    else if (x <= 0.05d0) then
        tmp = 1.0d0
    else if (x <= 2d+20) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 4e-42) {
		tmp = -1.0;
	} else if (x <= 0.05) {
		tmp = 1.0;
	} else if (x <= 2e+20) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 4e-42:
		tmp = -1.0
	elif x <= 0.05:
		tmp = 1.0
	elif x <= 2e+20:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 4e-42)
		tmp = -1.0;
	elseif (x <= 0.05)
		tmp = 1.0;
	elseif (x <= 2e+20)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 4e-42)
		tmp = -1.0;
	elseif (x <= 0.05)
		tmp = 1.0;
	elseif (x <= 2e+20)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 4e-42], -1.0, If[LessEqual[x, 0.05], 1.0, If[LessEqual[x, 2e+20], -1.0, 1.0]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-42}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 0.05:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 2 \cdot 10^{+20}:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.00000000000000015e-42 or 0.050000000000000003 < x < 2e20

    1. Initial program 55.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 62.4%

      \[\leadsto \color{blue}{-1} \]

    if 4.00000000000000015e-42 < x < 0.050000000000000003 or 2e20 < x

    1. Initial program 36.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 79.5%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-42}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 0.05:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+20}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 49.8% accurate, 19.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
	return -1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
public static double code(double x, double y) {
	return -1.0;
}
def code(x, y):
	return -1.0
function code(x, y)
	return -1.0
end
function tmp = code(x, y)
	tmp = -1.0;
end
code[x_, y_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 50.0%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 50.8%

    \[\leadsto \color{blue}{-1} \]
  4. Final simplification50.8%

    \[\leadsto -1 \]
  5. Add Preprocessing

Developer target: 51.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot y\right) \cdot 4\\ t_1 := x \cdot x + t_0\\ t_2 := \frac{t_0}{t_1}\\ t_3 := \left(y \cdot 4\right) \cdot y\\ \mathbf{if}\;\frac{x \cdot x - t_3}{x \cdot x + t_3} < 0.9743233849626781:\\ \;\;\;\;\frac{x \cdot x}{t_1} - t_2\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{t_1}}\right)}^{2} - t_2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y y) 4.0))
        (t_1 (+ (* x x) t_0))
        (t_2 (/ t_0 t_1))
        (t_3 (* (* y 4.0) y)))
   (if (< (/ (- (* x x) t_3) (+ (* x x) t_3)) 0.9743233849626781)
     (- (/ (* x x) t_1) t_2)
     (- (pow (/ x (sqrt t_1)) 2.0) t_2))))
double code(double x, double y) {
	double t_0 = (y * y) * 4.0;
	double t_1 = (x * x) + t_0;
	double t_2 = t_0 / t_1;
	double t_3 = (y * 4.0) * y;
	double tmp;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
		tmp = ((x * x) / t_1) - t_2;
	} else {
		tmp = pow((x / sqrt(t_1)), 2.0) - t_2;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = (y * y) * 4.0d0
    t_1 = (x * x) + t_0
    t_2 = t_0 / t_1
    t_3 = (y * 4.0d0) * y
    if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781d0) then
        tmp = ((x * x) / t_1) - t_2
    else
        tmp = ((x / sqrt(t_1)) ** 2.0d0) - t_2
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y * y) * 4.0;
	double t_1 = (x * x) + t_0;
	double t_2 = t_0 / t_1;
	double t_3 = (y * 4.0) * y;
	double tmp;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
		tmp = ((x * x) / t_1) - t_2;
	} else {
		tmp = Math.pow((x / Math.sqrt(t_1)), 2.0) - t_2;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y * y) * 4.0
	t_1 = (x * x) + t_0
	t_2 = t_0 / t_1
	t_3 = (y * 4.0) * y
	tmp = 0
	if (((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781:
		tmp = ((x * x) / t_1) - t_2
	else:
		tmp = math.pow((x / math.sqrt(t_1)), 2.0) - t_2
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y * y) * 4.0)
	t_1 = Float64(Float64(x * x) + t_0)
	t_2 = Float64(t_0 / t_1)
	t_3 = Float64(Float64(y * 4.0) * y)
	tmp = 0.0
	if (Float64(Float64(Float64(x * x) - t_3) / Float64(Float64(x * x) + t_3)) < 0.9743233849626781)
		tmp = Float64(Float64(Float64(x * x) / t_1) - t_2);
	else
		tmp = Float64((Float64(x / sqrt(t_1)) ^ 2.0) - t_2);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y * y) * 4.0;
	t_1 = (x * x) + t_0;
	t_2 = t_0 / t_1;
	t_3 = (y * 4.0) * y;
	tmp = 0.0;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781)
		tmp = ((x * x) / t_1) - t_2;
	else
		tmp = ((x / sqrt(t_1)) ^ 2.0) - t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[Less[N[(N[(N[(x * x), $MachinePrecision] - t$95$3), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], 0.9743233849626781], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], N[(N[Power[N[(x / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot y\right) \cdot 4\\
t_1 := x \cdot x + t_0\\
t_2 := \frac{t_0}{t_1}\\
t_3 := \left(y \cdot 4\right) \cdot y\\
\mathbf{if}\;\frac{x \cdot x - t_3}{x \cdot x + t_3} < 0.9743233849626781:\\
\;\;\;\;\frac{x \cdot x}{t_1} - t_2\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\sqrt{t_1}}\right)}^{2} - t_2\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024013 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))

  (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))