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

Percentage Accurate: 69.7% → 96.3%
Time: 9.9s
Alternatives: 6
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 6 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.3% accurate, 0.3× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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\_m \cdot z\_m}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + z\_m\right) \cdot \frac{y\_m - z\_m}{y\_m}\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + z\_m\right) \cdot \left(1 - \frac{z\_m}{y\_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z_m z_m)) (* y_m 2.0))))
   (*
    y_s
    (if (<= t_0 0.0)
      (* 0.5 (* (+ y_m z_m) (/ (- y_m z_m) y_m)))
      (if (<= t_0 INFINITY)
        (* 0.5 (+ y_m (* x (/ x y_m))))
        (* 0.5 (* (+ y_m z_m) (- 1.0 (/ z_m y_m)))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * ((y_m + z_m) * ((y_m - z_m) / y_m));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = 0.5 * ((y_m + z_m) * (1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = Math.abs(z);
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_m) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * ((y_m + z_m) * ((y_m - z_m) / y_m));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = 0.5 * ((y_m + z_m) * (1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)
	tmp = 0
	if t_0 <= 0.0:
		tmp = 0.5 * ((y_m + z_m) * ((y_m - z_m) / y_m))
	elif t_0 <= math.inf:
		tmp = 0.5 * (y_m + (x * (x / y_m)))
	else:
		tmp = 0.5 * ((y_m + z_m) * (1.0 - (z_m / y_m)))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z_m * z_m)) / Float64(y_m * 2.0))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(0.5 * Float64(Float64(y_m + z_m) * Float64(Float64(y_m - z_m) / y_m)));
	elseif (t_0 <= Inf)
		tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + z_m) * Float64(1.0 - Float64(z_m / y_m))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = 0.5 * ((y_m + z_m) * ((y_m - z_m) / y_m));
	elseif (t_0 <= Inf)
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	else
		tmp = 0.5 * ((y_m + z_m) * (1.0 - (z_m / y_m)));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(N[(y$95$m + z$95$m), $MachinePrecision] * N[(N[(y$95$m - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + z$95$m), $MachinePrecision] * N[(1.0 - N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
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\_m \cdot z\_m}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + z\_m\right) \cdot \frac{y\_m - z\_m}{y\_m}\right)\\

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

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


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

    1. Initial program 77.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg77.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-out77.8%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg77.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-177.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-out77.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative77.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-in77.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-frac77.8%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified77.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-squares77.8%

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

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

      \[\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 45.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*64.5%

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

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

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

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

    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-define81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg0.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-out0.0%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg0.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-10.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-out0.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative0.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-in0.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-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \cdot \left(z + y\right)\right) \]
      4. *-inverses78.9%

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

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

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

Alternative 2: 77.8% accurate, 0.4× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 2.6 \cdot 10^{+27} \lor \neg \left(z\_m \leq 3.9 \cdot 10^{+54}\right) \land \left(z\_m \leq 4.5 \cdot 10^{+88} \lor \neg \left(z\_m \leq 1.15 \cdot 10^{+113}\right) \land z\_m \leq 2.55 \cdot 10^{+132}\right):\\ \;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(z\_m \cdot \left(-1 - \frac{z\_m}{y\_m}\right)\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (or (<= z_m 2.6e+27)
          (and (not (<= z_m 3.9e+54))
               (or (<= z_m 4.5e+88)
                   (and (not (<= z_m 1.15e+113)) (<= z_m 2.55e+132)))))
    (* 0.5 (+ y_m (* x (/ x y_m))))
    (* 0.5 (* z_m (- -1.0 (/ z_m y_m)))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if ((z_m <= 2.6e+27) || (!(z_m <= 3.9e+54) && ((z_m <= 4.5e+88) || (!(z_m <= 1.15e+113) && (z_m <= 2.55e+132))))) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((z_m <= 2.6d+27) .or. (.not. (z_m <= 3.9d+54)) .and. (z_m <= 4.5d+88) .or. (.not. (z_m <= 1.15d+113)) .and. (z_m <= 2.55d+132)) then
        tmp = 0.5d0 * (y_m + (x * (x / y_m)))
    else
        tmp = 0.5d0 * (z_m * ((-1.0d0) - (z_m / y_m)))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if ((z_m <= 2.6e+27) || (!(z_m <= 3.9e+54) && ((z_m <= 4.5e+88) || (!(z_m <= 1.15e+113) && (z_m <= 2.55e+132))))) {
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	} else {
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if (z_m <= 2.6e+27) or (not (z_m <= 3.9e+54) and ((z_m <= 4.5e+88) or (not (z_m <= 1.15e+113) and (z_m <= 2.55e+132)))):
		tmp = 0.5 * (y_m + (x * (x / y_m)))
	else:
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if ((z_m <= 2.6e+27) || (!(z_m <= 3.9e+54) && ((z_m <= 4.5e+88) || (!(z_m <= 1.15e+113) && (z_m <= 2.55e+132)))))
		tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))));
	else
		tmp = Float64(0.5 * Float64(z_m * Float64(-1.0 - Float64(z_m / y_m))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if ((z_m <= 2.6e+27) || (~((z_m <= 3.9e+54)) && ((z_m <= 4.5e+88) || (~((z_m <= 1.15e+113)) && (z_m <= 2.55e+132)))))
		tmp = 0.5 * (y_m + (x * (x / y_m)));
	else
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[Or[LessEqual[z$95$m, 2.6e+27], And[N[Not[LessEqual[z$95$m, 3.9e+54]], $MachinePrecision], Or[LessEqual[z$95$m, 4.5e+88], And[N[Not[LessEqual[z$95$m, 1.15e+113]], $MachinePrecision], LessEqual[z$95$m, 2.55e+132]]]]], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(z$95$m * N[(-1.0 - N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.6 \cdot 10^{+27} \lor \neg \left(z\_m \leq 3.9 \cdot 10^{+54}\right) \land \left(z\_m \leq 4.5 \cdot 10^{+88} \lor \neg \left(z\_m \leq 1.15 \cdot 10^{+113}\right) \land z\_m \leq 2.55 \cdot 10^{+132}\right):\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.60000000000000009e27 or 3.9000000000000003e54 < z < 4.5e88 or 1.14999999999999998e113 < z < 2.55e132

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified72.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 z around inf 50.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.60000000000000009e27 < z < 3.9000000000000003e54 or 4.5e88 < z < 1.14999999999999998e113 or 2.55e132 < z

    1. Initial program 73.3%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg73.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-out73.3%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg73.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-173.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-out73.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative73.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-in73.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-frac73.3%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified84.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-squares85.3%

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

        \[\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-rr85.3%

      \[\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 83.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*88.6%

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(z \cdot \left(-1 \cdot \frac{z}{y} - 1\right)\right)} \]
    14. Step-by-step derivation
      1. sub-neg79.5%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(z \cdot \left(\color{blue}{-1} + \left(-\frac{z}{y}\right)\right)\right) \]
      7. unsub-neg79.5%

        \[\leadsto 0.5 \cdot \left(z \cdot \color{blue}{\left(-1 - \frac{z}{y}\right)}\right) \]
    15. Simplified79.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.6 \cdot 10^{+27} \lor \neg \left(z \leq 3.9 \cdot 10^{+54}\right) \land \left(z \leq 4.5 \cdot 10^{+88} \lor \neg \left(z \leq 1.15 \cdot 10^{+113}\right) \land z \leq 2.55 \cdot 10^{+132}\right):\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \left(-1 - \frac{z}{y}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.8% accurate, 0.4× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{z\_m \cdot \left(\left(-z\_m\right) - y\_m\right)}{y\_m}\\ t_1 := 0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 2.7 \cdot 10^{+27}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z\_m \leq 1.12 \cdot 10^{+55}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z\_m \leq 5 \cdot 10^{+87}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z\_m \leq 2.1 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z\_m \leq 4.55 \cdot 10^{+132}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(z\_m \cdot \left(-1 - \frac{z\_m}{y\_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ (* z_m (- (- z_m) y_m)) y_m)))
        (t_1 (* 0.5 (+ y_m (* x (/ x y_m))))))
   (*
    y_s
    (if (<= z_m 2.7e+27)
      t_1
      (if (<= z_m 1.12e+55)
        t_0
        (if (<= z_m 5e+87)
          t_1
          (if (<= z_m 2.1e+113)
            t_0
            (if (<= z_m 4.55e+132)
              t_1
              (* 0.5 (* z_m (- -1.0 (/ z_m y_m))))))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = 0.5 * ((z_m * (-z_m - y_m)) / y_m);
	double t_1 = 0.5 * (y_m + (x * (x / y_m)));
	double tmp;
	if (z_m <= 2.7e+27) {
		tmp = t_1;
	} else if (z_m <= 1.12e+55) {
		tmp = t_0;
	} else if (z_m <= 5e+87) {
		tmp = t_1;
	} else if (z_m <= 2.1e+113) {
		tmp = t_0;
	} else if (z_m <= 4.55e+132) {
		tmp = t_1;
	} else {
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * ((z_m * (-z_m - y_m)) / y_m)
    t_1 = 0.5d0 * (y_m + (x * (x / y_m)))
    if (z_m <= 2.7d+27) then
        tmp = t_1
    else if (z_m <= 1.12d+55) then
        tmp = t_0
    else if (z_m <= 5d+87) then
        tmp = t_1
    else if (z_m <= 2.1d+113) then
        tmp = t_0
    else if (z_m <= 4.55d+132) then
        tmp = t_1
    else
        tmp = 0.5d0 * (z_m * ((-1.0d0) - (z_m / y_m)))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = 0.5 * ((z_m * (-z_m - y_m)) / y_m);
	double t_1 = 0.5 * (y_m + (x * (x / y_m)));
	double tmp;
	if (z_m <= 2.7e+27) {
		tmp = t_1;
	} else if (z_m <= 1.12e+55) {
		tmp = t_0;
	} else if (z_m <= 5e+87) {
		tmp = t_1;
	} else if (z_m <= 2.1e+113) {
		tmp = t_0;
	} else if (z_m <= 4.55e+132) {
		tmp = t_1;
	} else {
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = 0.5 * ((z_m * (-z_m - y_m)) / y_m)
	t_1 = 0.5 * (y_m + (x * (x / y_m)))
	tmp = 0
	if z_m <= 2.7e+27:
		tmp = t_1
	elif z_m <= 1.12e+55:
		tmp = t_0
	elif z_m <= 5e+87:
		tmp = t_1
	elif z_m <= 2.1e+113:
		tmp = t_0
	elif z_m <= 4.55e+132:
		tmp = t_1
	else:
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(0.5 * Float64(Float64(z_m * Float64(Float64(-z_m) - y_m)) / y_m))
	t_1 = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))))
	tmp = 0.0
	if (z_m <= 2.7e+27)
		tmp = t_1;
	elseif (z_m <= 1.12e+55)
		tmp = t_0;
	elseif (z_m <= 5e+87)
		tmp = t_1;
	elseif (z_m <= 2.1e+113)
		tmp = t_0;
	elseif (z_m <= 4.55e+132)
		tmp = t_1;
	else
		tmp = Float64(0.5 * Float64(z_m * Float64(-1.0 - Float64(z_m / y_m))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = 0.5 * ((z_m * (-z_m - y_m)) / y_m);
	t_1 = 0.5 * (y_m + (x * (x / y_m)));
	tmp = 0.0;
	if (z_m <= 2.7e+27)
		tmp = t_1;
	elseif (z_m <= 1.12e+55)
		tmp = t_0;
	elseif (z_m <= 5e+87)
		tmp = t_1;
	elseif (z_m <= 2.1e+113)
		tmp = t_0;
	elseif (z_m <= 4.55e+132)
		tmp = t_1;
	else
		tmp = 0.5 * (z_m * (-1.0 - (z_m / y_m)));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(z$95$m * N[((-z$95$m) - y$95$m), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z$95$m, 2.7e+27], t$95$1, If[LessEqual[z$95$m, 1.12e+55], t$95$0, If[LessEqual[z$95$m, 5e+87], t$95$1, If[LessEqual[z$95$m, 2.1e+113], t$95$0, If[LessEqual[z$95$m, 4.55e+132], t$95$1, N[(0.5 * N[(z$95$m * N[(-1.0 - N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{z\_m \cdot \left(\left(-z\_m\right) - y\_m\right)}{y\_m}\\
t_1 := 0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.7 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z\_m \leq 1.12 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z\_m \leq 5 \cdot 10^{+87}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z\_m \leq 2.1 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z\_m \leq 4.55 \cdot 10^{+132}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 2.6999999999999997e27 or 1.12000000000000006e55 < z < 4.9999999999999998e87 or 2.0999999999999999e113 < z < 4.5499999999999997e132

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified72.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 z around inf 50.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6999999999999997e27 < z < 1.12000000000000006e55 or 4.9999999999999998e87 < z < 2.0999999999999999e113

    1. Initial program 92.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg92.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-out92.1%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg92.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-192.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-out92.1%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative92.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-in92.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-frac92.1%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified92.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. Step-by-step derivation
      1. difference-of-squares92.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. *-commutative92.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-rr92.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 92.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*99.7%

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

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

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

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

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

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

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

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

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

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

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

    if 4.5499999999999997e132 < z

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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*85.2%

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(z \cdot \left(-1 \cdot \frac{z}{y} - 1\right)\right)} \]
    14. Step-by-step derivation
      1. sub-neg78.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.7 \cdot 10^{+27}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \mathbf{elif}\;z \leq 1.12 \cdot 10^{+55}:\\ \;\;\;\;0.5 \cdot \frac{z \cdot \left(\left(-z\right) - y\right)}{y}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+87}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+113}:\\ \;\;\;\;0.5 \cdot \frac{z \cdot \left(\left(-z\right) - y\right)}{y}\\ \mathbf{elif}\;z \leq 4.55 \cdot 10^{+132}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \left(-1 - \frac{z}{y}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 69.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg69.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-out69.1%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg69.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-169.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-out69.1%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative69.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-in69.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-frac69.1%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified71.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 z around inf 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.29999999999999993e26 < z

    1. Initial program 76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 80.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*84.8%

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

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

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

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

Alternative 5: 53.6% accurate, 1.1× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.5 \cdot 10^{+15}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    1. Initial program 69.0%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified41.2%

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

    if 2.5e15 < z

    1. Initial program 76.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg76.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-out76.8%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg76.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-176.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-out76.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative76.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-in76.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-frac76.8%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified86.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-squares87.2%

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

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

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

      \[\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*83.4%

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(z \cdot \left(-1 \cdot \frac{z}{y} - 1\right)\right)} \]
    14. Step-by-step derivation
      1. sub-neg72.5%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(z \cdot \left(\color{blue}{-1} + \left(-\frac{z}{y}\right)\right)\right) \]
      7. unsub-neg72.5%

        \[\leadsto 0.5 \cdot \left(z \cdot \color{blue}{\left(-1 - \frac{z}{y}\right)}\right) \]
    15. Simplified72.5%

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

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

Alternative 6: 34.7% accurate, 5.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m) :precision binary64 (* y_s (* y_m 0.5)))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	return y_s * (y_m * 0.5);
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    code = y_s * (y_m * 0.5d0)
end function
z_m = Math.abs(z);
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_m) {
	return y_s * (y_m * 0.5);
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	return y_s * (y_m * 0.5)
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	return Float64(y_s * Float64(y_m * 0.5))
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z_m)
	tmp = y_s * (y_m * 0.5);
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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 70.8%

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

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

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

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

    \[\leadsto y \cdot 0.5 \]
  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 2024081 
(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)))