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

Percentage Accurate: 69.6% → 95.7%
Time: 11.8s
Alternatives: 9
Speedup: 0.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 69.6% accurate, 1.0× speedup?

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

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

Alternative 1: 95.7% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 7.6 \cdot 10^{+86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m - z, y\_m + z, x \cdot x\right)}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m - \frac{z}{\frac{y\_m}{z}}\right) + x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 7.6e+86)
    (/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
    (* 0.5 (+ (- y_m (/ z (/ y_m z))) (* x (/ x y_m)))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 7.6e+86) {
		tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m - (z / (y_m / z))) + (x * (x / y_m)));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 7.6e+86)
		tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m - Float64(z / Float64(y_m / z))) + Float64(x * Float64(x / y_m))));
	end
	return Float64(y_s * tmp)
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 7.6e+86], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

    if 7.59999999999999956e86 < y

    1. Initial program 31.2%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{y}^{2} - {z}^{2}}{y} + 0.5 \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. fma-def31.2%

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{\color{blue}{y \cdot y}}{y} - \frac{{z}^{2}}{y}, 0.5 \cdot \frac{{x}^{2}}{y}\right) \]
      4. associate-/l*61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 72.1% accurate, 0.4× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\frac{x}{y\_m}}{\frac{2}{x}}\\ t_1 := \frac{y\_m - z}{y\_m} \cdot \frac{y\_m + z}{2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 1.02 \cdot 10^{+42}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+87}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 3.15 \cdot 10^{+131}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 10^{+158}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+207}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (/ x y_m) (/ 2.0 x)))
        (t_1 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))
   (*
    y_s
    (if (<= x 1.02e+42)
      t_1
      (if (<= x 1.5e+87)
        t_0
        (if (<= x 3.15e+131)
          t_1
          (if (<= x 1e+158)
            (/ (* x 0.5) (/ y_m x))
            (if (<= x 2.2e+207) t_1 t_0))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = (x / y_m) / (2.0 / x);
	double t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	double tmp;
	if (x <= 1.02e+42) {
		tmp = t_1;
	} else if (x <= 1.5e+87) {
		tmp = t_0;
	} else if (x <= 3.15e+131) {
		tmp = t_1;
	} else if (x <= 1e+158) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (x <= 2.2e+207) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x / y_m) / (2.0d0 / x)
    t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
    if (x <= 1.02d+42) then
        tmp = t_1
    else if (x <= 1.5d+87) then
        tmp = t_0
    else if (x <= 3.15d+131) then
        tmp = t_1
    else if (x <= 1d+158) then
        tmp = (x * 0.5d0) / (y_m / x)
    else if (x <= 2.2d+207) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = (x / y_m) / (2.0 / x);
	double t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	double tmp;
	if (x <= 1.02e+42) {
		tmp = t_1;
	} else if (x <= 1.5e+87) {
		tmp = t_0;
	} else if (x <= 3.15e+131) {
		tmp = t_1;
	} else if (x <= 1e+158) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (x <= 2.2e+207) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = (x / y_m) / (2.0 / x)
	t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0)
	tmp = 0
	if x <= 1.02e+42:
		tmp = t_1
	elif x <= 1.5e+87:
		tmp = t_0
	elif x <= 3.15e+131:
		tmp = t_1
	elif x <= 1e+158:
		tmp = (x * 0.5) / (y_m / x)
	elif x <= 2.2e+207:
		tmp = t_1
	else:
		tmp = t_0
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(x / y_m) / Float64(2.0 / x))
	t_1 = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0))
	tmp = 0.0
	if (x <= 1.02e+42)
		tmp = t_1;
	elseif (x <= 1.5e+87)
		tmp = t_0;
	elseif (x <= 3.15e+131)
		tmp = t_1;
	elseif (x <= 1e+158)
		tmp = Float64(Float64(x * 0.5) / Float64(y_m / x));
	elseif (x <= 2.2e+207)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = (x / y_m) / (2.0 / x);
	t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
	tmp = 0.0;
	if (x <= 1.02e+42)
		tmp = t_1;
	elseif (x <= 1.5e+87)
		tmp = t_0;
	elseif (x <= 3.15e+131)
		tmp = t_1;
	elseif (x <= 1e+158)
		tmp = (x * 0.5) / (y_m / x);
	elseif (x <= 2.2e+207)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x / y$95$m), $MachinePrecision] / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.02e+42], t$95$1, If[LessEqual[x, 1.5e+87], t$95$0, If[LessEqual[x, 3.15e+131], t$95$1, If[LessEqual[x, 1e+158], N[(N[(x * 0.5), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e+207], t$95$1, t$95$0]]]]]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{\frac{x}{y\_m}}{\frac{2}{x}}\\
t_1 := \frac{y\_m - z}{y\_m} \cdot \frac{y\_m + z}{2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+42}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 3.15 \cdot 10^{+131}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 10^{+158}:\\
\;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+207}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.01999999999999996e42 or 1.4999999999999999e87 < x < 3.14999999999999998e131 or 9.99999999999999953e157 < x < 2.20000000000000009e207

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y - z}{y} \cdot \frac{y + z}{2}} \]
    7. Applied egg-rr74.4%

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

    if 1.01999999999999996e42 < x < 1.4999999999999999e87 or 2.20000000000000009e207 < x

    1. Initial program 81.6%

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

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

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

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

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

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

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

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

    if 3.14999999999999998e131 < x < 9.99999999999999953e157

    1. Initial program 68.5%

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \left(x \cdot \color{blue}{0.5}\right) \]
      3. *-commutative66.1%

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\left(0.5 \cdot x\right)} \]
      4. remove-double-div65.8%

        \[\leadsto \frac{x}{y} \cdot \left(0.5 \cdot \color{blue}{\frac{1}{\frac{1}{x}}}\right) \]
      5. div-inv65.8%

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{0.5}{\frac{1}{x}}} \]
      6. times-frac66.7%

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y \cdot \frac{1}{x}}} \]
      7. un-div-inv66.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.02 \cdot 10^{+42}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+87}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{2}{x}}\\ \mathbf{elif}\;x \leq 3.15 \cdot 10^{+131}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{elif}\;x \leq 10^{+158}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+207}:\\ \;\;\;\;\frac{y - z}{y} \cdot \frac{y + z}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{2}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.1% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 74.5%

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

    if 9.4999999999999996e147 < y

    1. Initial program 16.8%

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

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

        \[\leadsto \frac{\color{blue}{\left(y \cdot y - z \cdot z\right) + x \cdot x}}{y \cdot 2} \]
      3. sqr-neg16.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-squares27.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-def30.6%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.1% accurate, 0.7× speedup?

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

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

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


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

    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 x around 0 64.1%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{y}^{2} - {z}^{2}}{y} + 0.5 \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. fma-def64.1%

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{\color{blue}{y \cdot y}}{y} - \frac{{z}^{2}}{y}, 0.5 \cdot \frac{{x}^{2}}{y}\right) \]
      4. associate-/l*79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0999999999999996e149 < z

    1. Initial program 57.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(y \cdot y - z \cdot z\right) + x \cdot x}}{y \cdot 2} \]
      3. sqr-neg57.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-squares63.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-def71.6%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 52.5% accurate, 1.1× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 1.05 \cdot 10^{+53}:\\
\;\;\;\;\frac{\frac{x}{y\_m}}{\frac{2}{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \frac{1}{y\_m - z}}\\


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

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

    if 1.0500000000000001e53 < y

    1. Initial program 39.4%

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

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

        \[\leadsto \frac{\color{blue}{\left(y \cdot y - z \cdot z\right) + x \cdot x}}{y \cdot 2} \]
      3. sqr-neg39.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-squares46.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-def50.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-neg50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{2 \cdot \frac{\frac{y}{z + y}}{y - z}}} \]
    10. Taylor expanded in y around inf 55.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.05 \cdot 10^{+53}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{2}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 \cdot \frac{1}{y - z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 52.5% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 74.0%

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

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

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. unpow235.9%

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

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

        \[\leadsto \left(x \cdot x\right) \cdot \frac{1}{\color{blue}{\frac{y}{0.5}}} \]
      5. clear-num35.9%

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

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

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

    if 1.49999999999999999e53 < y

    1. Initial program 39.4%

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

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

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

Alternative 7: 52.0% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 74.0%

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

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

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{1}{y \cdot 2}} \]
      2. unpow235.9%

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

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

        \[\leadsto \left(x \cdot x\right) \cdot \frac{1}{\color{blue}{\frac{y}{0.5}}} \]
      5. clear-num35.9%

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

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

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

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

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

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

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

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

    if 5.49999999999999996e52 < y

    1. Initial program 39.4%

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

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

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

Alternative 8: 52.5% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 8 \cdot 10^{+52}:\\
\;\;\;\;\frac{\frac{x}{y\_m}}{\frac{2}{x}}\\

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


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

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

    if 7.9999999999999999e52 < y

    1. Initial program 39.4%

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

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

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

Alternative 9: 33.9% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Final simplification31.7%

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

Developer target: 99.8% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024040 
(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)))