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

Percentage Accurate: 69.0% → 90.9%
Time: 8.5s
Alternatives: 10
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

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

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


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

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

    if 2.8999999999999998e143 < y

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    6. Applied egg-rr91.6%

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

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

Alternative 2: 42.4% 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) \\ \begin{array}{l} t_0 := \frac{y_m + z_m}{-2 \cdot \frac{y_m}{z_m}}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 2.3 \cdot 10^{-121}:\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+25}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y_m}}}\\ \mathbf{elif}\;x \leq 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y_m}}}\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (+ y_m z_m) (* -2.0 (/ y_m z_m)))))
   (*
    y_s
    (if (<= x 2.3e-121)
      (* y_m 0.5)
      (if (<= x 1.25e-27)
        t_0
        (if (<= x 2.9e+25)
          (/ x (/ 2.0 (/ x y_m)))
          (if (<= x 1e+108) t_0 (/ 1.0 (/ 2.0 (* x (/ x 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 = (y_m + z_m) / (-2.0 * (y_m / z_m));
	double tmp;
	if (x <= 2.3e-121) {
		tmp = y_m * 0.5;
	} else if (x <= 1.25e-27) {
		tmp = t_0;
	} else if (x <= 2.9e+25) {
		tmp = x / (2.0 / (x / y_m));
	} else if (x <= 1e+108) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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) :: tmp
    t_0 = (y_m + z_m) / ((-2.0d0) * (y_m / z_m))
    if (x <= 2.3d-121) then
        tmp = y_m * 0.5d0
    else if (x <= 1.25d-27) then
        tmp = t_0
    else if (x <= 2.9d+25) then
        tmp = x / (2.0d0 / (x / y_m))
    else if (x <= 1d+108) then
        tmp = t_0
    else
        tmp = 1.0d0 / (2.0d0 / (x * (x / 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 = (y_m + z_m) / (-2.0 * (y_m / z_m));
	double tmp;
	if (x <= 2.3e-121) {
		tmp = y_m * 0.5;
	} else if (x <= 1.25e-27) {
		tmp = t_0;
	} else if (x <= 2.9e+25) {
		tmp = x / (2.0 / (x / y_m));
	} else if (x <= 1e+108) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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 = (y_m + z_m) / (-2.0 * (y_m / z_m))
	tmp = 0
	if x <= 2.3e-121:
		tmp = y_m * 0.5
	elif x <= 1.25e-27:
		tmp = t_0
	elif x <= 2.9e+25:
		tmp = x / (2.0 / (x / y_m))
	elif x <= 1e+108:
		tmp = t_0
	else:
		tmp = 1.0 / (2.0 / (x * (x / 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(y_m + z_m) / Float64(-2.0 * Float64(y_m / z_m)))
	tmp = 0.0
	if (x <= 2.3e-121)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 1.25e-27)
		tmp = t_0;
	elseif (x <= 2.9e+25)
		tmp = Float64(x / Float64(2.0 / Float64(x / y_m)));
	elseif (x <= 1e+108)
		tmp = t_0;
	else
		tmp = Float64(1.0 / Float64(2.0 / Float64(x * Float64(x / 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 = (y_m + z_m) / (-2.0 * (y_m / z_m));
	tmp = 0.0;
	if (x <= 2.3e-121)
		tmp = y_m * 0.5;
	elseif (x <= 1.25e-27)
		tmp = t_0;
	elseif (x <= 2.9e+25)
		tmp = x / (2.0 / (x / y_m));
	elseif (x <= 1e+108)
		tmp = t_0;
	else
		tmp = 1.0 / (2.0 / (x * (x / 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[(y$95$m + z$95$m), $MachinePrecision] / N[(-2.0 * N[(y$95$m / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 2.3e-121], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 1.25e-27], t$95$0, If[LessEqual[x, 2.9e+25], N[(x / N[(2.0 / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+108], t$95$0, N[(1.0 / N[(2.0 / N[(x * N[(x / 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{y_m + z_m}{-2 \cdot \frac{y_m}{z_m}}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 2.3 \cdot 10^{-121}:\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-27}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 10^{+108}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.30000000000000012e-121

    1. Initial program 71.4%

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

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

    if 2.30000000000000012e-121 < x < 1.25e-27 or 2.8999999999999999e25 < x < 1e108

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y + z}{\frac{\color{blue}{2 \cdot y}}{y - z}} \]
    8. Simplified82.2%

      \[\leadsto \color{blue}{\frac{y + z}{\frac{2 \cdot y}{y - z}}} \]
    9. Taylor expanded in y around 0 54.2%

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

    if 1.25e-27 < x < 2.8999999999999999e25

    1. Initial program 71.7%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv41.5%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/41.2%

        \[\leadsto x \cdot \color{blue}{\frac{x \cdot 0.5}{y}} \]
      2. metadata-eval41.2%

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv41.2%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/41.4%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/41.2%

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{2}{x}}} \cdot \frac{x}{y} \]
      8. frac-times41.2%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{\frac{2}{x} \cdot y}} \]
      9. *-un-lft-identity41.2%

        \[\leadsto \frac{\color{blue}{x}}{\frac{2}{x} \cdot y} \]
    6. Applied egg-rr41.2%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{2 \cdot y}{x}}} \]
      2. associate-/l*41.4%

        \[\leadsto \frac{x}{\color{blue}{\frac{2}{\frac{x}{y}}}} \]
    8. Applied egg-rr41.4%

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

    if 1e108 < x

    1. Initial program 60.1%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv66.6%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/85.6%

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

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv85.6%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/66.6%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/85.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
      6. clear-num85.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{2} \]
      7. clear-num85.5%

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{1}{\frac{2}{x}}} \]
      8. frac-times85.5%

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
      9. metadata-eval85.5%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y}{x} \cdot \frac{2}{x}} \]
    6. Applied egg-rr85.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
    7. Step-by-step derivation
      1. clear-num85.5%

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{2}}{\frac{x}{y} \cdot x}} \]
    8. Applied egg-rr85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.3 \cdot 10^{-121}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-27}:\\ \;\;\;\;\frac{y + z}{-2 \cdot \frac{y}{z}}\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+25}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\ \mathbf{elif}\;x \leq 10^{+108}:\\ \;\;\;\;\frac{y + z}{-2 \cdot \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y}}}\\ \end{array} \]

Alternative 3: 42.5% 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}\;x \leq 10^{-126}:\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-27}:\\ \;\;\;\;\frac{z_m}{y_m} \cdot \frac{\left(-z_m\right) - y_m}{2}\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+24}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y_m}}}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+110}:\\ \;\;\;\;\frac{y_m + z_m}{-2 \cdot \frac{y_m}{z_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y_m}}}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= x 1e-126)
    (* y_m 0.5)
    (if (<= x 1.3e-27)
      (* (/ z_m y_m) (/ (- (- z_m) y_m) 2.0))
      (if (<= x 3.8e+24)
        (/ x (/ 2.0 (/ x y_m)))
        (if (<= x 3.1e+110)
          (/ (+ y_m z_m) (* -2.0 (/ y_m z_m)))
          (/ 1.0 (/ 2.0 (* x (/ x 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 (x <= 1e-126) {
		tmp = y_m * 0.5;
	} else if (x <= 1.3e-27) {
		tmp = (z_m / y_m) * ((-z_m - y_m) / 2.0);
	} else if (x <= 3.8e+24) {
		tmp = x / (2.0 / (x / y_m));
	} else if (x <= 3.1e+110) {
		tmp = (y_m + z_m) / (-2.0 * (y_m / z_m));
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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 (x <= 1d-126) then
        tmp = y_m * 0.5d0
    else if (x <= 1.3d-27) then
        tmp = (z_m / y_m) * ((-z_m - y_m) / 2.0d0)
    else if (x <= 3.8d+24) then
        tmp = x / (2.0d0 / (x / y_m))
    else if (x <= 3.1d+110) then
        tmp = (y_m + z_m) / ((-2.0d0) * (y_m / z_m))
    else
        tmp = 1.0d0 / (2.0d0 / (x * (x / 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 (x <= 1e-126) {
		tmp = y_m * 0.5;
	} else if (x <= 1.3e-27) {
		tmp = (z_m / y_m) * ((-z_m - y_m) / 2.0);
	} else if (x <= 3.8e+24) {
		tmp = x / (2.0 / (x / y_m));
	} else if (x <= 3.1e+110) {
		tmp = (y_m + z_m) / (-2.0 * (y_m / z_m));
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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 x <= 1e-126:
		tmp = y_m * 0.5
	elif x <= 1.3e-27:
		tmp = (z_m / y_m) * ((-z_m - y_m) / 2.0)
	elif x <= 3.8e+24:
		tmp = x / (2.0 / (x / y_m))
	elif x <= 3.1e+110:
		tmp = (y_m + z_m) / (-2.0 * (y_m / z_m))
	else:
		tmp = 1.0 / (2.0 / (x * (x / 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 (x <= 1e-126)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 1.3e-27)
		tmp = Float64(Float64(z_m / y_m) * Float64(Float64(Float64(-z_m) - y_m) / 2.0));
	elseif (x <= 3.8e+24)
		tmp = Float64(x / Float64(2.0 / Float64(x / y_m)));
	elseif (x <= 3.1e+110)
		tmp = Float64(Float64(y_m + z_m) / Float64(-2.0 * Float64(y_m / z_m)));
	else
		tmp = Float64(1.0 / Float64(2.0 / Float64(x * Float64(x / 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 (x <= 1e-126)
		tmp = y_m * 0.5;
	elseif (x <= 1.3e-27)
		tmp = (z_m / y_m) * ((-z_m - y_m) / 2.0);
	elseif (x <= 3.8e+24)
		tmp = x / (2.0 / (x / y_m));
	elseif (x <= 3.1e+110)
		tmp = (y_m + z_m) / (-2.0 * (y_m / z_m));
	else
		tmp = 1.0 / (2.0 / (x * (x / 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[x, 1e-126], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 1.3e-27], N[(N[(z$95$m / y$95$m), $MachinePrecision] * N[(N[((-z$95$m) - y$95$m), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e+24], N[(x / N[(2.0 / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+110], N[(N[(y$95$m + z$95$m), $MachinePrecision] / N[(-2.0 * N[(y$95$m / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 / N[(x * N[(x / 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}\;x \leq 10^{-126}:\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-27}:\\
\;\;\;\;\frac{z_m}{y_m} \cdot \frac{\left(-z_m\right) - y_m}{2}\\

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+110}:\\
\;\;\;\;\frac{y_m + z_m}{-2 \cdot \frac{y_m}{z_m}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 9.9999999999999995e-127

    1. Initial program 71.4%

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

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

    if 9.9999999999999995e-127 < x < 1.30000000000000009e-27

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    6. Applied egg-rr79.2%

      \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    7. Taylor expanded in y around 0 49.2%

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

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

        \[\leadsto \color{blue}{\frac{-z}{y}} \cdot \frac{y + z}{2} \]
    9. Simplified49.2%

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

    if 1.30000000000000009e-27 < x < 3.80000000000000015e24

    1. Initial program 71.7%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv41.5%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/41.2%

        \[\leadsto x \cdot \color{blue}{\frac{x \cdot 0.5}{y}} \]
      2. metadata-eval41.2%

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv41.2%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/41.4%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/41.2%

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{2}{x}}} \cdot \frac{x}{y} \]
      8. frac-times41.2%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{\frac{2}{x} \cdot y}} \]
      9. *-un-lft-identity41.2%

        \[\leadsto \frac{\color{blue}{x}}{\frac{2}{x} \cdot y} \]
    6. Applied egg-rr41.2%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{2 \cdot y}{x}}} \]
      2. associate-/l*41.4%

        \[\leadsto \frac{x}{\color{blue}{\frac{2}{\frac{x}{y}}}} \]
    8. Applied egg-rr41.4%

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

    if 3.80000000000000015e24 < x < 3.10000000000000017e110

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y + z}}{\frac{y \cdot 2}{y - z}} \]
      3. *-commutative85.0%

        \[\leadsto \frac{y + z}{\frac{\color{blue}{2 \cdot y}}{y - z}} \]
    8. Simplified85.0%

      \[\leadsto \color{blue}{\frac{y + z}{\frac{2 \cdot y}{y - z}}} \]
    9. Taylor expanded in y around 0 58.7%

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

    if 3.10000000000000017e110 < x

    1. Initial program 60.1%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv66.6%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/85.6%

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

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv85.6%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/66.6%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/85.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
      6. clear-num85.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{2} \]
      7. clear-num85.5%

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{1}{\frac{2}{x}}} \]
      8. frac-times85.5%

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
      9. metadata-eval85.5%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y}{x} \cdot \frac{2}{x}} \]
    6. Applied egg-rr85.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
    7. Step-by-step derivation
      1. clear-num85.5%

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{2}}{\frac{x}{y} \cdot x}} \]
    8. Applied egg-rr85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 10^{-126}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-27}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{\left(-z\right) - y}{2}\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+24}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+110}:\\ \;\;\;\;\frac{y + z}{-2 \cdot \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y}}}\\ \end{array} \]

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

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


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

    1. Initial program 80.4%

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

    if 2.24999999999999984e144 < y

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    6. Applied egg-rr91.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.25 \cdot 10^{+144}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \end{array} \]

Alternative 5: 74.5% 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}\;x \leq 2.15 \cdot 10^{+111}:\\ \;\;\;\;\frac{y_m - z_m}{y_m} \cdot \frac{y_m + z_m}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y_m}}}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= x 2.15e+111)
    (* (/ (- y_m z_m) y_m) (/ (+ y_m z_m) 2.0))
    (/ 1.0 (/ 2.0 (* x (/ x 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 (x <= 2.15e+111) {
		tmp = ((y_m - z_m) / y_m) * ((y_m + z_m) / 2.0);
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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 (x <= 2.15d+111) then
        tmp = ((y_m - z_m) / y_m) * ((y_m + z_m) / 2.0d0)
    else
        tmp = 1.0d0 / (2.0d0 / (x * (x / 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 (x <= 2.15e+111) {
		tmp = ((y_m - z_m) / y_m) * ((y_m + z_m) / 2.0);
	} else {
		tmp = 1.0 / (2.0 / (x * (x / 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 x <= 2.15e+111:
		tmp = ((y_m - z_m) / y_m) * ((y_m + z_m) / 2.0)
	else:
		tmp = 1.0 / (2.0 / (x * (x / 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 (x <= 2.15e+111)
		tmp = Float64(Float64(Float64(y_m - z_m) / y_m) * Float64(Float64(y_m + z_m) / 2.0));
	else
		tmp = Float64(1.0 / Float64(2.0 / Float64(x * Float64(x / 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 (x <= 2.15e+111)
		tmp = ((y_m - z_m) / y_m) * ((y_m + z_m) / 2.0);
	else
		tmp = 1.0 / (2.0 / (x * (x / 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[x, 2.15e+111], N[(N[(N[(y$95$m - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z$95$m), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 / N[(x * N[(x / 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}\;x \leq 2.15 \cdot 10^{+111}:\\
\;\;\;\;\frac{y_m - z_m}{y_m} \cdot \frac{y_m + z_m}{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.14999999999999997e111

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    6. Applied egg-rr71.5%

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

    if 2.14999999999999997e111 < x

    1. Initial program 60.1%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv66.6%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/85.6%

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

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv85.6%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/66.6%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/85.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
      6. clear-num85.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{2} \]
      7. clear-num85.5%

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{1}{\frac{2}{x}}} \]
      8. frac-times85.5%

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
      9. metadata-eval85.5%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y}{x} \cdot \frac{2}{x}} \]
    6. Applied egg-rr85.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
    7. Step-by-step derivation
      1. clear-num85.5%

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{2}}{\frac{x}{y} \cdot x}} \]
    8. Applied egg-rr85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.15 \cdot 10^{+111}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y}}}\\ \end{array} \]

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.79999999999999987e110

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y + z}}{\frac{y \cdot 2}{y - z}} \]
      3. *-commutative71.5%

        \[\leadsto \frac{y + z}{\frac{\color{blue}{2 \cdot y}}{y - z}} \]
    8. Simplified71.5%

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

    if 2.79999999999999987e110 < x

    1. Initial program 60.1%

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

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

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

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv66.6%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/85.6%

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

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv85.6%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/66.6%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/85.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
      6. clear-num85.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{2} \]
      7. clear-num85.5%

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{1}{\frac{2}{x}}} \]
      8. frac-times85.5%

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
      9. metadata-eval85.5%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y}{x} \cdot \frac{2}{x}} \]
    6. Applied egg-rr85.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
    7. Step-by-step derivation
      1. clear-num85.5%

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{2}}{\frac{x}{y} \cdot x}} \]
    8. Applied egg-rr85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.8 \cdot 10^{+110}:\\ \;\;\;\;\frac{y + z}{\frac{y \cdot 2}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y}}}\\ \end{array} \]

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.15e83

    1. Initial program 71.6%

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

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

    if 2.15e83 < x

    1. Initial program 65.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. div-inv59.7%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. metadata-eval59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{\frac{y}{0.5}}} \]
      4. clear-num59.7%

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/75.2%

        \[\leadsto x \cdot \color{blue}{\frac{x \cdot 0.5}{y}} \]
      2. metadata-eval75.2%

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv75.2%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/59.7%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/75.2%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
      6. clear-num75.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{2} \]
      7. clear-num75.1%

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{1}{\frac{2}{x}}} \]
      8. frac-times75.1%

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
      9. metadata-eval75.1%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y}{x} \cdot \frac{2}{x}} \]
    6. Applied egg-rr75.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x} \cdot \frac{2}{x}}} \]
    7. Step-by-step derivation
      1. clear-num75.1%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot 2}{\frac{x}{y} \cdot x}}} \]
      3. metadata-eval75.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{2}}{\frac{x}{y} \cdot x}} \]
    8. Applied egg-rr75.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.15 \cdot 10^{+83}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2}{x \cdot \frac{x}{y}}}\\ \end{array} \]

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.5e83

    1. Initial program 71.6%

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

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

    if 1.5e83 < x

    1. Initial program 65.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. div-inv59.7%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. metadata-eval59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{\frac{y}{0.5}}} \]
      4. clear-num59.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{+83}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 6.99999999999999954e83

    1. Initial program 71.6%

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

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

    if 6.99999999999999954e83 < x

    1. Initial program 65.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. div-inv59.7%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. metadata-eval59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \]
      3. div-inv59.7%

        \[\leadsto {x}^{2} \cdot \frac{1}{\color{blue}{\frac{y}{0.5}}} \]
      4. clear-num59.7%

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/75.2%

        \[\leadsto x \cdot \color{blue}{\frac{x \cdot 0.5}{y}} \]
      2. metadata-eval75.2%

        \[\leadsto x \cdot \frac{x \cdot \color{blue}{\frac{1}{2}}}{y} \]
      3. div-inv75.2%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{2}}}{y} \]
      4. associate-*r/59.7%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{x}{2}}{y}} \]
      5. associate-*l/75.2%

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

        \[\leadsto \color{blue}{\frac{x}{2} \cdot \frac{x}{y}} \]
      7. clear-num75.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{2}{x}}} \cdot \frac{x}{y} \]
      8. frac-times75.1%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{\frac{2}{x} \cdot y}} \]
      9. *-un-lft-identity75.1%

        \[\leadsto \frac{\color{blue}{x}}{\frac{2}{x} \cdot y} \]
    6. Applied egg-rr75.1%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{2 \cdot y}{x}}} \]
      2. associate-/l*75.2%

        \[\leadsto \frac{x}{\color{blue}{\frac{2}{\frac{x}{y}}}} \]
    8. Applied egg-rr75.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{+83}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\ \end{array} \]

Alternative 10: 34.4% 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 1 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.6%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Final simplification33.0%

    \[\leadsto y \cdot 0.5 \]

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 2023318 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

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

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