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

Percentage Accurate: 69.6% → 99.7%
Time: 11.3s
Alternatives: 5
Speedup: 1.1×

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 5 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: 69.6% 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: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \left(0.5 \cdot \left(y\_m + \frac{x - z}{\sqrt{y\_m}} \cdot \frac{x + z}{\sqrt{y\_m}}\right)\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (* 0.5 (+ y_m (* (/ (- x z) (sqrt y_m)) (/ (+ x z) (sqrt y_m)))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	return y_s * (0.5 * (y_m + (((x - z) / sqrt(y_m)) * ((x + z) / sqrt(y_m)))));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (0.5d0 * (y_m + (((x - z) / sqrt(y_m)) * ((x + z) / sqrt(y_m)))))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	return y_s * (0.5 * (y_m + (((x - z) / Math.sqrt(y_m)) * ((x + z) / Math.sqrt(y_m)))));
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (0.5 * (y_m + (((x - z) / math.sqrt(y_m)) * ((x + z) / math.sqrt(y_m)))))
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(0.5 * Float64(y_m + Float64(Float64(Float64(x - z) / sqrt(y_m)) * Float64(Float64(x + z) / sqrt(y_m))))))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (0.5 * (y_m + (((x - z) / sqrt(y_m)) * ((x + z) / sqrt(y_m)))));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(0.5 * N[(y$95$m + N[(N[(N[(x - z), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \left(0.5 \cdot \left(y\_m + \frac{x - z}{\sqrt{y\_m}} \cdot \frac{x + z}{\sqrt{y\_m}}\right)\right)
\end{array}
Derivation
  1. Initial program 71.1%

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

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

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

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

      \[\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-171.1%

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

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

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

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

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

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

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

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

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

    \[\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 x around 0 82.7%

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\sqrt[3]{\color{blue}{{\left({x}^{2} - {z}^{2}\right)}^{3}}}}{y}\right) \]
  9. Applied egg-rr69.0%

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x} - z \cdot z}{y}\right) \]
    4. difference-of-squares89.4%

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

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

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

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

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

    \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x - z}{\sqrt{y}} \cdot \frac{x + z}{\sqrt{y}}}\right) \]
  14. Final simplification48.7%

    \[\leadsto 0.5 \cdot \left(y + \frac{x - z}{\sqrt{y}} \cdot \frac{x + z}{\sqrt{y}}\right) \]
  15. Add Preprocessing

Alternative 2: 94.1% accurate, 0.5× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq 0:\\ \;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) 0.0)
    (* 0.5 (- y_m (* z (/ z y_m))))
    (* 0.5 (+ y_m (* x (/ x y_m)))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) {
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	} else {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)) <= 0.0d0) then
        tmp = 0.5d0 * (y_m - (z * (z / y_m)))
    else
        tmp = 0.5d0 * (y_m + (x * (x / y_m)))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) {
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	} else {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if ((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0:
		tmp = 0.5 * (y_m - (z * (z / y_m)))
	else:
		tmp = 0.5 * (y_m + (x * (x / y_m)))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= 0.0)
		tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m))));
	else
		tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0)
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	else
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq 0:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\

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


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

    1. Initial program 74.0%

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

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

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

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

        \[\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-174.0%

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

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

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

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

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

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

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

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

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

      \[\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 x around 0 85.3%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\sqrt[3]{\color{blue}{{\left({x}^{2} - {z}^{2}\right)}^{3}}}}{y}\right) \]
    9. Applied egg-rr71.0%

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{\sqrt[3]{{\left({x}^{2} - {z}^{2}\right)}^{3}}}}{y}\right) \]
    10. Step-by-step derivation
      1. rem-cbrt-cube90.3%

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x} - z \cdot z}{y}\right) \]
      4. difference-of-squares90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \left(z \cdot \left(-1 \cdot \frac{x}{y}\right) + \left(z \cdot \frac{x}{y} + z \cdot \color{blue}{\left(-\frac{z}{y}\right)}\right)\right)\right) \]
      19. mul-1-neg61.6%

        \[\leadsto 0.5 \cdot \left(y + \left(z \cdot \left(-1 \cdot \frac{x}{y}\right) + \left(z \cdot \frac{x}{y} + z \cdot \color{blue}{\left(-1 \cdot \frac{z}{y}\right)}\right)\right)\right) \]
      20. distribute-lft-in62.4%

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

        \[\leadsto 0.5 \cdot \left(y + \left(z \cdot \left(-1 \cdot \frac{x}{y}\right) + z \cdot \color{blue}{\left(-1 \cdot \frac{z}{y} + \frac{x}{y}\right)}\right)\right) \]
    14. Simplified66.6%

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

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

    1. Initial program 68.4%

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

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

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

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

        \[\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-168.4%

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

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

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

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

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

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

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

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

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

      \[\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 x around 0 80.3%

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{\sqrt[3]{{\left({x}^{2} - {z}^{2}\right)}^{3}}}}{y}\right) \]
    10. Step-by-step derivation
      1. rem-cbrt-cube81.1%

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x} - z \cdot z}{y}\right) \]
      4. difference-of-squares88.6%

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{\left(x + z\right) \cdot \left(x - z\right)}}{y}\right) \]
    11. Applied egg-rr88.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \left(x \cdot \left(-1 \cdot \frac{z}{y}\right) + \color{blue}{x \cdot \left(\frac{z}{y} + \frac{x}{y}\right)}\right)\right) \]
      14. +-commutative61.6%

        \[\leadsto 0.5 \cdot \left(y + \left(x \cdot \left(-1 \cdot \frac{z}{y}\right) + x \cdot \color{blue}{\left(\frac{x}{y} + \frac{z}{y}\right)}\right)\right) \]
      15. +-commutative61.6%

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

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

        \[\leadsto 0.5 \cdot \left(y + x \cdot \color{blue}{\left(\frac{x}{y} + \left(\frac{z}{y} + -1 \cdot \frac{z}{y}\right)\right)}\right) \]
      18. distribute-rgt1-in64.6%

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

        \[\leadsto 0.5 \cdot \left(y + x \cdot \left(\frac{x}{y} + \color{blue}{0} \cdot \frac{z}{y}\right)\right) \]
      20. mul0-lft67.6%

        \[\leadsto 0.5 \cdot \left(y + x \cdot \left(\frac{x}{y} + \color{blue}{0}\right)\right) \]
    14. Simplified67.6%

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

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

Alternative 3: 72.5% accurate, 1.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 2.05 \cdot 10^{+176}:\\ \;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= z 2.05e+176)
    (* 0.5 (+ y_m (* x (/ x y_m))))
    (* z (* z (/ -0.5 y_m))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.05e+176) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = z * (z * (-0.5 / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 2.05d+176) then
        tmp = 0.5d0 * (y_m + (x * (x / y_m)))
    else
        tmp = z * (z * ((-0.5d0) / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.05e+176) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = z * (z * (-0.5 / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if z <= 2.05e+176:
		tmp = 0.5 * (y_m + (x * (x / y_m)))
	else:
		tmp = z * (z * (-0.5 / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (z <= 2.05e+176)
		tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))));
	else
		tmp = Float64(z * Float64(z * Float64(-0.5 / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (z <= 2.05e+176)
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	else
		tmp = z * (z * (-0.5 / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 2.05e+176], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.05 \cdot 10^{+176}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.05e176

    1. Initial program 72.2%

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

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

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

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

        \[\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-172.2%

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

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

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

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

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

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

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

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

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

      \[\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 x around 0 84.4%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\sqrt[3]{\color{blue}{{\left({x}^{2} - {z}^{2}\right)}^{3}}}}{y}\right) \]
    9. Applied egg-rr69.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{x \cdot x} - z \cdot z}{y}\right) \]
      4. difference-of-squares90.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \left(x \cdot \left(-1 \cdot \frac{z}{y}\right) + \left(x \cdot \frac{z}{y} + \color{blue}{x \cdot \frac{x}{y}}\right)\right)\right) \]
      13. distribute-lft-in68.7%

        \[\leadsto 0.5 \cdot \left(y + \left(x \cdot \left(-1 \cdot \frac{z}{y}\right) + \color{blue}{x \cdot \left(\frac{z}{y} + \frac{x}{y}\right)}\right)\right) \]
      14. +-commutative68.7%

        \[\leadsto 0.5 \cdot \left(y + \left(x \cdot \left(-1 \cdot \frac{z}{y}\right) + x \cdot \color{blue}{\left(\frac{x}{y} + \frac{z}{y}\right)}\right)\right) \]
      15. +-commutative68.7%

        \[\leadsto 0.5 \cdot \left(y + \color{blue}{\left(x \cdot \left(\frac{x}{y} + \frac{z}{y}\right) + x \cdot \left(-1 \cdot \frac{z}{y}\right)\right)}\right) \]
      16. distribute-lft-in71.3%

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

        \[\leadsto 0.5 \cdot \left(y + x \cdot \color{blue}{\left(\frac{x}{y} + \left(\frac{z}{y} + -1 \cdot \frac{z}{y}\right)\right)}\right) \]
      18. distribute-rgt1-in71.2%

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

        \[\leadsto 0.5 \cdot \left(y + x \cdot \left(\frac{x}{y} + \color{blue}{0} \cdot \frac{z}{y}\right)\right) \]
      20. mul0-lft73.8%

        \[\leadsto 0.5 \cdot \left(y + x \cdot \left(\frac{x}{y} + \color{blue}{0}\right)\right) \]
    14. Simplified73.8%

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

    if 2.05e176 < z

    1. Initial program 59.4%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
      2. metadata-eval73.7%

        \[\leadsto \frac{\color{blue}{\left(-0.5\right)} \cdot {z}^{2}}{y} \]
      3. distribute-lft-neg-in73.7%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot {z}^{2}}}{y} \]
      4. *-commutative73.7%

        \[\leadsto \frac{-\color{blue}{{z}^{2} \cdot 0.5}}{y} \]
      5. distribute-neg-frac73.7%

        \[\leadsto \color{blue}{-\frac{{z}^{2} \cdot 0.5}{y}} \]
      6. associate-*r/73.7%

        \[\leadsto -\color{blue}{{z}^{2} \cdot \frac{0.5}{y}} \]
      7. distribute-rgt-neg-in73.7%

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

        \[\leadsto {z}^{2} \cdot \color{blue}{\frac{-0.5}{y}} \]
      9. metadata-eval73.7%

        \[\leadsto {z}^{2} \cdot \frac{\color{blue}{-0.5}}{y} \]
    5. Simplified73.7%

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

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

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left({z}^{2} \cdot \frac{-0.5}{y}\right)}^{3}}} \]
    8. Step-by-step derivation
      1. rem-cbrt-cube73.7%

        \[\leadsto \color{blue}{{z}^{2} \cdot \frac{-0.5}{y}} \]
      2. *-commutative73.7%

        \[\leadsto \color{blue}{\frac{-0.5}{y} \cdot {z}^{2}} \]
      3. unpow273.7%

        \[\leadsto \frac{-0.5}{y} \cdot \color{blue}{\left(z \cdot z\right)} \]
      4. associate-*r*86.3%

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

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

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

Alternative 4: 53.7% accurate, 1.2× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 3 \cdot 10^{+38}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\_m\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= y_m 3e+38) (* z (* z (/ -0.5 y_m))) (* 0.5 y_m))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 3e+38) {
		tmp = z * (z * (-0.5 / y_m));
	} else {
		tmp = 0.5 * y_m;
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y_m <= 3d+38) then
        tmp = z * (z * ((-0.5d0) / y_m))
    else
        tmp = 0.5d0 * y_m
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 3e+38) {
		tmp = z * (z * (-0.5 / y_m));
	} else {
		tmp = 0.5 * y_m;
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if y_m <= 3e+38:
		tmp = z * (z * (-0.5 / y_m))
	else:
		tmp = 0.5 * y_m
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 3e+38)
		tmp = Float64(z * Float64(z * Float64(-0.5 / y_m)));
	else
		tmp = Float64(0.5 * y_m);
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (y_m <= 3e+38)
		tmp = z * (z * (-0.5 / y_m));
	else
		tmp = 0.5 * y_m;
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 3e+38], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 3 \cdot 10^{+38}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.0000000000000001e38

    1. Initial program 76.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
      2. metadata-eval35.5%

        \[\leadsto \frac{\color{blue}{\left(-0.5\right)} \cdot {z}^{2}}{y} \]
      3. distribute-lft-neg-in35.5%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot {z}^{2}}}{y} \]
      4. *-commutative35.5%

        \[\leadsto \frac{-\color{blue}{{z}^{2} \cdot 0.5}}{y} \]
      5. distribute-neg-frac35.5%

        \[\leadsto \color{blue}{-\frac{{z}^{2} \cdot 0.5}{y}} \]
      6. associate-*r/35.5%

        \[\leadsto -\color{blue}{{z}^{2} \cdot \frac{0.5}{y}} \]
      7. distribute-rgt-neg-in35.5%

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

        \[\leadsto {z}^{2} \cdot \color{blue}{\frac{-0.5}{y}} \]
      9. metadata-eval35.5%

        \[\leadsto {z}^{2} \cdot \frac{\color{blue}{-0.5}}{y} \]
    5. Simplified35.5%

      \[\leadsto \color{blue}{{z}^{2} \cdot \frac{-0.5}{y}} \]
    6. Step-by-step derivation
      1. add-cbrt-cube28.2%

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

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left({z}^{2} \cdot \frac{-0.5}{y}\right)}^{3}}} \]
    8. Step-by-step derivation
      1. rem-cbrt-cube35.5%

        \[\leadsto \color{blue}{{z}^{2} \cdot \frac{-0.5}{y}} \]
      2. *-commutative35.5%

        \[\leadsto \color{blue}{\frac{-0.5}{y} \cdot {z}^{2}} \]
      3. unpow235.5%

        \[\leadsto \frac{-0.5}{y} \cdot \color{blue}{\left(z \cdot z\right)} \]
      4. associate-*r*37.7%

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

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

    if 3.0000000000000001e38 < y

    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 68.6%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified68.6%

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.8%

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

Alternative 5: 34.2% accurate, 5.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \left(0.5 \cdot y\_m\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z) :precision binary64 (* y_s (* 0.5 y_m)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	return y_s * (0.5 * y_m);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (0.5d0 * y_m)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	return y_s * (0.5 * y_m);
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (0.5 * y_m)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(0.5 * y_m))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (0.5 * y_m);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(0.5 * y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \left(0.5 \cdot y\_m\right)
\end{array}
Derivation
  1. Initial program 71.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 36.9%

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified36.9%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification36.9%

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

Developer target: 99.8% 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 2024100 
(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)))