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

Percentage Accurate: 69.7% → 96.5%
Time: 13.8s
Alternatives: 10
Speedup: 0.9×

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: 69.7% 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: 96.5% accurate, 0.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := x \cdot \sqrt{\frac{0.5}{y_m}}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 0.8:\\ \;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_0, t_0, 0.5 \cdot \left(y_m - z \cdot \frac{z}{y_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* x (sqrt (/ 0.5 y_m)))))
   (*
    y_s
    (if (<= y_m 0.8)
      (/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
      (fma t_0 t_0 (* 0.5 (- y_m (* z (/ z 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 t_0 = x * sqrt((0.5 / y_m));
	double tmp;
	if (y_m <= 0.8) {
		tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
	} else {
		tmp = fma(t_0, t_0, (0.5 * (y_m - (z * (z / y_m)))));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(x * sqrt(Float64(0.5 / y_m)))
	tmp = 0.0
	if (y_m <= 0.8)
		tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0));
	else
		tmp = fma(t_0, t_0, Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))));
	end
	return Float64(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_] := Block[{t$95$0 = N[(x * N[Sqrt[N[(0.5 / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 0.8], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0 + N[(0.5 * N[(y$95$m - N[(z * N[(z / 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)

\\
\begin{array}{l}
t_0 := x \cdot \sqrt{\frac{0.5}{y_m}}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 0.8:\\
\;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_0, 0.5 \cdot \left(y_m - z \cdot \frac{z}{y_m}\right)\right)\\


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

    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. associate--l+74.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y + \left(-z\right), y - \left(-z\right), x \cdot x\right)}}{y \cdot 2} \]
      6. sub-neg75.9%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y - z}, y - \left(-z\right), x \cdot x\right)}{y \cdot 2} \]
      7. sub-neg75.9%

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg75.9%

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

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

    if 0.80000000000000004 < y

    1. Initial program 39.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. associate--l+39.3%

        \[\leadsto \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y \cdot 2} \]
      2. difference-of-squares44.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x \cdot \sqrt{\frac{0.5}{y}}, x \cdot \sqrt{\frac{0.5}{y}}, 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right)\right) \]
      2. *-un-lft-identity84.1%

        \[\leadsto \mathsf{fma}\left(x \cdot \sqrt{\frac{0.5}{y}}, x \cdot \sqrt{\frac{0.5}{y}}, 0.5 \cdot \left(y - \frac{z \cdot z}{\color{blue}{1 \cdot y}}\right)\right) \]
      3. times-frac99.8%

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

      \[\leadsto \mathsf{fma}\left(x \cdot \sqrt{\frac{0.5}{y}}, x \cdot \sqrt{\frac{0.5}{y}}, 0.5 \cdot \left(y - \color{blue}{\frac{z}{1} \cdot \frac{z}{y}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.9%

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

Alternative 2: 88.5% accurate, 0.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := {\left(\sqrt{0.5}\right)}^{2} \cdot \left(y_m - \frac{{z}^{2}}{y_m}\right) + x \cdot \frac{x \cdot 0.5}{y_m}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 3.5 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+125}:\\ \;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+147}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0
         (+
          (* (pow (sqrt 0.5) 2.0) (- y_m (/ (pow z 2.0) y_m)))
          (* x (/ (* x 0.5) y_m)))))
   (*
    y_s
    (if (<= z 3.5e+63)
      t_0
      (if (<= z 1.52e+125)
        (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
        (if (<= z 5.4e+147) t_0 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = (pow(sqrt(0.5), 2.0) * (y_m - (pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m));
	double tmp;
	if (z <= 3.5e+63) {
		tmp = t_0;
	} else if (z <= 1.52e+125) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else if (z <= 5.4e+147) {
		tmp = t_0;
	} else {
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = ((sqrt(0.5d0) ** 2.0d0) * (y_m - ((z ** 2.0d0) / y_m))) + (x * ((x * 0.5d0) / y_m))
    if (z <= 3.5d+63) then
        tmp = t_0
    else if (z <= 1.52d+125) then
        tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
    else if (z <= 5.4d+147) then
        tmp = t_0
    else
        tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
    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 t_0 = (Math.pow(Math.sqrt(0.5), 2.0) * (y_m - (Math.pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m));
	double tmp;
	if (z <= 3.5e+63) {
		tmp = t_0;
	} else if (z <= 1.52e+125) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else if (z <= 5.4e+147) {
		tmp = t_0;
	} else {
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = (math.pow(math.sqrt(0.5), 2.0) * (y_m - (math.pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m))
	tmp = 0
	if z <= 3.5e+63:
		tmp = t_0
	elif z <= 1.52e+125:
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	elif z <= 5.4e+147:
		tmp = t_0
	else:
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64((sqrt(0.5) ^ 2.0) * Float64(y_m - Float64((z ^ 2.0) / y_m))) + Float64(x * Float64(Float64(x * 0.5) / y_m)))
	tmp = 0.0
	if (z <= 3.5e+63)
		tmp = t_0;
	elseif (z <= 1.52e+125)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0));
	elseif (z <= 5.4e+147)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0));
	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)
	t_0 = ((sqrt(0.5) ^ 2.0) * (y_m - ((z ^ 2.0) / y_m))) + (x * ((x * 0.5) / y_m));
	tmp = 0.0;
	if (z <= 3.5e+63)
		tmp = t_0;
	elseif (z <= 1.52e+125)
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	elseif (z <= 5.4e+147)
		tmp = t_0;
	else
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	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_] := Block[{t$95$0 = N[(N[(N[Power[N[Sqrt[0.5], $MachinePrecision], 2.0], $MachinePrecision] * N[(y$95$m - N[(N[Power[z, 2.0], $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(x * 0.5), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 3.5e+63], t$95$0, If[LessEqual[z, 1.52e+125], 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], If[LessEqual[z, 5.4e+147], t$95$0, N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := {\left(\sqrt{0.5}\right)}^{2} \cdot \left(y_m - \frac{{z}^{2}}{y_m}\right) + x \cdot \frac{x \cdot 0.5}{y_m}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.52 \cdot 10^{+125}:\\
\;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\

\mathbf{elif}\;z \leq 5.4 \cdot 10^{+147}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 3.50000000000000029e63 or 1.5199999999999999e125 < z < 5.39999999999999995e147

    1. Initial program 66.8%

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

        \[\leadsto \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y \cdot 2} \]
      2. difference-of-squares67.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y - z, y + z, x \cdot x\right)}}{y \cdot 2} \]
      6. add-sqr-sqrt33.8%

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

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{\mathsf{fma}\left(y - z, y + z, x \cdot x\right)}{y \cdot 2}}\right)}^{2}} \]
    4. Applied egg-rr32.7%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt{0.5}\right)}^{2} \cdot \left(y - \frac{{z}^{2}}{y}\right) + \left(x \cdot x\right) \cdot \frac{\color{blue}{0.5}}{y} \]
      8. associate-*r*87.6%

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

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

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

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

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

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

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

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

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

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

    if 3.50000000000000029e63 < z < 1.5199999999999999e125

    1. Initial program 73.4%

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

    if 5.39999999999999995e147 < z

    1. Initial program 45.6%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y + \left(-z\right), y - \left(-z\right), x \cdot x\right)}}{y \cdot 2} \]
      6. sub-neg60.8%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y - z}, y - \left(-z\right), x \cdot x\right)}{y \cdot 2} \]
      7. sub-neg60.8%

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg60.8%

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv89.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u35.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)\right)} \]
      2. expm1-udef35.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)} - 1} \]
      3. un-div-inv35.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y + z}{2 \cdot \frac{y}{y - z}}}\right)} - 1 \]
      4. *-un-lft-identity35.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{1 \cdot \left(y + z\right)}}{2 \cdot \frac{y}{y - z}}\right)} - 1 \]
      5. *-commutative35.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{1 \cdot \left(y + z\right)}{\color{blue}{\frac{y}{y - z} \cdot 2}}\right)} - 1 \]
      6. times-frac35.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y}{y - z}} \cdot \frac{y + z}{2}}\right)} - 1 \]
      7. clear-num35.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y - z}{y}} \cdot \frac{y + z}{2}\right)} - 1 \]
    9. Applied egg-rr35.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def35.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)\right)} \]
      2. expm1-log1p89.6%

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    11. Simplified89.6%

      \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.5 \cdot 10^{+63}:\\ \;\;\;\;{\left(\sqrt{0.5}\right)}^{2} \cdot \left(y - \frac{{z}^{2}}{y}\right) + x \cdot \frac{x \cdot 0.5}{y}\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+125}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+147}:\\ \;\;\;\;{\left(\sqrt{0.5}\right)}^{2} \cdot \left(y - \frac{{z}^{2}}{y}\right) + x \cdot \frac{x \cdot 0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 90.1% accurate, 0.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}\;y_m \leq 1.45 \cdot 10^{+72}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 1.45e+72)
    (/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
    (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0)))))
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 <= 1.45e+72) {
		tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
	} else {
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	}
	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 <= 1.45e+72)
		tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0));
	else
		tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0));
	end
	return Float64(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, 1.45e+72], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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}\;y_m \leq 1.45 \cdot 10^{+72}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\


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

    1. Initial program 74.5%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y + \left(-z\right), y - \left(-z\right), x \cdot x\right)}}{y \cdot 2} \]
      6. sub-neg76.7%

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

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg76.7%

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

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

    if 1.45000000000000009e72 < y

    1. Initial program 26.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv88.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u63.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)\right)} \]
      2. expm1-udef63.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)} - 1} \]
      3. un-div-inv63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y + z}{2 \cdot \frac{y}{y - z}}}\right)} - 1 \]
      4. *-un-lft-identity63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{1 \cdot \left(y + z\right)}}{2 \cdot \frac{y}{y - z}}\right)} - 1 \]
      5. *-commutative63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{1 \cdot \left(y + z\right)}{\color{blue}{\frac{y}{y - z} \cdot 2}}\right)} - 1 \]
      6. times-frac63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y}{y - z}} \cdot \frac{y + z}{2}}\right)} - 1 \]
      7. clear-num63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y - z}{y}} \cdot \frac{y + z}{2}\right)} - 1 \]
    9. Applied egg-rr63.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def63.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)\right)} \]
      2. expm1-log1p88.3%

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    11. Simplified88.3%

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

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

Alternative 4: 73.4% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \left(y_m - z\right) \cdot \left(\left(y_m + z\right) \cdot \frac{0.5}{y_m}\right)\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 1.7 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{+80}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+194}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* (- y_m z) (* (+ y_m z) (/ 0.5 y_m)))))
   (*
    y_s
    (if (<= x 1.7e+71)
      t_0
      (if (<= x 1e+80)
        (/ (* x (/ x y_m)) 2.0)
        (if (<= x 6.5e+194) t_0 (/ x (* 2.0 (/ y_m x)))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m));
	double tmp;
	if (x <= 1.7e+71) {
		tmp = t_0;
	} else if (x <= 1e+80) {
		tmp = (x * (x / y_m)) / 2.0;
	} else if (x <= 6.5e+194) {
		tmp = t_0;
	} else {
		tmp = x / (2.0 * (y_m / x));
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (y_m - z) * ((y_m + z) * (0.5d0 / y_m))
    if (x <= 1.7d+71) then
        tmp = t_0
    else if (x <= 1d+80) then
        tmp = (x * (x / y_m)) / 2.0d0
    else if (x <= 6.5d+194) then
        tmp = t_0
    else
        tmp = x / (2.0d0 * (y_m / x))
    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 t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m));
	double tmp;
	if (x <= 1.7e+71) {
		tmp = t_0;
	} else if (x <= 1e+80) {
		tmp = (x * (x / y_m)) / 2.0;
	} else if (x <= 6.5e+194) {
		tmp = t_0;
	} else {
		tmp = x / (2.0 * (y_m / x));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m))
	tmp = 0
	if x <= 1.7e+71:
		tmp = t_0
	elif x <= 1e+80:
		tmp = (x * (x / y_m)) / 2.0
	elif x <= 6.5e+194:
		tmp = t_0
	else:
		tmp = x / (2.0 * (y_m / x))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(y_m - z) * Float64(Float64(y_m + z) * Float64(0.5 / y_m)))
	tmp = 0.0
	if (x <= 1.7e+71)
		tmp = t_0;
	elseif (x <= 1e+80)
		tmp = Float64(Float64(x * Float64(x / y_m)) / 2.0);
	elseif (x <= 6.5e+194)
		tmp = t_0;
	else
		tmp = Float64(x / Float64(2.0 * Float64(y_m / x)));
	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)
	t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m));
	tmp = 0.0;
	if (x <= 1.7e+71)
		tmp = t_0;
	elseif (x <= 1e+80)
		tmp = (x * (x / y_m)) / 2.0;
	elseif (x <= 6.5e+194)
		tmp = t_0;
	else
		tmp = x / (2.0 * (y_m / x));
	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_] := Block[{t$95$0 = N[(N[(y$95$m - z), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.7e+71], t$95$0, If[LessEqual[x, 1e+80], N[(N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.5e+194], t$95$0, N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \left(y_m - z\right) \cdot \left(\left(y_m + z\right) \cdot \frac{0.5}{y_m}\right)\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{+71}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 10^{+80}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{+194}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.6999999999999999e71 or 1e80 < x < 6.50000000000000005e194

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(y + z\right) \cdot \left(y - z\right)}}{y \cdot 2} \]
    6. Step-by-step derivation
      1. div-inv48.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6999999999999999e71 < x < 1e80

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac99.7%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    5. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{y} \cdot x}{2}} \]
    7. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{y} \cdot x}{2}} \]

    if 6.50000000000000005e194 < x

    1. Initial program 70.6%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv85.6%

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

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{2 \cdot y}} \]
      3. associate-/r*85.6%

        \[\leadsto {x}^{2} \cdot \color{blue}{\frac{\frac{1}{2}}{y}} \]
      4. metadata-eval85.6%

        \[\leadsto {x}^{2} \cdot \frac{\color{blue}{0.5}}{y} \]
      5. unpow285.6%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      6. associate-*l*90.2%

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    6. Step-by-step derivation
      1. metadata-eval90.2%

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

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

        \[\leadsto x \cdot \left(x \cdot \frac{\color{blue}{{\left(\sqrt{0.5}\right)}^{2}}}{y}\right) \]
      4. associate-*r/90.2%

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

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

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

        \[\leadsto x \cdot \frac{1}{\frac{y}{x \cdot {0.5}^{\color{blue}{1}}}} \]
      8. metadata-eval90.3%

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{x \cdot 0.5}}} \]
    8. Step-by-step derivation
      1. un-div-inv90.3%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x \cdot 0.5}}} \]
      2. *-un-lft-identity90.3%

        \[\leadsto \frac{x}{\frac{\color{blue}{1 \cdot y}}{x \cdot 0.5}} \]
      3. *-commutative90.3%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{1}{0.5} \cdot \frac{y}{x}}} \]
      5. metadata-eval90.3%

        \[\leadsto \frac{x}{\color{blue}{2} \cdot \frac{y}{x}} \]
    9. Applied egg-rr90.3%

      \[\leadsto \color{blue}{\frac{x}{2 \cdot \frac{y}{x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.9%

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

Alternative 5: 73.5% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 1.75 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+195}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))
   (*
    y_s
    (if (<= x 1.75e+72)
      t_0
      (if (<= x 9.5e+79)
        (/ (* x (/ x y_m)) 2.0)
        (if (<= x 2.2e+195) t_0 (/ x (* 2.0 (/ y_m x)))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	double tmp;
	if (x <= 1.75e+72) {
		tmp = t_0;
	} else if (x <= 9.5e+79) {
		tmp = (x * (x / y_m)) / 2.0;
	} else if (x <= 2.2e+195) {
		tmp = t_0;
	} else {
		tmp = x / (2.0 * (y_m / x));
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
    if (x <= 1.75d+72) then
        tmp = t_0
    else if (x <= 9.5d+79) then
        tmp = (x * (x / y_m)) / 2.0d0
    else if (x <= 2.2d+195) then
        tmp = t_0
    else
        tmp = x / (2.0d0 * (y_m / x))
    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 t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	double tmp;
	if (x <= 1.75e+72) {
		tmp = t_0;
	} else if (x <= 9.5e+79) {
		tmp = (x * (x / y_m)) / 2.0;
	} else if (x <= 2.2e+195) {
		tmp = t_0;
	} else {
		tmp = x / (2.0 * (y_m / x));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0)
	tmp = 0
	if x <= 1.75e+72:
		tmp = t_0
	elif x <= 9.5e+79:
		tmp = (x * (x / y_m)) / 2.0
	elif x <= 2.2e+195:
		tmp = t_0
	else:
		tmp = x / (2.0 * (y_m / x))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0))
	tmp = 0.0
	if (x <= 1.75e+72)
		tmp = t_0;
	elseif (x <= 9.5e+79)
		tmp = Float64(Float64(x * Float64(x / y_m)) / 2.0);
	elseif (x <= 2.2e+195)
		tmp = t_0;
	else
		tmp = Float64(x / Float64(2.0 * Float64(y_m / x)));
	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)
	t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	tmp = 0.0;
	if (x <= 1.75e+72)
		tmp = t_0;
	elseif (x <= 9.5e+79)
		tmp = (x * (x / y_m)) / 2.0;
	elseif (x <= 2.2e+195)
		tmp = t_0;
	else
		tmp = x / (2.0 * (y_m / x));
	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_] := Block[{t$95$0 = N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.75e+72], t$95$0, If[LessEqual[x, 9.5e+79], N[(N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.2e+195], t$95$0, N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+72}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 9.5 \cdot 10^{+79}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+195}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.75000000000000005e72 or 9.49999999999999994e79 < x < 2.2e195

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv75.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)\right)} \]
      2. expm1-udef33.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)} - 1} \]
      3. un-div-inv33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y + z}{2 \cdot \frac{y}{y - z}}}\right)} - 1 \]
      4. *-un-lft-identity33.0%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y}{y - z}} \cdot \frac{y + z}{2}}\right)} - 1 \]
      7. clear-num33.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y - z}{y}} \cdot \frac{y + z}{2}\right)} - 1 \]
    9. Applied egg-rr33.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def38.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)\right)} \]
      2. expm1-log1p75.4%

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    11. Simplified75.4%

      \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]

    if 1.75000000000000005e72 < x < 9.49999999999999994e79

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac99.7%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    5. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{y} \cdot x}{2}} \]
    7. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{y} \cdot x}{2}} \]

    if 2.2e195 < x

    1. Initial program 70.6%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv85.6%

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

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{2 \cdot y}} \]
      3. associate-/r*85.6%

        \[\leadsto {x}^{2} \cdot \color{blue}{\frac{\frac{1}{2}}{y}} \]
      4. metadata-eval85.6%

        \[\leadsto {x}^{2} \cdot \frac{\color{blue}{0.5}}{y} \]
      5. unpow285.6%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      6. associate-*l*90.2%

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    6. Step-by-step derivation
      1. metadata-eval90.2%

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

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

        \[\leadsto x \cdot \left(x \cdot \frac{\color{blue}{{\left(\sqrt{0.5}\right)}^{2}}}{y}\right) \]
      4. associate-*r/90.2%

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

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

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

        \[\leadsto x \cdot \frac{1}{\frac{y}{x \cdot {0.5}^{\color{blue}{1}}}} \]
      8. metadata-eval90.3%

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{x \cdot 0.5}}} \]
    8. Step-by-step derivation
      1. un-div-inv90.3%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x \cdot 0.5}}} \]
      2. *-un-lft-identity90.3%

        \[\leadsto \frac{x}{\frac{\color{blue}{1 \cdot y}}{x \cdot 0.5}} \]
      3. *-commutative90.3%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{1}{0.5} \cdot \frac{y}{x}}} \]
      5. metadata-eval90.3%

        \[\leadsto \frac{x}{\color{blue}{2} \cdot \frac{y}{x}} \]
    9. Applied egg-rr90.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.75 \cdot 10^{+72}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y}}{2}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+195}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 88.6% accurate, 0.9× 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.4 \cdot 10^{+73}:\\ \;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 3.4e+73)
    (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
    (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0)))))
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 <= 3.4e+73) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	}
	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 <= 3.4d+73) then
        tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
    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 <= 3.4e+73) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	}
	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 <= 3.4e+73:
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0)
	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 <= 3.4e+73)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0));
	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 <= 3.4e+73)
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	else
		tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	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, 3.4e+73], 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], N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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}\;y_m \leq 3.4 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\


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

    1. Initial program 74.5%

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

    if 3.4000000000000002e73 < y

    1. Initial program 26.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv88.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u63.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)\right)} \]
      2. expm1-udef63.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(y + z\right) \cdot \frac{1}{2 \cdot \frac{y}{y - z}}\right)} - 1} \]
      3. un-div-inv63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y + z}{2 \cdot \frac{y}{y - z}}}\right)} - 1 \]
      4. *-un-lft-identity63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{1 \cdot \left(y + z\right)}}{2 \cdot \frac{y}{y - z}}\right)} - 1 \]
      5. *-commutative63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{1 \cdot \left(y + z\right)}{\color{blue}{\frac{y}{y - z} \cdot 2}}\right)} - 1 \]
      6. times-frac63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y}{y - z}} \cdot \frac{y + z}{2}}\right)} - 1 \]
      7. clear-num63.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{y - z}{y}} \cdot \frac{y + z}{2}\right)} - 1 \]
    9. Applied egg-rr63.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def63.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - z}{y} \cdot \frac{y + z}{2}\right)\right)} \]
      2. expm1-log1p88.3%

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    11. Simplified88.3%

      \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.5%

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

Alternative 7: 43.8% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot \frac{0.5}{y_m}\right)\\ y_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 1.7 \cdot 10^{-207}:\\ \;\;\;\;\left(y_m + z\right) \cdot 0.5\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-50}:\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* x (* x (/ 0.5 y_m)))))
   (*
    y_s
    (if (<= z 1.7e-207)
      (* (+ y_m z) 0.5)
      (if (<= z 3.5e-181)
        t_0
        (if (<= z 4.1e-50)
          (* y_m 0.5)
          (if (<= z 3e+143) t_0 (* (/ z y_m) (/ z -2.0)))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = x * (x * (0.5 / y_m));
	double tmp;
	if (z <= 1.7e-207) {
		tmp = (y_m + z) * 0.5;
	} else if (z <= 3.5e-181) {
		tmp = t_0;
	} else if (z <= 4.1e-50) {
		tmp = y_m * 0.5;
	} else if (z <= 3e+143) {
		tmp = t_0;
	} else {
		tmp = (z / y_m) * (z / -2.0);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = x * (x * (0.5d0 / y_m))
    if (z <= 1.7d-207) then
        tmp = (y_m + z) * 0.5d0
    else if (z <= 3.5d-181) then
        tmp = t_0
    else if (z <= 4.1d-50) then
        tmp = y_m * 0.5d0
    else if (z <= 3d+143) then
        tmp = t_0
    else
        tmp = (z / y_m) * (z / (-2.0d0))
    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 t_0 = x * (x * (0.5 / y_m));
	double tmp;
	if (z <= 1.7e-207) {
		tmp = (y_m + z) * 0.5;
	} else if (z <= 3.5e-181) {
		tmp = t_0;
	} else if (z <= 4.1e-50) {
		tmp = y_m * 0.5;
	} else if (z <= 3e+143) {
		tmp = t_0;
	} else {
		tmp = (z / y_m) * (z / -2.0);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = x * (x * (0.5 / y_m))
	tmp = 0
	if z <= 1.7e-207:
		tmp = (y_m + z) * 0.5
	elif z <= 3.5e-181:
		tmp = t_0
	elif z <= 4.1e-50:
		tmp = y_m * 0.5
	elif z <= 3e+143:
		tmp = t_0
	else:
		tmp = (z / y_m) * (z / -2.0)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(x * Float64(x * Float64(0.5 / y_m)))
	tmp = 0.0
	if (z <= 1.7e-207)
		tmp = Float64(Float64(y_m + z) * 0.5);
	elseif (z <= 3.5e-181)
		tmp = t_0;
	elseif (z <= 4.1e-50)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 3e+143)
		tmp = t_0;
	else
		tmp = Float64(Float64(z / y_m) * Float64(z / -2.0));
	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)
	t_0 = x * (x * (0.5 / y_m));
	tmp = 0.0;
	if (z <= 1.7e-207)
		tmp = (y_m + z) * 0.5;
	elseif (z <= 3.5e-181)
		tmp = t_0;
	elseif (z <= 4.1e-50)
		tmp = y_m * 0.5;
	elseif (z <= 3e+143)
		tmp = t_0;
	else
		tmp = (z / y_m) * (z / -2.0);
	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_] := Block[{t$95$0 = N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.7e-207], N[(N[(y$95$m + z), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[z, 3.5e-181], t$95$0, If[LessEqual[z, 4.1e-50], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 3e+143], t$95$0, N[(N[(z / y$95$m), $MachinePrecision] * N[(z / -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \frac{0.5}{y_m}\right)\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{-207}:\\
\;\;\;\;\left(y_m + z\right) \cdot 0.5\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{-181}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 4.1 \cdot 10^{-50}:\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{elif}\;z \leq 3 \cdot 10^{+143}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 1.69999999999999999e-207

    1. Initial program 67.1%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y + \left(-z\right), y - \left(-z\right), x \cdot x\right)}}{y \cdot 2} \]
      6. sub-neg69.8%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y - z}, y - \left(-z\right), x \cdot x\right)}{y \cdot 2} \]
      7. sub-neg69.8%

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg69.8%

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv68.4%

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

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

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

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

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

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

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

    if 1.69999999999999999e-207 < z < 3.49999999999999996e-181 or 4.09999999999999985e-50 < z < 3.0000000000000001e143

    1. Initial program 72.5%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv51.5%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. *-commutative51.5%

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{2 \cdot y}} \]
      3. associate-/r*51.5%

        \[\leadsto {x}^{2} \cdot \color{blue}{\frac{\frac{1}{2}}{y}} \]
      4. metadata-eval51.5%

        \[\leadsto {x}^{2} \cdot \frac{\color{blue}{0.5}}{y} \]
      5. unpow251.5%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      6. associate-*l*56.9%

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

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

    if 3.49999999999999996e-181 < z < 4.09999999999999985e-50

    1. Initial program 58.4%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]

    if 3.0000000000000001e143 < z

    1. Initial program 47.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y - z, y + z, x \cdot x\right)}}{y \cdot 2} \]
      6. clear-num61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{y \cdot -2}}{{z}^{2}}\right)}^{-1} \]
    7. Simplified54.5%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot -2}{{z}^{2}}}} \]
      2. clear-num54.5%

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{y \cdot -2} \]
      4. times-frac68.7%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
    9. Applied egg-rr68.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.7 \cdot 10^{-207}:\\ \;\;\;\;\left(y + z\right) \cdot 0.5\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-181}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-50}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+143}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 43.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{x}{2 \cdot \frac{y_m}{x}}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 5.9 \cdot 10^{-210}:\\ \;\;\;\;\left(y_m + z\right) \cdot 0.5\\ \mathbf{elif}\;z \leq 1.62 \cdot 10^{-180}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-50}:\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ x (* 2.0 (/ y_m x)))))
   (*
    y_s
    (if (<= z 5.9e-210)
      (* (+ y_m z) 0.5)
      (if (<= z 1.62e-180)
        t_0
        (if (<= z 1.02e-50)
          (* y_m 0.5)
          (if (<= z 7.5e+143) t_0 (* (/ z y_m) (/ z -2.0)))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = x / (2.0 * (y_m / x));
	double tmp;
	if (z <= 5.9e-210) {
		tmp = (y_m + z) * 0.5;
	} else if (z <= 1.62e-180) {
		tmp = t_0;
	} else if (z <= 1.02e-50) {
		tmp = y_m * 0.5;
	} else if (z <= 7.5e+143) {
		tmp = t_0;
	} else {
		tmp = (z / y_m) * (z / -2.0);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 * (y_m / x))
    if (z <= 5.9d-210) then
        tmp = (y_m + z) * 0.5d0
    else if (z <= 1.62d-180) then
        tmp = t_0
    else if (z <= 1.02d-50) then
        tmp = y_m * 0.5d0
    else if (z <= 7.5d+143) then
        tmp = t_0
    else
        tmp = (z / y_m) * (z / (-2.0d0))
    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 t_0 = x / (2.0 * (y_m / x));
	double tmp;
	if (z <= 5.9e-210) {
		tmp = (y_m + z) * 0.5;
	} else if (z <= 1.62e-180) {
		tmp = t_0;
	} else if (z <= 1.02e-50) {
		tmp = y_m * 0.5;
	} else if (z <= 7.5e+143) {
		tmp = t_0;
	} else {
		tmp = (z / y_m) * (z / -2.0);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = x / (2.0 * (y_m / x))
	tmp = 0
	if z <= 5.9e-210:
		tmp = (y_m + z) * 0.5
	elif z <= 1.62e-180:
		tmp = t_0
	elif z <= 1.02e-50:
		tmp = y_m * 0.5
	elif z <= 7.5e+143:
		tmp = t_0
	else:
		tmp = (z / y_m) * (z / -2.0)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(x / Float64(2.0 * Float64(y_m / x)))
	tmp = 0.0
	if (z <= 5.9e-210)
		tmp = Float64(Float64(y_m + z) * 0.5);
	elseif (z <= 1.62e-180)
		tmp = t_0;
	elseif (z <= 1.02e-50)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 7.5e+143)
		tmp = t_0;
	else
		tmp = Float64(Float64(z / y_m) * Float64(z / -2.0));
	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)
	t_0 = x / (2.0 * (y_m / x));
	tmp = 0.0;
	if (z <= 5.9e-210)
		tmp = (y_m + z) * 0.5;
	elseif (z <= 1.62e-180)
		tmp = t_0;
	elseif (z <= 1.02e-50)
		tmp = y_m * 0.5;
	elseif (z <= 7.5e+143)
		tmp = t_0;
	else
		tmp = (z / y_m) * (z / -2.0);
	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_] := Block[{t$95$0 = N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 5.9e-210], N[(N[(y$95$m + z), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[z, 1.62e-180], t$95$0, If[LessEqual[z, 1.02e-50], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 7.5e+143], t$95$0, N[(N[(z / y$95$m), $MachinePrecision] * N[(z / -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{x}{2 \cdot \frac{y_m}{x}}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 5.9 \cdot 10^{-210}:\\
\;\;\;\;\left(y_m + z\right) \cdot 0.5\\

\mathbf{elif}\;z \leq 1.62 \cdot 10^{-180}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{-50}:\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{elif}\;z \leq 7.5 \cdot 10^{+143}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 5.8999999999999999e-210

    1. Initial program 67.1%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y + \left(-z\right), y - \left(-z\right), x \cdot x\right)}}{y \cdot 2} \]
      6. sub-neg69.8%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y - z}, y - \left(-z\right), x \cdot x\right)}{y \cdot 2} \]
      7. sub-neg69.8%

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg69.8%

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv68.4%

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

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

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

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

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

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

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

    if 5.8999999999999999e-210 < z < 1.61999999999999996e-180 or 1.0199999999999999e-50 < z < 7.49999999999999974e143

    1. Initial program 72.5%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv51.5%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. *-commutative51.5%

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{2 \cdot y}} \]
      3. associate-/r*51.5%

        \[\leadsto {x}^{2} \cdot \color{blue}{\frac{\frac{1}{2}}{y}} \]
      4. metadata-eval51.5%

        \[\leadsto {x}^{2} \cdot \frac{\color{blue}{0.5}}{y} \]
      5. unpow251.5%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      6. associate-*l*56.9%

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    6. Step-by-step derivation
      1. metadata-eval56.9%

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

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

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

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

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

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

        \[\leadsto x \cdot \frac{1}{\frac{y}{x \cdot {0.5}^{\color{blue}{1}}}} \]
      8. metadata-eval56.9%

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{x \cdot 0.5}}} \]
    8. Step-by-step derivation
      1. un-div-inv57.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x \cdot 0.5}}} \]
      2. *-un-lft-identity57.0%

        \[\leadsto \frac{x}{\frac{\color{blue}{1 \cdot y}}{x \cdot 0.5}} \]
      3. *-commutative57.0%

        \[\leadsto \frac{x}{\frac{1 \cdot y}{\color{blue}{0.5 \cdot x}}} \]
      4. times-frac57.0%

        \[\leadsto \frac{x}{\color{blue}{\frac{1}{0.5} \cdot \frac{y}{x}}} \]
      5. metadata-eval57.0%

        \[\leadsto \frac{x}{\color{blue}{2} \cdot \frac{y}{x}} \]
    9. Applied egg-rr57.0%

      \[\leadsto \color{blue}{\frac{x}{2 \cdot \frac{y}{x}}} \]

    if 1.61999999999999996e-180 < z < 1.0199999999999999e-50

    1. Initial program 58.4%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]

    if 7.49999999999999974e143 < z

    1. Initial program 47.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y - z, y + z, x \cdot x\right)}}{y \cdot 2} \]
      6. clear-num61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{y \cdot -2}}{{z}^{2}}\right)}^{-1} \]
    7. Simplified54.5%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot -2}{{z}^{2}}}} \]
      2. clear-num54.5%

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{y \cdot -2} \]
      4. times-frac68.7%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
    9. Applied egg-rr68.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.9 \cdot 10^{-210}:\\ \;\;\;\;\left(y + z\right) \cdot 0.5\\ \mathbf{elif}\;z \leq 1.62 \cdot 10^{-180}:\\ \;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-50}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+143}:\\ \;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 52.8% accurate, 1.7× 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 2 \cdot 10^{+63}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y_m}\right)\\ \mathbf{else}:\\ \;\;\;\;y_m \cdot 0.5\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= y_m 2e+63) (* x (* x (/ 0.5 y_m))) (* y_m 0.5))))
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 <= 2e+63) {
		tmp = x * (x * (0.5 / y_m));
	} else {
		tmp = y_m * 0.5;
	}
	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 <= 2d+63) then
        tmp = x * (x * (0.5d0 / y_m))
    else
        tmp = y_m * 0.5d0
    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 <= 2e+63) {
		tmp = x * (x * (0.5 / y_m));
	} else {
		tmp = y_m * 0.5;
	}
	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 <= 2e+63:
		tmp = x * (x * (0.5 / y_m))
	else:
		tmp = y_m * 0.5
	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 <= 2e+63)
		tmp = Float64(x * Float64(x * Float64(0.5 / y_m)));
	else
		tmp = Float64(y_m * 0.5);
	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 <= 2e+63)
		tmp = x * (x * (0.5 / y_m));
	else
		tmp = y_m * 0.5;
	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, 2e+63], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $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 2 \cdot 10^{+63}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y_m}\right)\\

\mathbf{else}:\\
\;\;\;\;y_m \cdot 0.5\\


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

    1. Initial program 74.3%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv36.6%

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

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{2 \cdot y}} \]
      3. associate-/r*36.6%

        \[\leadsto {x}^{2} \cdot \color{blue}{\frac{\frac{1}{2}}{y}} \]
      4. metadata-eval36.6%

        \[\leadsto {x}^{2} \cdot \frac{\color{blue}{0.5}}{y} \]
      5. unpow236.6%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      6. associate-*l*38.0%

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

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

    if 2.00000000000000012e63 < y

    1. Initial program 28.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 70.8%

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

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

Alternative 10: 34.9% accurate, 5.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \left(y_m \cdot 0.5\right) \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
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 * (y_m * 0.5);
}
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 * (y_m * 0.5d0)
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 * (y_m * 0.5);
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (y_m * 0.5)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(y_m * 0.5))
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (y_m * 0.5);
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[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \left(y_m \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 63.9%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Final simplification37.8%

    \[\leadsto y \cdot 0.5 \]
  5. 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 2024010 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :herbie-target
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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