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

Percentage Accurate: 67.8% → 98.3%
Time: 11.3s
Alternatives: 8
Speedup: 0.7×

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 8 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: 67.8% 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: 98.3% 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 := \frac{z}{\sqrt{y\_m}}\\ y\_s \cdot \left(0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{\frac{x}{{y\_m}^{0.25}}}{{y\_m}^{0.25}}, \sqrt{y\_m}\right) + t\_0\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right) - t\_0\right)\right)\right) \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 (/ z (sqrt y_m))))
   (*
    y_s
    (*
     0.5
     (*
      (+ (hypot (/ (/ x (pow y_m 0.25)) (pow y_m 0.25)) (sqrt y_m)) t_0)
      (- (hypot (/ x (sqrt y_m)) (sqrt y_m)) t_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 = z / sqrt(y_m);
	return y_s * (0.5 * ((hypot(((x / pow(y_m, 0.25)) / pow(y_m, 0.25)), sqrt(y_m)) + t_0) * (hypot((x / sqrt(y_m)), sqrt(y_m)) - t_0)));
}
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 = z / Math.sqrt(y_m);
	return y_s * (0.5 * ((Math.hypot(((x / Math.pow(y_m, 0.25)) / Math.pow(y_m, 0.25)), Math.sqrt(y_m)) + t_0) * (Math.hypot((x / Math.sqrt(y_m)), Math.sqrt(y_m)) - t_0)));
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = z / math.sqrt(y_m)
	return y_s * (0.5 * ((math.hypot(((x / math.pow(y_m, 0.25)) / math.pow(y_m, 0.25)), math.sqrt(y_m)) + t_0) * (math.hypot((x / math.sqrt(y_m)), math.sqrt(y_m)) - t_0)))
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(z / sqrt(y_m))
	return Float64(y_s * Float64(0.5 * Float64(Float64(hypot(Float64(Float64(x / (y_m ^ 0.25)) / (y_m ^ 0.25)), sqrt(y_m)) + t_0) * Float64(hypot(Float64(x / sqrt(y_m)), sqrt(y_m)) - t_0))))
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	t_0 = z / sqrt(y_m);
	tmp = y_s * (0.5 * ((hypot(((x / (y_m ^ 0.25)) / (y_m ^ 0.25)), sqrt(y_m)) + t_0) * (hypot((x / sqrt(y_m)), sqrt(y_m)) - t_0)));
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[(z / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(0.5 * N[(N[(N[Sqrt[N[(N[(x / N[Power[y$95$m, 0.25], $MachinePrecision]), $MachinePrecision] / N[Power[y$95$m, 0.25], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sqrt[y$95$m], $MachinePrecision] ^ 2], $MachinePrecision] + t$95$0), $MachinePrecision] * N[(N[Sqrt[N[(x / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sqrt[y$95$m], $MachinePrecision] ^ 2], $MachinePrecision] - t$95$0), $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{z}{\sqrt{y\_m}}\\
y\_s \cdot \left(0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{\frac{x}{{y\_m}^{0.25}}}{{y\_m}^{0.25}}, \sqrt{y\_m}\right) + t\_0\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right) - t\_0\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right)} \]
  8. Step-by-step derivation
    1. *-un-lft-identity50.1%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{\color{blue}{1 \cdot x}}{\sqrt{y}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    2. add-sqr-sqrt50.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1 \cdot x}{\color{blue}{\sqrt{\sqrt{y}} \cdot \sqrt{\sqrt{y}}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    3. times-frac50.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\color{blue}{\frac{1}{\sqrt{\sqrt{y}}} \cdot \frac{x}{\sqrt{\sqrt{y}}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    4. pow1/250.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1}{\sqrt{\color{blue}{{y}^{0.5}}}} \cdot \frac{x}{\sqrt{\sqrt{y}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    5. sqrt-pow150.0%

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

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1}{{y}^{\color{blue}{0.25}}} \cdot \frac{x}{\sqrt{\sqrt{y}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    7. pow1/250.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1}{{y}^{0.25}} \cdot \frac{x}{\sqrt{\color{blue}{{y}^{0.5}}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    8. sqrt-pow150.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1}{{y}^{0.25}} \cdot \frac{x}{\color{blue}{{y}^{\left(\frac{0.5}{2}\right)}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    9. metadata-eval50.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{1}{{y}^{0.25}} \cdot \frac{x}{{y}^{\color{blue}{0.25}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  9. Applied egg-rr50.0%

    \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\color{blue}{\frac{1}{{y}^{0.25}} \cdot \frac{x}{{y}^{0.25}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  10. Step-by-step derivation
    1. associate-*l/50.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\color{blue}{\frac{1 \cdot \frac{x}{{y}^{0.25}}}{{y}^{0.25}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
    2. *-lft-identity50.0%

      \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{\color{blue}{\frac{x}{{y}^{0.25}}}}{{y}^{0.25}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  11. Simplified50.0%

    \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\color{blue}{\frac{\frac{x}{{y}^{0.25}}}{{y}^{0.25}}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  12. Final simplification50.0%

    \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{\frac{x}{{y}^{0.25}}}{{y}^{0.25}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  13. Add Preprocessing

Alternative 2: 98.3% 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 := \mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right)\\ t_1 := \frac{z}{\sqrt{y\_m}}\\ y\_s \cdot \left(0.5 \cdot \left(\left(t\_0 - t\_1\right) \cdot \left(t\_1 + t\_0\right)\right)\right) \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 (hypot (/ x (sqrt y_m)) (sqrt y_m))) (t_1 (/ z (sqrt y_m))))
   (* y_s (* 0.5 (* (- t_0 t_1) (+ t_1 t_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 = hypot((x / sqrt(y_m)), sqrt(y_m));
	double t_1 = z / sqrt(y_m);
	return y_s * (0.5 * ((t_0 - t_1) * (t_1 + t_0)));
}
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.hypot((x / Math.sqrt(y_m)), Math.sqrt(y_m));
	double t_1 = z / Math.sqrt(y_m);
	return y_s * (0.5 * ((t_0 - t_1) * (t_1 + t_0)));
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = math.hypot((x / math.sqrt(y_m)), math.sqrt(y_m))
	t_1 = z / math.sqrt(y_m)
	return y_s * (0.5 * ((t_0 - t_1) * (t_1 + t_0)))
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = hypot(Float64(x / sqrt(y_m)), sqrt(y_m))
	t_1 = Float64(z / sqrt(y_m))
	return Float64(y_s * Float64(0.5 * Float64(Float64(t_0 - t_1) * Float64(t_1 + t_0))))
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	t_0 = hypot((x / sqrt(y_m)), sqrt(y_m));
	t_1 = z / sqrt(y_m);
	tmp = y_s * (0.5 * ((t_0 - t_1) * (t_1 + t_0)));
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[Sqrt[N[(x / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sqrt[y$95$m], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(z / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(0.5 * N[(N[(t$95$0 - t$95$1), $MachinePrecision] * N[(t$95$1 + t$95$0), $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 := \mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right)\\
t_1 := \frac{z}{\sqrt{y\_m}}\\
y\_s \cdot \left(0.5 \cdot \left(\left(t\_0 - t\_1\right) \cdot \left(t\_1 + t\_0\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.6% 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 4 \cdot 10^{-21}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, \left(y\_m - z\right) \cdot \left(y\_m + z\right)\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - \frac{z}{\frac{y\_m}{z}}\right)\\ \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 4e-21)
    (* 0.5 (/ (fma x x (* (- y_m z) (+ y_m z))) y_m))
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (/ z (/ y_m z)))))))
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 <= 4e-21) {
		tmp = 0.5 * (fma(x, x, ((y_m - z) * (y_m + z))) / y_m);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	}
	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 <= 4e-21)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m - z) * Float64(y_m + z))) / y_m));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z / Float64(y_m / z))));
	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, 4e-21], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 4 \cdot 10^{-21}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, \left(y\_m - z\right) \cdot \left(y\_m + z\right)\right)}{y\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.99999999999999963e-21

    1. Initial program 81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999963e-21 < y

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) - \frac{z}{1} \cdot \frac{z}{y}\right) \]
    10. Step-by-step derivation
      1. clear-num99.9%

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(y + \frac{x}{1} \cdot \frac{x}{y}\right) - \frac{\color{blue}{\frac{z}{1}}}{1 \cdot \frac{y}{z}}\right) \]
      5. /-rgt-identity99.9%

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

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

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

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

Alternative 4: 96.1% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-146} \lor \neg \left(t\_0 \leq \infty\right):\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + z\right) \cdot \frac{y\_m - z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\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 x) (* y_m y_m)) (* z z)) (* y_m 2.0))))
   (*
    y_s
    (if (or (<= t_0 -5e-146) (not (<= t_0 INFINITY)))
      (* 0.5 (* (+ y_m z) (/ (- y_m z) y_m)))
      (* 0.5 (+ y_m (* x (/ x y_m))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if ((t_0 <= -5e-146) || !(t_0 <= ((double) INFINITY))) {
		tmp = 0.5 * ((y_m + z) * ((y_m - z) / y_m));
	} else {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	}
	return y_s * tmp;
}
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) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if ((t_0 <= -5e-146) || !(t_0 <= Double.POSITIVE_INFINITY)) {
		tmp = 0.5 * ((y_m + z) * ((y_m - z) / y_m));
	} else {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	tmp = 0
	if (t_0 <= -5e-146) or not (t_0 <= math.inf):
		tmp = 0.5 * ((y_m + z) * ((y_m - z) / y_m))
	else:
		tmp = 0.5 * (y_m + (x * (x / y_m)))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0))
	tmp = 0.0
	if ((t_0 <= -5e-146) || !(t_0 <= Inf))
		tmp = Float64(0.5 * Float64(Float64(y_m + z) * Float64(Float64(y_m - z) / y_m)));
	else
		tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	tmp = 0.0;
	if ((t_0 <= -5e-146) || ~((t_0 <= Inf)))
		tmp = 0.5 * ((y_m + z) * ((y_m - z) / y_m));
	else
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = 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[(y$95$s * If[Or[LessEqual[t$95$0, -5e-146], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(0.5 * N[(N[(y$95$m + z), $MachinePrecision] * N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-146} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + z\right) \cdot \frac{y\_m - z}{y\_m}\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) < -4.99999999999999957e-146 or +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2))

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999957e-146 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) < +inf.0

    1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.1% accurate, 0.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 6 \cdot 10^{-21}:\\ \;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - \frac{z}{\frac{y\_m}{z}}\right)\\ \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 6e-21)
    (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (/ z (/ y_m z)))))))
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 <= 6e-21) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	}
	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 <= 6d-21) then
        tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = 0.5d0 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)))
    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 <= 6e-21) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	}
	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 <= 6e-21:
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)))
	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 <= 6e-21)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z / Float64(y_m / z))));
	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 <= 6e-21)
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	else
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	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, 6e-21], 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[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.99999999999999982e-21

    1. Initial program 81.5%

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

    if 5.99999999999999982e-21 < y

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{x}{1} \cdot \frac{x}{y}}\right) - \frac{z}{1} \cdot \frac{z}{y}\right) \]
    10. Step-by-step derivation
      1. clear-num99.9%

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(y + \frac{x}{1} \cdot \frac{x}{y}\right) - \frac{\color{blue}{\frac{z}{1}}}{1 \cdot \frac{y}{z}}\right) \]
      5. /-rgt-identity99.9%

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

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

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

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

Alternative 6: 43.8% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 1.6 \cdot 10^{-31}:\\ \;\;\;\;0.5 \cdot \left(y\_m + z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y\_m + z\right) \cdot \frac{z}{y\_m}\right) \cdot \left(-0.5\right)\\ \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 (<= z 1.6e-31) (* 0.5 (+ y_m z)) (* (* (+ y_m z) (/ z 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 (z <= 1.6e-31) {
		tmp = 0.5 * (y_m + z);
	} else {
		tmp = ((y_m + z) * (z / 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 (z <= 1.6d-31) then
        tmp = 0.5d0 * (y_m + z)
    else
        tmp = ((y_m + z) * (z / 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 (z <= 1.6e-31) {
		tmp = 0.5 * (y_m + z);
	} else {
		tmp = ((y_m + z) * (z / 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 z <= 1.6e-31:
		tmp = 0.5 * (y_m + z)
	else:
		tmp = ((y_m + z) * (z / 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 (z <= 1.6e-31)
		tmp = Float64(0.5 * Float64(y_m + z));
	else
		tmp = Float64(Float64(Float64(y_m + z) * Float64(z / y_m)) * Float64(-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 (z <= 1.6e-31)
		tmp = 0.5 * (y_m + z);
	else
		tmp = ((y_m + z) * (z / 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[z, 1.6e-31], N[(0.5 * N[(y$95$m + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m + z), $MachinePrecision] * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] * (-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}\;z \leq 1.6 \cdot 10^{-31}:\\
\;\;\;\;0.5 \cdot \left(y\_m + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.60000000000000009e-31

    1. Initial program 72.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(y + z\right) \cdot \frac{y - z}{y}\right)} \]
    10. Taylor expanded in y around inf 39.8%

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

    if 1.60000000000000009e-31 < z

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(\left(y + z\right) \cdot \color{blue}{\left(-1 \cdot \frac{z}{y}\right)}\right) \]
    11. Step-by-step derivation
      1. neg-mul-164.5%

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

        \[\leadsto 0.5 \cdot \left(\left(y + z\right) \cdot \color{blue}{\frac{z}{-y}}\right) \]
    12. Simplified64.5%

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

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

Alternative 7: 67.6% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(y + z\right) \cdot \frac{y - z}{y}\right)} \]
  10. Final simplification71.6%

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

Alternative 8: 35.6% accurate, 5.0× speedup?

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

\\
y\_s \cdot \left(0.5 \cdot y\_m\right)
\end{array}
Derivation
  1. Initial program 74.3%

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

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified32.1%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification32.1%

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

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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

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

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