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

Percentage Accurate: 50.9% → 99.9%
Time: 14.9s
Alternatives: 10
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 10 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: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\ \frac{1}{\frac{t\_0}{\mathsf{fma}\left(y\_m, 2, x\right)}} \cdot \frac{x + y\_m \cdot -2}{t\_0} \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (hypot x (* y_m 2.0))))
   (* (/ 1.0 (/ t_0 (fma y_m 2.0 x))) (/ (+ x (* y_m -2.0)) t_0))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = hypot(x, (y_m * 2.0));
	return (1.0 / (t_0 / fma(y_m, 2.0, x))) * ((x + (y_m * -2.0)) / t_0);
}
y_m = abs(y)
function code(x, y_m)
	t_0 = hypot(x, Float64(y_m * 2.0))
	return Float64(Float64(1.0 / Float64(t_0 / fma(y_m, 2.0, x))) * Float64(Float64(x + Float64(y_m * -2.0)) / t_0))
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(1.0 / N[(t$95$0 / N[(y$95$m * 2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\
\frac{1}{\frac{t\_0}{\mathsf{fma}\left(y\_m, 2, x\right)}} \cdot \frac{x + y\_m \cdot -2}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 49.9%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. fma-define49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
    3. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
  3. Simplified49.9%

    \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot y}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    2. add-sqr-sqrt49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot y} \cdot \sqrt{\left(y \cdot 4\right) \cdot y}}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    3. difference-of-squares49.9%

      \[\leadsto \frac{\color{blue}{\left(x + \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    4. *-commutative49.9%

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    5. associate-*r*49.9%

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(y \cdot y\right) \cdot 4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    6. sqrt-prod49.9%

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

      \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    8. add-sqr-sqrt38.7%

      \[\leadsto \frac{\left(x + \color{blue}{y} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    9. metadata-eval38.7%

      \[\leadsto \frac{\left(x + y \cdot \color{blue}{2}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    10. *-commutative38.7%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    11. associate-*r*38.6%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{\left(y \cdot y\right) \cdot 4}}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    12. sqrt-prod38.6%

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    14. add-sqr-sqrt49.9%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{y} \cdot \sqrt{4}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    15. metadata-eval49.9%

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

    \[\leadsto \frac{\color{blue}{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt49.8%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}} \]
    2. times-frac51.3%

      \[\leadsto \color{blue}{\frac{x + y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}} \]
    3. +-commutative51.3%

      \[\leadsto \frac{\color{blue}{y \cdot 2 + x}}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. fma-define51.3%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, 2, x\right)}}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    5. fma-undefine51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\sqrt{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    6. add-sqr-sqrt51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\sqrt{x \cdot x + \color{blue}{\sqrt{y \cdot \left(y \cdot 4\right)} \cdot \sqrt{y \cdot \left(y \cdot 4\right)}}}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    7. hypot-define51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\color{blue}{\mathsf{hypot}\left(x, \sqrt{y \cdot \left(y \cdot 4\right)}\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    8. sqrt-prod25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\sqrt{y} \cdot \sqrt{y \cdot 4}}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    9. sqrt-prod25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    10. metadata-eval25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    11. associate-*l*25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot 2}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    12. add-sqr-sqrt51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{y} \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
  8. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
  9. Step-by-step derivation
    1. clear-num99.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    2. inv-pow99.9%

      \[\leadsto \color{blue}{{\left(\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}\right)}^{-1}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  10. Applied egg-rr99.9%

    \[\leadsto \color{blue}{{\left(\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}\right)}^{-1}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  11. Step-by-step derivation
    1. unpow-199.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  12. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  13. Final simplification99.9%

    \[\leadsto \frac{1}{\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  14. Add Preprocessing

Alternative 2: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\ \frac{x + y\_m \cdot -2}{t\_0} \cdot \frac{\mathsf{fma}\left(y\_m, 2, x\right)}{t\_0} \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (hypot x (* y_m 2.0))))
   (* (/ (+ x (* y_m -2.0)) t_0) (/ (fma y_m 2.0 x) t_0))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = hypot(x, (y_m * 2.0));
	return ((x + (y_m * -2.0)) / t_0) * (fma(y_m, 2.0, x) / t_0);
}
y_m = abs(y)
function code(x, y_m)
	t_0 = hypot(x, Float64(y_m * 2.0))
	return Float64(Float64(Float64(x + Float64(y_m * -2.0)) / t_0) * Float64(fma(y_m, 2.0, x) / t_0))
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(y$95$m * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\
\frac{x + y\_m \cdot -2}{t\_0} \cdot \frac{\mathsf{fma}\left(y\_m, 2, x\right)}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 49.9%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. fma-define49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
    3. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
  3. Simplified49.9%

    \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot y}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    2. add-sqr-sqrt49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot y} \cdot \sqrt{\left(y \cdot 4\right) \cdot y}}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    3. difference-of-squares49.9%

      \[\leadsto \frac{\color{blue}{\left(x + \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    4. *-commutative49.9%

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    5. associate-*r*49.9%

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(y \cdot y\right) \cdot 4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    6. sqrt-prod49.9%

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

      \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    8. add-sqr-sqrt38.7%

      \[\leadsto \frac{\left(x + \color{blue}{y} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    9. metadata-eval38.7%

      \[\leadsto \frac{\left(x + y \cdot \color{blue}{2}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    10. *-commutative38.7%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    11. associate-*r*38.6%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{\left(y \cdot y\right) \cdot 4}}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    12. sqrt-prod38.6%

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    14. add-sqr-sqrt49.9%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{y} \cdot \sqrt{4}\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    15. metadata-eval49.9%

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

    \[\leadsto \frac{\color{blue}{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt49.8%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}} \]
    2. times-frac51.3%

      \[\leadsto \color{blue}{\frac{x + y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}} \]
    3. +-commutative51.3%

      \[\leadsto \frac{\color{blue}{y \cdot 2 + x}}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. fma-define51.3%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, 2, x\right)}}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    5. fma-undefine51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\sqrt{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    6. add-sqr-sqrt51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\sqrt{x \cdot x + \color{blue}{\sqrt{y \cdot \left(y \cdot 4\right)} \cdot \sqrt{y \cdot \left(y \cdot 4\right)}}}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    7. hypot-define51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\color{blue}{\mathsf{hypot}\left(x, \sqrt{y \cdot \left(y \cdot 4\right)}\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    8. sqrt-prod25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\sqrt{y} \cdot \sqrt{y \cdot 4}}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    9. sqrt-prod25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    10. metadata-eval25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    11. associate-*l*25.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot 2}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    12. add-sqr-sqrt51.3%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{y} \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
  8. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
  9. Final simplification99.9%

    \[\leadsto \frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
  10. Add Preprocessing

Alternative 3: 81.1% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := x \cdot x - t\_0\\ \mathbf{if}\;y\_m \leq 4.5 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y\_m}{x}\right)\right)\right)\\ \mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\ \mathbf{elif}\;y\_m \leq 4.1 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y\_m \leq 10^{+150}:\\ \;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (- (* x x) t_0)))
   (if (<= y_m 4.5e-107)
     (+ 1.0 (* -8.0 (* 2.0 (log (hypot 1.0 (/ y_m x))))))
     (if (<= y_m 1.6e+26)
       (/ t_1 (+ (* x x) t_0))
       (if (<= y_m 4.1e+38)
         1.0
         (if (<= y_m 1e+150)
           (/ t_1 (fma x x t_0))
           (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = (x * x) - t_0;
	double tmp;
	if (y_m <= 4.5e-107) {
		tmp = 1.0 + (-8.0 * (2.0 * log(hypot(1.0, (y_m / x)))));
	} else if (y_m <= 1.6e+26) {
		tmp = t_1 / ((x * x) + t_0);
	} else if (y_m <= 4.1e+38) {
		tmp = 1.0;
	} else if (y_m <= 1e+150) {
		tmp = t_1 / fma(x, x, t_0);
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(Float64(x * x) - t_0)
	tmp = 0.0
	if (y_m <= 4.5e-107)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(2.0 * log(hypot(1.0, Float64(y_m / x))))));
	elseif (y_m <= 1.6e+26)
		tmp = Float64(t_1 / Float64(Float64(x * x) + t_0));
	elseif (y_m <= 4.1e+38)
		tmp = 1.0;
	elseif (y_m <= 1e+150)
		tmp = Float64(t_1 / fma(x, x, t_0));
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -1.0);
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[y$95$m, 4.5e-107], N[(1.0 + N[(-8.0 * N[(2.0 * N[Log[N[Sqrt[1.0 ^ 2 + N[(y$95$m / x), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.6e+26], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 4.1e+38], 1.0, If[LessEqual[y$95$m, 1e+150], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := x \cdot x - t\_0\\
\mathbf{if}\;y\_m \leq 4.5 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y\_m}{x}\right)\right)\right)\\

\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\

\mathbf{elif}\;y\_m \leq 4.1 \cdot 10^{+38}:\\
\;\;\;\;1\\

\mathbf{elif}\;y\_m \leq 10^{+150}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 4.50000000000000016e-107

    1. Initial program 51.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative51.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. add-log-exp52.1%

        \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{\frac{{y}^{2}}{{x}^{2}}}\right)} \]
      2. add-sqr-sqrt52.1%

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

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\color{blue}{\left(\frac{\sqrt{{y}^{2}}}{\sqrt{{x}^{2}}}\right)}}^{2}}\right) \]
      5. unpow252.1%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      6. sqrt-prod17.5%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      7. add-sqr-sqrt54.2%

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\sqrt{\color{blue}{x \cdot x}}}\right)}^{2}}\right) \]
      9. sqrt-prod30.3%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{2}}\right) \]
      10. add-sqr-sqrt58.6%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{x}}\right)}^{2}}\right) \]
    7. Applied egg-rr58.6%

      \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{{\left(\frac{y}{x}\right)}^{2}}\right)} \]
    8. Taylor expanded in y around 0 52.7%

      \[\leadsto 1 + -8 \cdot \log \color{blue}{\left(1 + \frac{{y}^{2}}{{x}^{2}}\right)} \]
    9. Step-by-step derivation
      1. unpow252.7%

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

        \[\leadsto 1 + -8 \cdot \log \left(1 + \frac{y \cdot y}{\color{blue}{x \cdot x}}\right) \]
      3. times-frac60.3%

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

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \left(\log \color{blue}{\left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)} + \log \left(\sqrt{1 + {\left(\frac{y}{x}\right)}^{2}}\right)\right) \]
      5. unpow260.3%

        \[\leadsto 1 + -8 \cdot \left(\log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right) + \log \left(\sqrt{1 + \color{blue}{\frac{y}{x} \cdot \frac{y}{x}}}\right)\right) \]
      6. hypot-1-def61.9%

        \[\leadsto 1 + -8 \cdot \left(\log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right) + \log \color{blue}{\left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)}\right) \]
    12. Applied egg-rr61.9%

      \[\leadsto 1 + -8 \cdot \color{blue}{\left(\log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right) + \log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)\right)} \]
    13. Step-by-step derivation
      1. count-261.9%

        \[\leadsto 1 + -8 \cdot \color{blue}{\left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)\right)} \]
    14. Simplified61.9%

      \[\leadsto 1 + -8 \cdot \color{blue}{\left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)\right)} \]

    if 4.50000000000000016e-107 < y < 1.60000000000000014e26

    1. Initial program 76.6%

      \[\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 1.60000000000000014e26 < y < 4.1000000000000003e38

    1. Initial program 0.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    if 4.1000000000000003e38 < y < 9.99999999999999981e149

    1. Initial program 90.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative90.7%

        \[\leadsto \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      2. fma-define90.9%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
      3. *-commutative90.9%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Simplified90.9%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing

    if 9.99999999999999981e149 < y

    1. Initial program 5.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative5.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]
    6. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}}} - 1 \]
    7. Step-by-step derivation
      1. unpow277.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      4. unpow290.8%

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

      \[\leadsto \color{blue}{0.5 \cdot {\left(\frac{x}{y}\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. pow290.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num90.8%

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) - 1 \]
      3. un-div-inv90.8%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
    10. Applied egg-rr90.8%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
  3. Recombined 5 regimes into one program.
  4. Final simplification70.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.5 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y}{x}\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 10^{+150}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.0% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := x \cdot x - t\_0\\ \mathbf{if}\;y\_m \leq 9 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\ \mathbf{elif}\;y\_m \leq 1.45 \cdot 10^{+26}:\\ \;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\ \mathbf{elif}\;y\_m \leq 6.6 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\ \;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (- (* x x) t_0)))
   (if (<= y_m 9e-107)
     (+ 1.0 (* -8.0 (log (+ 1.0 (/ (/ y_m x) (/ x y_m))))))
     (if (<= y_m 1.45e+26)
       (/ t_1 (+ (* x x) t_0))
       (if (<= y_m 6.6e+38)
         1.0
         (if (<= y_m 1.58e+150)
           (/ t_1 (fma x x t_0))
           (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = (x * x) - t_0;
	double tmp;
	if (y_m <= 9e-107) {
		tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m)))));
	} else if (y_m <= 1.45e+26) {
		tmp = t_1 / ((x * x) + t_0);
	} else if (y_m <= 6.6e+38) {
		tmp = 1.0;
	} else if (y_m <= 1.58e+150) {
		tmp = t_1 / fma(x, x, t_0);
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(Float64(x * x) - t_0)
	tmp = 0.0
	if (y_m <= 9e-107)
		tmp = Float64(1.0 + Float64(-8.0 * log(Float64(1.0 + Float64(Float64(y_m / x) / Float64(x / y_m))))));
	elseif (y_m <= 1.45e+26)
		tmp = Float64(t_1 / Float64(Float64(x * x) + t_0));
	elseif (y_m <= 6.6e+38)
		tmp = 1.0;
	elseif (y_m <= 1.58e+150)
		tmp = Float64(t_1 / fma(x, x, t_0));
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -1.0);
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[y$95$m, 9e-107], N[(1.0 + N[(-8.0 * N[Log[N[(1.0 + N[(N[(y$95$m / x), $MachinePrecision] / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.45e+26], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 6.6e+38], 1.0, If[LessEqual[y$95$m, 1.58e+150], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := x \cdot x - t\_0\\
\mathbf{if}\;y\_m \leq 9 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\

\mathbf{elif}\;y\_m \leq 1.45 \cdot 10^{+26}:\\
\;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\

\mathbf{elif}\;y\_m \leq 6.6 \cdot 10^{+38}:\\
\;\;\;\;1\\

\mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 9.00000000000000032e-107

    1. Initial program 51.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative51.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. add-log-exp52.1%

        \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{\frac{{y}^{2}}{{x}^{2}}}\right)} \]
      2. add-sqr-sqrt52.1%

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

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\color{blue}{\left(\frac{\sqrt{{y}^{2}}}{\sqrt{{x}^{2}}}\right)}}^{2}}\right) \]
      5. unpow252.1%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      6. sqrt-prod17.5%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      7. add-sqr-sqrt54.2%

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\sqrt{\color{blue}{x \cdot x}}}\right)}^{2}}\right) \]
      9. sqrt-prod30.3%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{2}}\right) \]
      10. add-sqr-sqrt58.6%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{x}}\right)}^{2}}\right) \]
    7. Applied egg-rr58.6%

      \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{{\left(\frac{y}{x}\right)}^{2}}\right)} \]
    8. Taylor expanded in y around 0 52.7%

      \[\leadsto 1 + -8 \cdot \log \color{blue}{\left(1 + \frac{{y}^{2}}{{x}^{2}}\right)} \]
    9. Step-by-step derivation
      1. unpow252.7%

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

        \[\leadsto 1 + -8 \cdot \log \left(1 + \frac{y \cdot y}{\color{blue}{x \cdot x}}\right) \]
      3. times-frac60.3%

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

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

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

        \[\leadsto 1 + -8 \cdot \log \left(1 + \color{blue}{\frac{y}{x} \cdot \frac{y}{x}}\right) \]
      2. clear-num60.3%

        \[\leadsto 1 + -8 \cdot \log \left(1 + \frac{y}{x} \cdot \color{blue}{\frac{1}{\frac{x}{y}}}\right) \]
      3. div-inv60.3%

        \[\leadsto 1 + -8 \cdot \log \left(1 + \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}}\right) \]
    12. Applied egg-rr60.3%

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

    if 9.00000000000000032e-107 < y < 1.45e26

    1. Initial program 76.6%

      \[\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 1.45e26 < y < 6.5999999999999998e38

    1. Initial program 0.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    if 6.5999999999999998e38 < y < 1.57999999999999993e150

    1. Initial program 90.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative90.7%

        \[\leadsto \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      2. fma-define90.9%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
      3. *-commutative90.9%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Simplified90.9%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing

    if 1.57999999999999993e150 < y

    1. Initial program 5.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative5.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]
    6. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}}} - 1 \]
    7. Step-by-step derivation
      1. unpow277.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      4. unpow290.8%

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

      \[\leadsto \color{blue}{0.5 \cdot {\left(\frac{x}{y}\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. pow290.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num90.8%

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) - 1 \]
      3. un-div-inv90.8%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
    10. Applied egg-rr90.8%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
  3. Recombined 5 regimes into one program.
  4. Final simplification69.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y}{x}}{\frac{x}{y}}\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+26}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.58 \cdot 10^{+150}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 81.0% accurate, 0.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\ \mathbf{if}\;y\_m \leq 1.65 \cdot 10^{-105}:\\ \;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\ \mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y\_m \leq 8 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
   (if (<= y_m 1.65e-105)
     (+ 1.0 (* -8.0 (log (+ 1.0 (/ (/ y_m x) (/ x y_m))))))
     (if (<= y_m 1.6e+26)
       t_1
       (if (<= y_m 8e+38)
         1.0
         (if (<= y_m 1.58e+150)
           t_1
           (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	double tmp;
	if (y_m <= 1.65e-105) {
		tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m)))));
	} else if (y_m <= 1.6e+26) {
		tmp = t_1;
	} else if (y_m <= 8e+38) {
		tmp = 1.0;
	} else if (y_m <= 1.58e+150) {
		tmp = t_1;
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y_m * (y_m * 4.0d0)
    t_1 = ((x * x) - t_0) / ((x * x) + t_0)
    if (y_m <= 1.65d-105) then
        tmp = 1.0d0 + ((-8.0d0) * log((1.0d0 + ((y_m / x) / (x / y_m)))))
    else if (y_m <= 1.6d+26) then
        tmp = t_1
    else if (y_m <= 8d+38) then
        tmp = 1.0d0
    else if (y_m <= 1.58d+150) then
        tmp = t_1
    else
        tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-1.0d0)
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	double tmp;
	if (y_m <= 1.65e-105) {
		tmp = 1.0 + (-8.0 * Math.log((1.0 + ((y_m / x) / (x / y_m)))));
	} else if (y_m <= 1.6e+26) {
		tmp = t_1;
	} else if (y_m <= 8e+38) {
		tmp = 1.0;
	} else if (y_m <= 1.58e+150) {
		tmp = t_1;
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m):
	t_0 = y_m * (y_m * 4.0)
	t_1 = ((x * x) - t_0) / ((x * x) + t_0)
	tmp = 0
	if y_m <= 1.65e-105:
		tmp = 1.0 + (-8.0 * math.log((1.0 + ((y_m / x) / (x / y_m)))))
	elif y_m <= 1.6e+26:
		tmp = t_1
	elif y_m <= 8e+38:
		tmp = 1.0
	elif y_m <= 1.58e+150:
		tmp = t_1
	else:
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0
	return tmp
y_m = abs(y)
function code(x, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
	tmp = 0.0
	if (y_m <= 1.65e-105)
		tmp = Float64(1.0 + Float64(-8.0 * log(Float64(1.0 + Float64(Float64(y_m / x) / Float64(x / y_m))))));
	elseif (y_m <= 1.6e+26)
		tmp = t_1;
	elseif (y_m <= 8e+38)
		tmp = 1.0;
	elseif (y_m <= 1.58e+150)
		tmp = t_1;
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -1.0);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m)
	t_0 = y_m * (y_m * 4.0);
	t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	tmp = 0.0;
	if (y_m <= 1.65e-105)
		tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m)))));
	elseif (y_m <= 1.6e+26)
		tmp = t_1;
	elseif (y_m <= 8e+38)
		tmp = 1.0;
	elseif (y_m <= 1.58e+150)
		tmp = t_1;
	else
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 1.65e-105], N[(1.0 + N[(-8.0 * N[Log[N[(1.0 + N[(N[(y$95$m / x), $MachinePrecision] / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.6e+26], t$95$1, If[LessEqual[y$95$m, 8e+38], 1.0, If[LessEqual[y$95$m, 1.58e+150], t$95$1, N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{if}\;y\_m \leq 1.65 \cdot 10^{-105}:\\
\;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\

\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y\_m \leq 8 \cdot 10^{+38}:\\
\;\;\;\;1\\

\mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 1.6499999999999999e-105

    1. Initial program 51.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative51.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. add-log-exp52.1%

        \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{\frac{{y}^{2}}{{x}^{2}}}\right)} \]
      2. add-sqr-sqrt52.1%

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

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\color{blue}{\left(\frac{\sqrt{{y}^{2}}}{\sqrt{{x}^{2}}}\right)}}^{2}}\right) \]
      5. unpow252.1%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      6. sqrt-prod17.5%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{{x}^{2}}}\right)}^{2}}\right) \]
      7. add-sqr-sqrt54.2%

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

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\sqrt{\color{blue}{x \cdot x}}}\right)}^{2}}\right) \]
      9. sqrt-prod30.3%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{2}}\right) \]
      10. add-sqr-sqrt58.6%

        \[\leadsto 1 + -8 \cdot \log \left(e^{{\left(\frac{y}{\color{blue}{x}}\right)}^{2}}\right) \]
    7. Applied egg-rr58.6%

      \[\leadsto 1 + -8 \cdot \color{blue}{\log \left(e^{{\left(\frac{y}{x}\right)}^{2}}\right)} \]
    8. Taylor expanded in y around 0 52.7%

      \[\leadsto 1 + -8 \cdot \log \color{blue}{\left(1 + \frac{{y}^{2}}{{x}^{2}}\right)} \]
    9. Step-by-step derivation
      1. unpow252.7%

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

        \[\leadsto 1 + -8 \cdot \log \left(1 + \frac{y \cdot y}{\color{blue}{x \cdot x}}\right) \]
      3. times-frac60.3%

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

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

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

        \[\leadsto 1 + -8 \cdot \log \left(1 + \color{blue}{\frac{y}{x} \cdot \frac{y}{x}}\right) \]
      2. clear-num60.3%

        \[\leadsto 1 + -8 \cdot \log \left(1 + \frac{y}{x} \cdot \color{blue}{\frac{1}{\frac{x}{y}}}\right) \]
      3. div-inv60.3%

        \[\leadsto 1 + -8 \cdot \log \left(1 + \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}}\right) \]
    12. Applied egg-rr60.3%

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

    if 1.6499999999999999e-105 < y < 1.60000000000000014e26 or 7.99999999999999982e38 < y < 1.57999999999999993e150

    1. Initial program 82.6%

      \[\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 1.60000000000000014e26 < y < 7.99999999999999982e38

    1. Initial program 0.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    if 1.57999999999999993e150 < y

    1. Initial program 5.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative5.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]
    6. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}}} - 1 \]
    7. Step-by-step derivation
      1. unpow277.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      4. unpow290.8%

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

      \[\leadsto \color{blue}{0.5 \cdot {\left(\frac{x}{y}\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. pow290.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num90.8%

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) - 1 \]
      3. un-div-inv90.8%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
    10. Applied egg-rr90.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.65 \cdot 10^{-105}:\\ \;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y}{x}}{\frac{x}{y}}\right)\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.58 \cdot 10^{+150}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 80.6% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\ \mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\ \mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y\_m \leq 3.8 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y\_m \leq 1.32 \cdot 10^{+150}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
   (if (<= y_m 4.8e-107)
     (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
     (if (<= y_m 1.6e+26)
       t_1
       (if (<= y_m 3.8e+38)
         1.0
         (if (<= y_m 1.32e+150)
           t_1
           (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))
y_m = fabs(y);
double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	double tmp;
	if (y_m <= 4.8e-107) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else if (y_m <= 1.6e+26) {
		tmp = t_1;
	} else if (y_m <= 3.8e+38) {
		tmp = 1.0;
	} else if (y_m <= 1.32e+150) {
		tmp = t_1;
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y_m * (y_m * 4.0d0)
    t_1 = ((x * x) - t_0) / ((x * x) + t_0)
    if (y_m <= 4.8d-107) then
        tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
    else if (y_m <= 1.6d+26) then
        tmp = t_1
    else if (y_m <= 3.8d+38) then
        tmp = 1.0d0
    else if (y_m <= 1.32d+150) then
        tmp = t_1
    else
        tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-1.0d0)
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	double tmp;
	if (y_m <= 4.8e-107) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else if (y_m <= 1.6e+26) {
		tmp = t_1;
	} else if (y_m <= 3.8e+38) {
		tmp = 1.0;
	} else if (y_m <= 1.32e+150) {
		tmp = t_1;
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m):
	t_0 = y_m * (y_m * 4.0)
	t_1 = ((x * x) - t_0) / ((x * x) + t_0)
	tmp = 0
	if y_m <= 4.8e-107:
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)))
	elif y_m <= 1.6e+26:
		tmp = t_1
	elif y_m <= 3.8e+38:
		tmp = 1.0
	elif y_m <= 1.32e+150:
		tmp = t_1
	else:
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0
	return tmp
y_m = abs(y)
function code(x, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
	tmp = 0.0
	if (y_m <= 4.8e-107)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x))));
	elseif (y_m <= 1.6e+26)
		tmp = t_1;
	elseif (y_m <= 3.8e+38)
		tmp = 1.0;
	elseif (y_m <= 1.32e+150)
		tmp = t_1;
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -1.0);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m)
	t_0 = y_m * (y_m * 4.0);
	t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	tmp = 0.0;
	if (y_m <= 4.8e-107)
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	elseif (y_m <= 1.6e+26)
		tmp = t_1;
	elseif (y_m <= 3.8e+38)
		tmp = 1.0;
	elseif (y_m <= 1.32e+150)
		tmp = t_1;
	else
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 4.8e-107], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.6e+26], t$95$1, If[LessEqual[y$95$m, 3.8e+38], 1.0, If[LessEqual[y$95$m, 1.32e+150], t$95$1, N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\

\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y\_m \leq 3.8 \cdot 10^{+38}:\\
\;\;\;\;1\\

\mathbf{elif}\;y\_m \leq 1.32 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 4.79999999999999989e-107

    1. Initial program 51.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative51.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow252.3%

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

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

        \[\leadsto 1 + -8 \cdot \color{blue}{\left(\frac{y}{x} \cdot \frac{y}{x}\right)} \]
    7. Applied egg-rr59.1%

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

    if 4.79999999999999989e-107 < y < 1.60000000000000014e26 or 3.7999999999999998e38 < y < 1.32e150

    1. Initial program 82.6%

      \[\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 1.60000000000000014e26 < y < 3.7999999999999998e38

    1. Initial program 0.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    if 1.32e150 < y

    1. Initial program 5.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative5.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]
    6. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}}} - 1 \]
    7. Step-by-step derivation
      1. unpow277.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      4. unpow290.8%

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

      \[\leadsto \color{blue}{0.5 \cdot {\left(\frac{x}{y}\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. pow290.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num90.8%

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) - 1 \]
      3. un-div-inv90.8%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
    10. Applied egg-rr90.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.8 \cdot 10^{-107}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+26}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{+150}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.4% accurate, 0.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 1.7 \cdot 10^{-43} \lor \neg \left(y\_m \leq 3.2 \cdot 10^{+25}\right) \land y\_m \leq 4.5 \cdot 10^{+56}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (if (or (<= y_m 1.7e-43) (and (not (<= y_m 3.2e+25)) (<= y_m 4.5e+56)))
   (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
   -1.0))
y_m = fabs(y);
double code(double x, double y_m) {
	double tmp;
	if ((y_m <= 1.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56))) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8) :: tmp
    if ((y_m <= 1.7d-43) .or. (.not. (y_m <= 3.2d+25)) .and. (y_m <= 4.5d+56)) then
        tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	double tmp;
	if ((y_m <= 1.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56))) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m):
	tmp = 0
	if (y_m <= 1.7e-43) or (not (y_m <= 3.2e+25) and (y_m <= 4.5e+56)):
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)))
	else:
		tmp = -1.0
	return tmp
y_m = abs(y)
function code(x, y_m)
	tmp = 0.0
	if ((y_m <= 1.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56)))
		tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x))));
	else
		tmp = -1.0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m)
	tmp = 0.0;
	if ((y_m <= 1.7e-43) || (~((y_m <= 3.2e+25)) && (y_m <= 4.5e+56)))
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := If[Or[LessEqual[y$95$m, 1.7e-43], And[N[Not[LessEqual[y$95$m, 3.2e+25]], $MachinePrecision], LessEqual[y$95$m, 4.5e+56]]], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.7 \cdot 10^{-43} \lor \neg \left(y\_m \leq 3.2 \cdot 10^{+25}\right) \land y\_m \leq 4.5 \cdot 10^{+56}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.7e-43 or 3.1999999999999999e25 < y < 4.5000000000000003e56

    1. Initial program 54.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative54.4%

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
      3. *-commutative54.4%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Simplified54.4%

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow253.3%

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

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

        \[\leadsto 1 + -8 \cdot \color{blue}{\left(\frac{y}{x} \cdot \frac{y}{x}\right)} \]
    7. Applied egg-rr59.3%

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

    if 1.7e-43 < y < 3.1999999999999999e25 or 4.5000000000000003e56 < y

    1. Initial program 38.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative38.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.7 \cdot 10^{-43} \lor \neg \left(y \leq 3.2 \cdot 10^{+25}\right) \land y \leq 4.5 \cdot 10^{+56}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 75.1% accurate, 0.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 2 \cdot 10^{-43} \lor \neg \left(y\_m \leq 1.55 \cdot 10^{+25}\right) \land y\_m \leq 5.5 \cdot 10^{+56}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (if (or (<= y_m 2e-43) (and (not (<= y_m 1.55e+25)) (<= y_m 5.5e+56)))
   (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
   (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))
y_m = fabs(y);
double code(double x, double y_m) {
	double tmp;
	if ((y_m <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56))) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8) :: tmp
    if ((y_m <= 2d-43) .or. (.not. (y_m <= 1.55d+25)) .and. (y_m <= 5.5d+56)) then
        tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
    else
        tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-1.0d0)
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	double tmp;
	if ((y_m <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56))) {
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	} else {
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m):
	tmp = 0
	if (y_m <= 2e-43) or (not (y_m <= 1.55e+25) and (y_m <= 5.5e+56)):
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)))
	else:
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0
	return tmp
y_m = abs(y)
function code(x, y_m)
	tmp = 0.0
	if ((y_m <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56)))
		tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x))));
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -1.0);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m)
	tmp = 0.0;
	if ((y_m <= 2e-43) || (~((y_m <= 1.55e+25)) && (y_m <= 5.5e+56)))
		tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
	else
		tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := If[Or[LessEqual[y$95$m, 2e-43], And[N[Not[LessEqual[y$95$m, 1.55e+25]], $MachinePrecision], LessEqual[y$95$m, 5.5e+56]]], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2 \cdot 10^{-43} \lor \neg \left(y\_m \leq 1.55 \cdot 10^{+25}\right) \land y\_m \leq 5.5 \cdot 10^{+56}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.00000000000000015e-43 or 1.5499999999999999e25 < y < 5.5000000000000002e56

    1. Initial program 54.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative54.4%

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
      3. *-commutative54.4%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Simplified54.4%

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

      \[\leadsto \color{blue}{1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow253.3%

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

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

        \[\leadsto 1 + -8 \cdot \color{blue}{\left(\frac{y}{x} \cdot \frac{y}{x}\right)} \]
    7. Applied egg-rr59.3%

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

    if 2.00000000000000015e-43 < y < 1.5499999999999999e25 or 5.5000000000000002e56 < y

    1. Initial program 38.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative38.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.125 \cdot \frac{{x}^{4}}{{y}^{4}} + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]
    6. Taylor expanded in x around 0 75.2%

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      4. unpow282.7%

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

      \[\leadsto \color{blue}{0.5 \cdot {\left(\frac{x}{y}\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. pow282.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num82.7%

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) - 1 \]
      3. un-div-inv82.7%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} - 1 \]
    10. Applied egg-rr82.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-43} \lor \neg \left(y \leq 1.55 \cdot 10^{+25}\right) \land y \leq 5.5 \cdot 10^{+56}:\\ \;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 73.9% accurate, 1.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 1.3 \cdot 10^{-43}:\\ \;\;\;\;1\\ \mathbf{elif}\;y\_m \leq 5 \cdot 10^{+25}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y\_m \leq 5 \cdot 10^{+56}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m)
 :precision binary64
 (if (<= y_m 1.3e-43)
   1.0
   (if (<= y_m 5e+25) -1.0 (if (<= y_m 5e+56) 1.0 -1.0))))
y_m = fabs(y);
double code(double x, double y_m) {
	double tmp;
	if (y_m <= 1.3e-43) {
		tmp = 1.0;
	} else if (y_m <= 5e+25) {
		tmp = -1.0;
	} else if (y_m <= 5e+56) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8) :: tmp
    if (y_m <= 1.3d-43) then
        tmp = 1.0d0
    else if (y_m <= 5d+25) then
        tmp = -1.0d0
    else if (y_m <= 5d+56) then
        tmp = 1.0d0
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	double tmp;
	if (y_m <= 1.3e-43) {
		tmp = 1.0;
	} else if (y_m <= 5e+25) {
		tmp = -1.0;
	} else if (y_m <= 5e+56) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m):
	tmp = 0
	if y_m <= 1.3e-43:
		tmp = 1.0
	elif y_m <= 5e+25:
		tmp = -1.0
	elif y_m <= 5e+56:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
y_m = abs(y)
function code(x, y_m)
	tmp = 0.0
	if (y_m <= 1.3e-43)
		tmp = 1.0;
	elseif (y_m <= 5e+25)
		tmp = -1.0;
	elseif (y_m <= 5e+56)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m)
	tmp = 0.0;
	if (y_m <= 1.3e-43)
		tmp = 1.0;
	elseif (y_m <= 5e+25)
		tmp = -1.0;
	elseif (y_m <= 5e+56)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := If[LessEqual[y$95$m, 1.3e-43], 1.0, If[LessEqual[y$95$m, 5e+25], -1.0, If[LessEqual[y$95$m, 5e+56], 1.0, -1.0]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.3 \cdot 10^{-43}:\\
\;\;\;\;1\\

\mathbf{elif}\;y\_m \leq 5 \cdot 10^{+25}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y\_m \leq 5 \cdot 10^{+56}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.3e-43 or 5.00000000000000024e25 < y < 5.00000000000000024e56

    1. Initial program 54.4%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative54.4%

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
      3. *-commutative54.4%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Simplified54.4%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 57.7%

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

    if 1.3e-43 < y < 5.00000000000000024e25 or 5.00000000000000024e56 < y

    1. Initial program 38.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative38.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.3 \cdot 10^{-43}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+25}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+56}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 50.2% accurate, 19.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ -1 \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m) :precision binary64 -1.0)
y_m = fabs(y);
double code(double x, double y_m) {
	return -1.0;
}
y_m = abs(y)
real(8) function code(x, y_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    code = -1.0d0
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
	return -1.0;
}
y_m = math.fabs(y)
def code(x, y_m):
	return -1.0
y_m = abs(y)
function code(x, y_m)
	return -1.0
end
y_m = abs(y);
function tmp = code(x, y_m)
	tmp = -1.0;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := -1.0
\begin{array}{l}
y_m = \left|y\right|

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

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. fma-define49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]
    3. *-commutative49.9%

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
  3. Simplified49.9%

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

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification52.5%

    \[\leadsto -1 \]
  7. 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 2024041 
(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))))