Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A

Percentage Accurate: 68.4% → 93.4%
Time: 11.2s
Alternatives: 10
Speedup: 0.5×

Specification

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

\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\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: 68.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z):
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
end
function tmp = code(x, y, z)
	tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}

Alternative 1: 93.4% accurate, 0.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_0 := \frac{{z\_m}^{2}}{y}\\ \mathbf{if}\;z\_m \cdot z\_m \leq 2 \cdot 10^{-30}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(-1, t\_0, \left(z\_m + y\right) \cdot \frac{y - z\_m}{y} + \left(t\_0 + \frac{{x}^{2}}{y}\right)\right)\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 10^{+296}:\\ \;\;\;\;0.5 \cdot \left({z\_m}^{2} \cdot \left(\frac{y}{{z\_m}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z\_m}^{2}}, \frac{-1}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (let* ((t_0 (/ (pow z_m 2.0) y)))
   (if (<= (* z_m z_m) 2e-30)
     (*
      0.5
      (fma
       -1.0
       t_0
       (+ (* (+ z_m y) (/ (- y z_m) y)) (+ t_0 (/ (pow x 2.0) y)))))
     (if (<= (* z_m z_m) 1e+296)
       (*
        0.5
        (*
         (pow z_m 2.0)
         (+ (/ y (pow z_m 2.0)) (fma (/ x y) (/ x (pow z_m 2.0)) (/ -1.0 y)))))
       (+ (* (/ (* z_m (/ z_m y)) y) (* y -0.5)) (* 0.5 y))))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double t_0 = pow(z_m, 2.0) / y;
	double tmp;
	if ((z_m * z_m) <= 2e-30) {
		tmp = 0.5 * fma(-1.0, t_0, (((z_m + y) * ((y - z_m) / y)) + (t_0 + (pow(x, 2.0) / y))));
	} else if ((z_m * z_m) <= 1e+296) {
		tmp = 0.5 * (pow(z_m, 2.0) * ((y / pow(z_m, 2.0)) + fma((x / y), (x / pow(z_m, 2.0)), (-1.0 / y))));
	} else {
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y);
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m)
	t_0 = Float64((z_m ^ 2.0) / y)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 2e-30)
		tmp = Float64(0.5 * fma(-1.0, t_0, Float64(Float64(Float64(z_m + y) * Float64(Float64(y - z_m) / y)) + Float64(t_0 + Float64((x ^ 2.0) / y)))));
	elseif (Float64(z_m * z_m) <= 1e+296)
		tmp = Float64(0.5 * Float64((z_m ^ 2.0) * Float64(Float64(y / (z_m ^ 2.0)) + fma(Float64(x / y), Float64(x / (z_m ^ 2.0)), Float64(-1.0 / y)))));
	else
		tmp = Float64(Float64(Float64(Float64(z_m * Float64(z_m / y)) / y) * Float64(y * -0.5)) + Float64(0.5 * y));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[Power[z$95$m, 2.0], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e-30], N[(0.5 * N[(-1.0 * t$95$0 + N[(N[(N[(z$95$m + y), $MachinePrecision] * N[(N[(y - z$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 + N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+296], N[(0.5 * N[(N[Power[z$95$m, 2.0], $MachinePrecision] * N[(N[(y / N[Power[z$95$m, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] * N[(x / N[Power[z$95$m, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * N[(y * -0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_0 := \frac{{z\_m}^{2}}{y}\\
\mathbf{if}\;z\_m \cdot z\_m \leq 2 \cdot 10^{-30}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(-1, t\_0, \left(z\_m + y\right) \cdot \frac{y - z\_m}{y} + \left(t\_0 + \frac{{x}^{2}}{y}\right)\right)\\

\mathbf{elif}\;z\_m \cdot z\_m \leq 10^{+296}:\\
\;\;\;\;0.5 \cdot \left({z\_m}^{2} \cdot \left(\frac{y}{{z\_m}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z\_m}^{2}}, \frac{-1}{y}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\


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

    1. Initial program 80.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg80.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out80.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg280.5%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg80.5%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-180.5%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out80.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative80.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in80.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac80.5%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval80.5%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval80.5%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+80.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define80.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified80.5%

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(y, y, -z \cdot z\right) + \mathsf{fma}\left(-z, z, z \cdot z\right)}\right)}{y} \]
      2. fma-neg80.5%

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot y - z \cdot z\right)} + \mathsf{fma}\left(-z, z, z \cdot z\right)\right)}{y} \]
      3. difference-of-squares80.5%

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y + z\right) \cdot \left(y - z\right)} + \mathsf{fma}\left(-z, z, z \cdot z\right)\right)}{y} \]
      4. fma-define80.5%

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(y + z, y - z, \mathsf{fma}\left(-z, z, z \cdot z\right)\right)}\right)}{y} \]
      5. pow280.5%

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \mathsf{fma}\left(y + z, y - z, \mathsf{fma}\left(-z, z, \color{blue}{{z}^{2}}\right)\right)\right)}{y} \]
    6. Applied egg-rr80.5%

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(y + z, y - z, \mathsf{fma}\left(-z, z, {z}^{2}\right)\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 80.5%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(-1, \frac{{z}^{2}}{y}, \frac{\left(y + z\right) \cdot \left(y - z\right)}{y} + \left(\frac{{x}^{2}}{y} + \frac{{z}^{2}}{y}\right)\right)} \]
      2. associate-/l*96.9%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(-1, \frac{{z}^{2}}{y}, \color{blue}{\left(y + z\right) \cdot \frac{y - z}{y}} + \left(\frac{{x}^{2}}{y} + \frac{{z}^{2}}{y}\right)\right) \]
      3. +-commutative96.9%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(-1, \frac{{z}^{2}}{y}, \color{blue}{\left(z + y\right)} \cdot \frac{y - z}{y} + \left(\frac{{x}^{2}}{y} + \frac{{z}^{2}}{y}\right)\right) \]
    9. Simplified96.9%

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

    if 2e-30 < (*.f64 z z) < 9.99999999999999981e295

    1. Initial program 83.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg83.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out83.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg283.5%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg83.5%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-183.5%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out83.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative83.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in83.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac83.5%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval83.5%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval83.5%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+83.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define83.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified83.5%

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

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

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

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac98.1%

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

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac98.1%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval98.1%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{\color{blue}{-1}}{y}\right)\right)\right) \]
    7. Simplified98.1%

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

    if 9.99999999999999981e295 < (*.f64 z z)

    1. Initial program 48.1%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{{y}^{2}}\right)} \]
    4. Step-by-step derivation
      1. *-commutative48.1%

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

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative60.8%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified60.8%

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5 + 0.5\right)} \]
      2. distribute-rgt-in60.8%

        \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5\right) \cdot y + 0.5 \cdot y} \]
      3. associate-*l*60.8%

        \[\leadsto \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot \left(-0.5 \cdot y\right)} + 0.5 \cdot y \]
      4. add-sqr-sqrt60.8%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}} \cdot \sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      5. pow260.8%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)}^{2}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      6. sqrt-div60.8%

        \[\leadsto {\color{blue}{\left(\frac{\sqrt{{z}^{2}}}{\sqrt{{y}^{2}}}\right)}}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      7. sqrt-pow181.4%

        \[\leadsto {\left(\frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      8. metadata-eval81.4%

        \[\leadsto {\left(\frac{{z}^{\color{blue}{1}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      9. pow181.4%

        \[\leadsto {\left(\frac{\color{blue}{z}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      10. sqrt-pow193.6%

        \[\leadsto {\left(\frac{z}{\color{blue}{{y}^{\left(\frac{2}{2}\right)}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      11. metadata-eval93.6%

        \[\leadsto {\left(\frac{z}{{y}^{\color{blue}{1}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      12. pow193.6%

        \[\leadsto {\left(\frac{z}{\color{blue}{y}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    10. Applied egg-rr93.6%

      \[\leadsto \color{blue}{{\left(\frac{z}{y}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y} \]
    11. Step-by-step derivation
      1. unpow293.6%

        \[\leadsto \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      2. associate-*r/93.7%

        \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    12. Applied egg-rr93.7%

      \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-30}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(-1, \frac{{z}^{2}}{y}, \left(z + y\right) \cdot \frac{y - z}{y} + \left(\frac{{z}^{2}}{y} + \frac{{x}^{2}}{y}\right)\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+296}:\\ \;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{-1}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \frac{z}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 76.9% accurate, 0.1× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z\_m \cdot z\_m}{2 \cdot y}\\ \mathbf{if}\;t\_0 \leq 10^{+289}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z\_m \cdot z\_m\right)}{y}\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \left(x \cdot \frac{1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z_m z_m)) (* 2.0 y))))
   (if (<= t_0 1e+289)
     (* 0.5 (/ (fma x x (- (* y y) (* z_m z_m))) y))
     (if (<= t_0 INFINITY)
       (* 0.5 (+ y (* x (* x (/ 1.0 y)))))
       (+ (* (/ (* z_m (/ z_m y)) y) (* y -0.5)) (* 0.5 y))))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double t_0 = (((x * x) + (y * y)) - (z_m * z_m)) / (2.0 * y);
	double tmp;
	if (t_0 <= 1e+289) {
		tmp = 0.5 * (fma(x, x, ((y * y) - (z_m * z_m))) / y);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 0.5 * (y + (x * (x * (1.0 / y))));
	} else {
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y);
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z_m * z_m)) / Float64(2.0 * y))
	tmp = 0.0
	if (t_0 <= 1e+289)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z_m * z_m))) / y));
	elseif (t_0 <= Inf)
		tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x * Float64(1.0 / y)))));
	else
		tmp = Float64(Float64(Float64(Float64(z_m * Float64(z_m / y)) / y) * Float64(y * -0.5)) + Float64(0.5 * y));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+289], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y + N[(x * N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * N[(y * -0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z\_m \cdot z\_m}{2 \cdot y}\\
\mathbf{if}\;t\_0 \leq 10^{+289}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z\_m \cdot z\_m\right)}{y}\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \left(x \cdot \frac{1}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 1.0000000000000001e289

    1. Initial program 87.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg87.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out87.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg287.6%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg87.6%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-187.6%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out87.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative87.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in87.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac87.6%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval87.6%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval87.6%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+87.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define87.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified87.6%

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

    if 1.0000000000000001e289 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0

    1. Initial program 71.9%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt35.6%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine35.6%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow235.6%

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

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/35.6%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative35.6%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified35.6%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 56.8%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{y}\right) \]
      3. associate-*l*62.3%

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

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

    if +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 0.0%

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

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

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{x}^{2} - {z}^{2}}{{y}^{2}} \cdot 0.5}\right) \]
    5. Simplified0.0%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative26.7%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified26.7%

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5 + 0.5\right)} \]
      2. distribute-rgt-in26.7%

        \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5\right) \cdot y + 0.5 \cdot y} \]
      3. associate-*l*26.7%

        \[\leadsto \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot \left(-0.5 \cdot y\right)} + 0.5 \cdot y \]
      4. add-sqr-sqrt26.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}} \cdot \sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      5. pow226.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)}^{2}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      6. sqrt-div26.7%

        \[\leadsto {\color{blue}{\left(\frac{\sqrt{{z}^{2}}}{\sqrt{{y}^{2}}}\right)}}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      7. sqrt-pow161.1%

        \[\leadsto {\left(\frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      8. metadata-eval61.1%

        \[\leadsto {\left(\frac{{z}^{\color{blue}{1}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      9. pow161.1%

        \[\leadsto {\left(\frac{\color{blue}{z}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      10. sqrt-pow186.7%

        \[\leadsto {\left(\frac{z}{\color{blue}{{y}^{\left(\frac{2}{2}\right)}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      11. metadata-eval86.7%

        \[\leadsto {\left(\frac{z}{{y}^{\color{blue}{1}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      12. pow186.7%

        \[\leadsto {\left(\frac{z}{\color{blue}{y}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    10. Applied egg-rr86.7%

      \[\leadsto \color{blue}{{\left(\frac{z}{y}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y} \]
    11. Step-by-step derivation
      1. unpow286.7%

        \[\leadsto \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      2. associate-*r/86.8%

        \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    12. Applied egg-rr86.8%

      \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{2 \cdot y} \leq 10^{+289}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{elif}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{2 \cdot y} \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \left(x \cdot \frac{1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \frac{z}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.9% accurate, 0.3× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z\_m \cdot z\_m}{2 \cdot y}\\ \mathbf{if}\;t\_0 \leq 10^{+289}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \left(x \cdot \frac{1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z_m z_m)) (* 2.0 y))))
   (if (<= t_0 1e+289)
     t_0
     (if (<= t_0 INFINITY)
       (* 0.5 (+ y (* x (* x (/ 1.0 y)))))
       (+ (* (/ (* z_m (/ z_m y)) y) (* y -0.5)) (* 0.5 y))))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double t_0 = (((x * x) + (y * y)) - (z_m * z_m)) / (2.0 * y);
	double tmp;
	if (t_0 <= 1e+289) {
		tmp = t_0;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 0.5 * (y + (x * (x * (1.0 / y))));
	} else {
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y);
	}
	return tmp;
}
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
	double t_0 = (((x * x) + (y * y)) - (z_m * z_m)) / (2.0 * y);
	double tmp;
	if (t_0 <= 1e+289) {
		tmp = t_0;
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = 0.5 * (y + (x * (x * (1.0 / y))));
	} else {
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y);
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m):
	t_0 = (((x * x) + (y * y)) - (z_m * z_m)) / (2.0 * y)
	tmp = 0
	if t_0 <= 1e+289:
		tmp = t_0
	elif t_0 <= math.inf:
		tmp = 0.5 * (y + (x * (x * (1.0 / y))))
	else:
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y)
	return tmp
z_m = abs(z)
function code(x, y, z_m)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z_m * z_m)) / Float64(2.0 * y))
	tmp = 0.0
	if (t_0 <= 1e+289)
		tmp = t_0;
	elseif (t_0 <= Inf)
		tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x * Float64(1.0 / y)))));
	else
		tmp = Float64(Float64(Float64(Float64(z_m * Float64(z_m / y)) / y) * Float64(y * -0.5)) + Float64(0.5 * y));
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m)
	t_0 = (((x * x) + (y * y)) - (z_m * z_m)) / (2.0 * y);
	tmp = 0.0;
	if (t_0 <= 1e+289)
		tmp = t_0;
	elseif (t_0 <= Inf)
		tmp = 0.5 * (y + (x * (x * (1.0 / y))));
	else
		tmp = (((z_m * (z_m / y)) / y) * (y * -0.5)) + (0.5 * y);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+289], t$95$0, If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y + N[(x * N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * N[(y * -0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z\_m \cdot z\_m}{2 \cdot y}\\
\mathbf{if}\;t\_0 \leq 10^{+289}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \left(x \cdot \frac{1}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 1.0000000000000001e289

    1. Initial program 87.6%

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

    if 1.0000000000000001e289 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0

    1. Initial program 71.9%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt35.6%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine35.6%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow235.6%

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

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow235.6%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/35.6%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative35.6%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified35.6%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 56.8%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{y}\right) \]
      3. associate-*l*62.3%

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

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

    if +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 0.0%

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

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

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{x}^{2} - {z}^{2}}{{y}^{2}} \cdot 0.5}\right) \]
    5. Simplified0.0%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative26.7%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified26.7%

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5 + 0.5\right)} \]
      2. distribute-rgt-in26.7%

        \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5\right) \cdot y + 0.5 \cdot y} \]
      3. associate-*l*26.7%

        \[\leadsto \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot \left(-0.5 \cdot y\right)} + 0.5 \cdot y \]
      4. add-sqr-sqrt26.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}} \cdot \sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      5. pow226.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)}^{2}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      6. sqrt-div26.7%

        \[\leadsto {\color{blue}{\left(\frac{\sqrt{{z}^{2}}}{\sqrt{{y}^{2}}}\right)}}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      7. sqrt-pow161.1%

        \[\leadsto {\left(\frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      8. metadata-eval61.1%

        \[\leadsto {\left(\frac{{z}^{\color{blue}{1}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      9. pow161.1%

        \[\leadsto {\left(\frac{\color{blue}{z}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      10. sqrt-pow186.7%

        \[\leadsto {\left(\frac{z}{\color{blue}{{y}^{\left(\frac{2}{2}\right)}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      11. metadata-eval86.7%

        \[\leadsto {\left(\frac{z}{{y}^{\color{blue}{1}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      12. pow186.7%

        \[\leadsto {\left(\frac{z}{\color{blue}{y}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    10. Applied egg-rr86.7%

      \[\leadsto \color{blue}{{\left(\frac{z}{y}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y} \]
    11. Step-by-step derivation
      1. unpow286.7%

        \[\leadsto \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      2. associate-*r/86.8%

        \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    12. Applied egg-rr86.8%

      \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.0%

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

Alternative 4: 83.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.1 \cdot 10^{-20}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\

\mathbf{elif}\;z\_m \leq 4.7 \cdot 10^{+20} \lor \neg \left(z\_m \leq 10^{+36}\right):\\
\;\;\;\;\frac{z\_m \cdot \frac{z\_m}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 5.10000000000000019e-20

    1. Initial program 74.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt55.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/55.4%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative55.4%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified55.4%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 70.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity70.2%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac73.7%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. clear-num73.7%

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

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

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

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

    if 5.10000000000000019e-20 < z < 4.7e20 or 1.00000000000000004e36 < z

    1. Initial program 68.1%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{{y}^{2}}\right)} \]
    4. Step-by-step derivation
      1. *-commutative63.3%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{x}^{2} - {z}^{2}}{{y}^{2}} \cdot 0.5}\right) \]
    5. Simplified63.3%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative71.8%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified71.8%

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5 + 0.5\right)} \]
      2. distribute-rgt-in71.8%

        \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5\right) \cdot y + 0.5 \cdot y} \]
      3. associate-*l*71.8%

        \[\leadsto \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot \left(-0.5 \cdot y\right)} + 0.5 \cdot y \]
      4. add-sqr-sqrt71.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}} \cdot \sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      5. pow271.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)}^{2}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      6. sqrt-div71.7%

        \[\leadsto {\color{blue}{\left(\frac{\sqrt{{z}^{2}}}{\sqrt{{y}^{2}}}\right)}}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      7. sqrt-pow180.7%

        \[\leadsto {\left(\frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      8. metadata-eval80.7%

        \[\leadsto {\left(\frac{{z}^{\color{blue}{1}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      9. pow180.7%

        \[\leadsto {\left(\frac{\color{blue}{z}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      10. sqrt-pow185.3%

        \[\leadsto {\left(\frac{z}{\color{blue}{{y}^{\left(\frac{2}{2}\right)}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      11. metadata-eval85.3%

        \[\leadsto {\left(\frac{z}{{y}^{\color{blue}{1}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      12. pow185.3%

        \[\leadsto {\left(\frac{z}{\color{blue}{y}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    10. Applied egg-rr85.3%

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

        \[\leadsto \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      2. associate-*r/85.4%

        \[\leadsto \color{blue}{\frac{\frac{z}{y} \cdot z}{y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    12. Applied egg-rr85.4%

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

    if 4.7e20 < z < 1.00000000000000004e36

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt99.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative100.0%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 99.5%

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

        \[\leadsto \color{blue}{0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)} \]
    8. Simplified99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac99.5%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. /-rgt-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{x} \cdot \frac{x}{y}\right) \]
      2. clear-num99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
    12. Applied egg-rr100.0%

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.1 \cdot 10^{-20}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{+20} \lor \neg \left(z \leq 10^{+36}\right):\\ \;\;\;\;\frac{z \cdot \frac{z}{y}}{y} \cdot \left(y \cdot -0.5\right) + 0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 83.2% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 5.2 \cdot 10^{-21}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\ \mathbf{elif}\;z\_m \leq 4.4 \cdot 10^{+19} \lor \neg \left(z\_m \leq 2.05 \cdot 10^{+36}\right):\\ \;\;\;\;0.5 \cdot y + \left(y \cdot -0.5\right) \cdot \frac{z\_m}{y \cdot \frac{y}{z\_m}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 5.2e-21)
   (* 0.5 (+ y (/ (/ x y) (/ 1.0 x))))
   (if (or (<= z_m 4.4e+19) (not (<= z_m 2.05e+36)))
     (+ (* 0.5 y) (* (* y -0.5) (/ z_m (* y (/ y z_m)))))
     (* 0.5 (+ y (/ x (/ y x)))))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 5.2e-21) {
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	} else if ((z_m <= 4.4e+19) || !(z_m <= 2.05e+36)) {
		tmp = (0.5 * y) + ((y * -0.5) * (z_m / (y * (y / z_m))));
	} else {
		tmp = 0.5 * (y + (x / (y / x)));
	}
	return tmp;
}
z_m = abs(z)
real(8) function code(x, y, z_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 5.2d-21) then
        tmp = 0.5d0 * (y + ((x / y) / (1.0d0 / x)))
    else if ((z_m <= 4.4d+19) .or. (.not. (z_m <= 2.05d+36))) then
        tmp = (0.5d0 * y) + ((y * (-0.5d0)) * (z_m / (y * (y / z_m))))
    else
        tmp = 0.5d0 * (y + (x / (y / x)))
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 5.2e-21) {
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	} else if ((z_m <= 4.4e+19) || !(z_m <= 2.05e+36)) {
		tmp = (0.5 * y) + ((y * -0.5) * (z_m / (y * (y / z_m))));
	} else {
		tmp = 0.5 * (y + (x / (y / x)));
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m):
	tmp = 0
	if z_m <= 5.2e-21:
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)))
	elif (z_m <= 4.4e+19) or not (z_m <= 2.05e+36):
		tmp = (0.5 * y) + ((y * -0.5) * (z_m / (y * (y / z_m))))
	else:
		tmp = 0.5 * (y + (x / (y / x)))
	return tmp
z_m = abs(z)
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 5.2e-21)
		tmp = Float64(0.5 * Float64(y + Float64(Float64(x / y) / Float64(1.0 / x))));
	elseif ((z_m <= 4.4e+19) || !(z_m <= 2.05e+36))
		tmp = Float64(Float64(0.5 * y) + Float64(Float64(y * -0.5) * Float64(z_m / Float64(y * Float64(y / z_m)))));
	else
		tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x))));
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 5.2e-21)
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	elseif ((z_m <= 4.4e+19) || ~((z_m <= 2.05e+36)))
		tmp = (0.5 * y) + ((y * -0.5) * (z_m / (y * (y / z_m))));
	else
		tmp = 0.5 * (y + (x / (y / x)));
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 5.2e-21], N[(0.5 * N[(y + N[(N[(x / y), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z$95$m, 4.4e+19], N[Not[LessEqual[z$95$m, 2.05e+36]], $MachinePrecision]], N[(N[(0.5 * y), $MachinePrecision] + N[(N[(y * -0.5), $MachinePrecision] * N[(z$95$m / N[(y * N[(y / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.2 \cdot 10^{-21}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\

\mathbf{elif}\;z\_m \leq 4.4 \cdot 10^{+19} \lor \neg \left(z\_m \leq 2.05 \cdot 10^{+36}\right):\\
\;\;\;\;0.5 \cdot y + \left(y \cdot -0.5\right) \cdot \frac{z\_m}{y \cdot \frac{y}{z\_m}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 5.20000000000000035e-21

    1. Initial program 74.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt55.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/55.4%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative55.4%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified55.4%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 70.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity70.2%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac73.7%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. clear-num73.7%

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

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

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

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

    if 5.20000000000000035e-21 < z < 4.4e19 or 2.05000000000000006e36 < z

    1. Initial program 68.1%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{{y}^{2}}\right)} \]
    4. Step-by-step derivation
      1. *-commutative63.3%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{x}^{2} - {z}^{2}}{{y}^{2}} \cdot 0.5}\right) \]
    5. Simplified63.3%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative71.8%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified71.8%

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5 + 0.5\right)} \]
      2. distribute-rgt-in71.8%

        \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{{y}^{2}} \cdot -0.5\right) \cdot y + 0.5 \cdot y} \]
      3. associate-*l*71.8%

        \[\leadsto \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot \left(-0.5 \cdot y\right)} + 0.5 \cdot y \]
      4. add-sqr-sqrt71.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}} \cdot \sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      5. pow271.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{{z}^{2}}{{y}^{2}}}\right)}^{2}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      6. sqrt-div71.7%

        \[\leadsto {\color{blue}{\left(\frac{\sqrt{{z}^{2}}}{\sqrt{{y}^{2}}}\right)}}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      7. sqrt-pow180.7%

        \[\leadsto {\left(\frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      8. metadata-eval80.7%

        \[\leadsto {\left(\frac{{z}^{\color{blue}{1}}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      9. pow180.7%

        \[\leadsto {\left(\frac{\color{blue}{z}}{\sqrt{{y}^{2}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      10. sqrt-pow185.3%

        \[\leadsto {\left(\frac{z}{\color{blue}{{y}^{\left(\frac{2}{2}\right)}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      11. metadata-eval85.3%

        \[\leadsto {\left(\frac{z}{{y}^{\color{blue}{1}}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      12. pow185.3%

        \[\leadsto {\left(\frac{z}{\color{blue}{y}}\right)}^{2} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    10. Applied egg-rr85.3%

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

        \[\leadsto \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      2. clear-num85.4%

        \[\leadsto \left(\color{blue}{\frac{1}{\frac{y}{z}}} \cdot \frac{z}{y}\right) \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      3. frac-times85.4%

        \[\leadsto \color{blue}{\frac{1 \cdot z}{\frac{y}{z} \cdot y}} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
      4. *-un-lft-identity85.4%

        \[\leadsto \frac{\color{blue}{z}}{\frac{y}{z} \cdot y} \cdot \left(-0.5 \cdot y\right) + 0.5 \cdot y \]
    12. Applied egg-rr85.4%

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

    if 4.4e19 < z < 2.05000000000000006e36

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt99.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative100.0%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 99.5%

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

        \[\leadsto \color{blue}{0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)} \]
    8. Simplified99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac99.5%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. /-rgt-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{x} \cdot \frac{x}{y}\right) \]
      2. clear-num99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
    12. Applied egg-rr100.0%

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.2 \cdot 10^{-21}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+19} \lor \neg \left(z \leq 2.05 \cdot 10^{+36}\right):\\ \;\;\;\;0.5 \cdot y + \left(y \cdot -0.5\right) \cdot \frac{z}{y \cdot \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 83.1% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 5.1 \cdot 10^{-20}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\ \mathbf{elif}\;z\_m \leq 6.2 \cdot 10^{+20} \lor \neg \left(z\_m \leq 1.15 \cdot 10^{+36}\right):\\ \;\;\;\;y \cdot \left(0.5 + -0.5 \cdot \left(\frac{z\_m}{y} \cdot \frac{z\_m}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 5.1e-20)
   (* 0.5 (+ y (/ (/ x y) (/ 1.0 x))))
   (if (or (<= z_m 6.2e+20) (not (<= z_m 1.15e+36)))
     (* y (+ 0.5 (* -0.5 (* (/ z_m y) (/ z_m y)))))
     (* 0.5 (+ y (/ x (/ y x)))))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 5.1e-20) {
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	} else if ((z_m <= 6.2e+20) || !(z_m <= 1.15e+36)) {
		tmp = y * (0.5 + (-0.5 * ((z_m / y) * (z_m / y))));
	} else {
		tmp = 0.5 * (y + (x / (y / x)));
	}
	return tmp;
}
z_m = abs(z)
real(8) function code(x, y, z_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 5.1d-20) then
        tmp = 0.5d0 * (y + ((x / y) / (1.0d0 / x)))
    else if ((z_m <= 6.2d+20) .or. (.not. (z_m <= 1.15d+36))) then
        tmp = y * (0.5d0 + ((-0.5d0) * ((z_m / y) * (z_m / y))))
    else
        tmp = 0.5d0 * (y + (x / (y / x)))
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 5.1e-20) {
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	} else if ((z_m <= 6.2e+20) || !(z_m <= 1.15e+36)) {
		tmp = y * (0.5 + (-0.5 * ((z_m / y) * (z_m / y))));
	} else {
		tmp = 0.5 * (y + (x / (y / x)));
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m):
	tmp = 0
	if z_m <= 5.1e-20:
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)))
	elif (z_m <= 6.2e+20) or not (z_m <= 1.15e+36):
		tmp = y * (0.5 + (-0.5 * ((z_m / y) * (z_m / y))))
	else:
		tmp = 0.5 * (y + (x / (y / x)))
	return tmp
z_m = abs(z)
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 5.1e-20)
		tmp = Float64(0.5 * Float64(y + Float64(Float64(x / y) / Float64(1.0 / x))));
	elseif ((z_m <= 6.2e+20) || !(z_m <= 1.15e+36))
		tmp = Float64(y * Float64(0.5 + Float64(-0.5 * Float64(Float64(z_m / y) * Float64(z_m / y)))));
	else
		tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x))));
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 5.1e-20)
		tmp = 0.5 * (y + ((x / y) / (1.0 / x)));
	elseif ((z_m <= 6.2e+20) || ~((z_m <= 1.15e+36)))
		tmp = y * (0.5 + (-0.5 * ((z_m / y) * (z_m / y))));
	else
		tmp = 0.5 * (y + (x / (y / x)));
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 5.1e-20], N[(0.5 * N[(y + N[(N[(x / y), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z$95$m, 6.2e+20], N[Not[LessEqual[z$95$m, 1.15e+36]], $MachinePrecision]], N[(y * N[(0.5 + N[(-0.5 * N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.1 \cdot 10^{-20}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\

\mathbf{elif}\;z\_m \leq 6.2 \cdot 10^{+20} \lor \neg \left(z\_m \leq 1.15 \cdot 10^{+36}\right):\\
\;\;\;\;y \cdot \left(0.5 + -0.5 \cdot \left(\frac{z\_m}{y} \cdot \frac{z\_m}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 5.10000000000000019e-20

    1. Initial program 74.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt55.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine55.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow255.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/55.4%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative55.4%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified55.4%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 70.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity70.2%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac73.7%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. clear-num73.7%

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

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

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

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

    if 5.10000000000000019e-20 < z < 6.2e20 or 1.14999999999999998e36 < z

    1. Initial program 68.1%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{{y}^{2}}\right)} \]
    4. Step-by-step derivation
      1. *-commutative63.3%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{x}^{2} - {z}^{2}}{{y}^{2}} \cdot 0.5}\right) \]
    5. Simplified63.3%

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

      \[\leadsto \color{blue}{y \cdot \left(0.5 + -0.5 \cdot \frac{{z}^{2}}{{y}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative71.8%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{{z}^{2}}{{y}^{2}} \cdot -0.5}\right) \]
    8. Simplified71.8%

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

        \[\leadsto y \cdot \left(0.5 + \frac{{z}^{2}}{\color{blue}{y \cdot y}} \cdot -0.5\right) \]
      2. unpow271.8%

        \[\leadsto y \cdot \left(0.5 + \frac{\color{blue}{z \cdot z}}{y \cdot y} \cdot -0.5\right) \]
      3. times-frac85.3%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\left(\frac{z}{y} \cdot \frac{z}{y}\right)} \cdot -0.5\right) \]
    10. Applied egg-rr85.3%

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

    if 6.2e20 < z < 1.14999999999999998e36

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
      2. rem-square-sqrt99.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
      3. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      4. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      5. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
      6. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
      7. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
      8. hypot-undefine99.5%

        \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
      9. unpow299.5%

        \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
      10. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
      11. *-commutative100.0%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
    6. Taylor expanded in x around 0 99.5%

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

        \[\leadsto \color{blue}{0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)} \]
    8. Simplified99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
      2. *-un-lft-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x}{\color{blue}{1 \cdot y}}\right) \]
      3. times-frac99.5%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
    11. Step-by-step derivation
      1. /-rgt-identity99.5%

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{x} \cdot \frac{x}{y}\right) \]
      2. clear-num99.5%

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

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
    12. Applied egg-rr100.0%

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.1 \cdot 10^{-20}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+20} \lor \neg \left(z \leq 1.15 \cdot 10^{+36}\right):\\ \;\;\;\;y \cdot \left(0.5 + -0.5 \cdot \left(\frac{z}{y} \cdot \frac{z}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 67.3% accurate, 1.4× speedup?

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

\\
0.5 \cdot \left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right)
\end{array}
Derivation
  1. Initial program 73.3%

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

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
    2. rem-square-sqrt47.3%

      \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
    3. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    4. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    5. hypot-undefine47.3%

      \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    6. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
    7. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
    8. hypot-undefine47.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
    9. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
    10. associate-*l/47.2%

      \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
    11. *-commutative47.2%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
  5. Simplified47.2%

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
  6. Taylor expanded in x around 0 61.1%

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
    2. *-un-lft-identity61.1%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
  10. Applied egg-rr64.4%

    \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
  11. Step-by-step derivation
    1. clear-num64.4%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{1 \cdot \frac{x}{y}}{\frac{1}{x}}}\right) \]
    3. *-un-lft-identity64.4%

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{\frac{x}{y}}}{\frac{1}{x}}\right) \]
  12. Applied egg-rr64.4%

    \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{\frac{x}{y}}{\frac{1}{x}}}\right) \]
  13. Add Preprocessing

Alternative 8: 67.3% accurate, 1.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right) \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m) :precision binary64 (* 0.5 (+ y (/ x (/ y x)))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	return 0.5 * (y + (x / (y / x)));
}
z_m = abs(z)
real(8) function code(x, y, z_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = 0.5d0 * (y + (x / (y / x)))
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
	return 0.5 * (y + (x / (y / x)));
}
z_m = math.fabs(z)
def code(x, y, z_m):
	return 0.5 * (y + (x / (y / x)))
z_m = abs(z)
function code(x, y, z_m)
	return Float64(0.5 * Float64(y + Float64(x / Float64(y / x))))
end
z_m = abs(z);
function tmp = code(x, y, z_m)
	tmp = 0.5 * (y + (x / (y / x)));
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|

\\
0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)
\end{array}
Derivation
  1. Initial program 73.3%

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

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left({x}^{2} + {y}^{2}\right)}{y}} \]
    2. rem-square-sqrt47.3%

      \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}}{y} \]
    3. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    4. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    5. hypot-undefine47.3%

      \[\leadsto \frac{0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)}{y} \]
    6. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}\right)}{y} \]
    7. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}\right)}{y} \]
    8. hypot-undefine47.3%

      \[\leadsto \frac{0.5 \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\right)}{y} \]
    9. unpow247.3%

      \[\leadsto \frac{0.5 \cdot \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}}{y} \]
    10. associate-*l/47.2%

      \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \]
    11. *-commutative47.2%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
  5. Simplified47.2%

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} \cdot \frac{0.5}{y}} \]
  6. Taylor expanded in x around 0 61.1%

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x}}{y}\right) \]
    2. *-un-lft-identity61.1%

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
  10. Applied egg-rr64.4%

    \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) \]
  11. Step-by-step derivation
    1. /-rgt-identity64.4%

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

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
  12. Applied egg-rr64.4%

    \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) \]
  13. Add Preprocessing

Alternative 9: 35.0% accurate, 5.0× speedup?

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

\\
0.5 \cdot y
\end{array}
Derivation
  1. Initial program 73.3%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutative34.0%

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified34.0%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification34.0%

    \[\leadsto 0.5 \cdot y \]
  7. Add Preprocessing

Alternative 10: 1.8% accurate, 5.0× speedup?

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

\\
y \cdot -0.5
\end{array}
Derivation
  1. Initial program 73.3%

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

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

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

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

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

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

      \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
    7. pow272.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    2. associate-*r/73.2%

      \[\leadsto \frac{1}{\color{blue}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
  6. Simplified73.2%

    \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
  7. Taylor expanded in y around inf 33.9%

    \[\leadsto \frac{1}{\color{blue}{\frac{2}{y}}} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt18.6%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\frac{2}{y}}} \cdot \sqrt{\frac{1}{\frac{2}{y}}}} \]
    2. sqrt-unprod13.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\frac{2}{y}} \cdot \frac{1}{\frac{2}{y}}}} \]
    3. associate-/r/13.1%

      \[\leadsto \sqrt{\color{blue}{\left(\frac{1}{2} \cdot y\right)} \cdot \frac{1}{\frac{2}{y}}} \]
    4. metadata-eval13.1%

      \[\leadsto \sqrt{\left(\color{blue}{0.5} \cdot y\right) \cdot \frac{1}{\frac{2}{y}}} \]
    5. associate-/r/13.1%

      \[\leadsto \sqrt{\left(0.5 \cdot y\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot y\right)}} \]
    6. metadata-eval13.1%

      \[\leadsto \sqrt{\left(0.5 \cdot y\right) \cdot \left(\color{blue}{0.5} \cdot y\right)} \]
    7. swap-sqr13.1%

      \[\leadsto \sqrt{\color{blue}{\left(0.5 \cdot 0.5\right) \cdot \left(y \cdot y\right)}} \]
    8. metadata-eval13.1%

      \[\leadsto \sqrt{\color{blue}{0.25} \cdot \left(y \cdot y\right)} \]
    9. metadata-eval13.1%

      \[\leadsto \sqrt{\color{blue}{\left(-0.5 \cdot -0.5\right)} \cdot \left(y \cdot y\right)} \]
    10. swap-sqr13.1%

      \[\leadsto \sqrt{\color{blue}{\left(-0.5 \cdot y\right) \cdot \left(-0.5 \cdot y\right)}} \]
    11. sqrt-unprod0.9%

      \[\leadsto \color{blue}{\sqrt{-0.5 \cdot y} \cdot \sqrt{-0.5 \cdot y}} \]
    12. add-sqr-sqrt1.9%

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    13. *-commutative1.9%

      \[\leadsto \color{blue}{y \cdot -0.5} \]
  9. Applied egg-rr1.9%

    \[\leadsto \color{blue}{y \cdot -0.5} \]
  10. Add Preprocessing

Developer target: 99.9% accurate, 1.0× speedup?

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

\\
y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)
\end{array}

Reproduce

?
herbie shell --seed 2024085 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))