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

Percentage Accurate: 69.4% → 95.9%
Time: 10.9s
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.4% 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.9% 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 6.6 \cdot 10^{-31}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{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 6.6e-31)
    (* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (* z (/ z y_m)))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 6.6e-31) {
		tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 6.6e-31)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z * Float64(z / y_m))));
	end
	return Float64(y_s * tmp)
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 6.6e-31], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / 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 6.6 \cdot 10^{-31}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\

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


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

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5999999999999998e-31 < y

    1. Initial program 46.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 42.8% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 2.45 \cdot 10^{-275}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-229}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-211}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-147}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{0.5 \cdot x}{y\_m}\\ \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 (* z (* (/ z y_m) -0.5))))
   (*
    y_s
    (if (<= x 2.45e-275)
      t_0
      (if (<= x 1.75e-229)
        (* y_m 0.5)
        (if (<= x 1.65e-211)
          t_0
          (if (<= x 3.6e-147)
            (* y_m 0.5)
            (if (<= x 5e+24) t_0 (* x (/ (* 0.5 x) y_m))))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = z * ((z / y_m) * -0.5);
	double tmp;
	if (x <= 2.45e-275) {
		tmp = t_0;
	} else if (x <= 1.75e-229) {
		tmp = y_m * 0.5;
	} else if (x <= 1.65e-211) {
		tmp = t_0;
	} else if (x <= 3.6e-147) {
		tmp = y_m * 0.5;
	} else if (x <= 5e+24) {
		tmp = t_0;
	} else {
		tmp = x * ((0.5 * x) / y_m);
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = z * ((z / y_m) * (-0.5d0))
    if (x <= 2.45d-275) then
        tmp = t_0
    else if (x <= 1.75d-229) then
        tmp = y_m * 0.5d0
    else if (x <= 1.65d-211) then
        tmp = t_0
    else if (x <= 3.6d-147) then
        tmp = y_m * 0.5d0
    else if (x <= 5d+24) then
        tmp = t_0
    else
        tmp = x * ((0.5d0 * x) / y_m)
    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 = z * ((z / y_m) * -0.5);
	double tmp;
	if (x <= 2.45e-275) {
		tmp = t_0;
	} else if (x <= 1.75e-229) {
		tmp = y_m * 0.5;
	} else if (x <= 1.65e-211) {
		tmp = t_0;
	} else if (x <= 3.6e-147) {
		tmp = y_m * 0.5;
	} else if (x <= 5e+24) {
		tmp = t_0;
	} else {
		tmp = x * ((0.5 * x) / y_m);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = z * ((z / y_m) * -0.5)
	tmp = 0
	if x <= 2.45e-275:
		tmp = t_0
	elif x <= 1.75e-229:
		tmp = y_m * 0.5
	elif x <= 1.65e-211:
		tmp = t_0
	elif x <= 3.6e-147:
		tmp = y_m * 0.5
	elif x <= 5e+24:
		tmp = t_0
	else:
		tmp = x * ((0.5 * x) / y_m)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(z * Float64(Float64(z / y_m) * -0.5))
	tmp = 0.0
	if (x <= 2.45e-275)
		tmp = t_0;
	elseif (x <= 1.75e-229)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 1.65e-211)
		tmp = t_0;
	elseif (x <= 3.6e-147)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 5e+24)
		tmp = t_0;
	else
		tmp = Float64(x * Float64(Float64(0.5 * x) / y_m));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = z * ((z / y_m) * -0.5);
	tmp = 0.0;
	if (x <= 2.45e-275)
		tmp = t_0;
	elseif (x <= 1.75e-229)
		tmp = y_m * 0.5;
	elseif (x <= 1.65e-211)
		tmp = t_0;
	elseif (x <= 3.6e-147)
		tmp = y_m * 0.5;
	elseif (x <= 5e+24)
		tmp = t_0;
	else
		tmp = x * ((0.5 * x) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(z * N[(N[(z / y$95$m), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 2.45e-275], t$95$0, If[LessEqual[x, 1.75e-229], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 1.65e-211], t$95$0, If[LessEqual[x, 3.6e-147], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 5e+24], t$95$0, N[(x * N[(N[(0.5 * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 2.45 \cdot 10^{-275}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{-229}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{-211}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{-147}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 5 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.44999999999999991e-275 or 1.7500000000000002e-229 < x < 1.6500000000000001e-211 or 3.60000000000000012e-147 < x < 5.00000000000000045e24

    1. Initial program 75.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    7. Simplified41.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*41.6%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{{z}^{2}}{y}} \]
      2. unpow241.6%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{z \cdot z}}{y} \]
      3. associate-*l/43.2%

        \[\leadsto -0.5 \cdot \color{blue}{\left(\frac{z}{y} \cdot z\right)} \]
      4. associate-*r*43.2%

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

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

    if 2.44999999999999991e-275 < x < 1.7500000000000002e-229 or 1.6500000000000001e-211 < x < 3.60000000000000012e-147

    1. Initial program 46.5%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified65.6%

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

    if 5.00000000000000045e24 < x

    1. Initial program 74.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 inf 74.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.45 \cdot 10^{-275}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-229}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-211}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-147}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+24}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 42.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.38 \cdot 10^{-275}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5.3 \cdot 10^{-226}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-211}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 3.5 \cdot 10^{-147}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.37999999999999997e-275 or 5.3000000000000004e-226 < x < 1.35e-211 or 3.50000000000000004e-147 < x < 1.2e24

    1. Initial program 75.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    7. Simplified41.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*41.6%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{{z}^{2}}{y}} \]
      2. unpow241.6%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{z \cdot z}}{y} \]
      3. associate-*l/43.2%

        \[\leadsto -0.5 \cdot \color{blue}{\left(\frac{z}{y} \cdot z\right)} \]
      4. associate-*r*43.2%

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

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

    if 1.37999999999999997e-275 < x < 5.3000000000000004e-226 or 1.35e-211 < x < 3.50000000000000004e-147

    1. Initial program 46.5%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified65.6%

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

    if 1.2e24 < x

    1. Initial program 74.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 inf 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    11. Applied egg-rr77.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.38 \cdot 10^{-275}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-226}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-211}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-147}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+24}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot x}{\frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 42.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 2.45 \cdot 10^{-275}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 4.5 \cdot 10^{-228}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-211}:\\
\;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y\_m}\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-147}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 4.6 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.44999999999999991e-275 or 6.79999999999999991e-147 < x < 4.5999999999999998e24

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    7. Simplified40.1%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*40.1%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{{z}^{2}}{y}} \]
      2. unpow240.1%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{z \cdot z}}{y} \]
      3. associate-*l/41.7%

        \[\leadsto -0.5 \cdot \color{blue}{\left(\frac{z}{y} \cdot z\right)} \]
      4. associate-*r*41.7%

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

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

    if 2.44999999999999991e-275 < x < 4.4999999999999999e-228 or 1.3e-211 < x < 6.79999999999999991e-147

    1. Initial program 46.5%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified65.6%

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

    if 4.4999999999999999e-228 < x < 1.3e-211

    1. Initial program 84.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{y} \cdot \left({\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z\right) \]
      9. pow284.8%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    7. Simplified83.4%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*83.4%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{{z}^{2}}{y}} \]
      2. unpow283.4%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{z \cdot z}}{y} \]
      3. associate-*l/83.1%

        \[\leadsto -0.5 \cdot \color{blue}{\left(\frac{z}{y} \cdot z\right)} \]
      4. associate-*r*83.1%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot z}{y}} \cdot z \]
      2. associate-*l/83.4%

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

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

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

    if 4.5999999999999998e24 < x

    1. Initial program 74.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 inf 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    11. Applied egg-rr77.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.45 \cdot 10^{-275}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-228}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-211}:\\ \;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-147}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+24}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot x}{\frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 92.3% 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}\;x \leq 1.35 \cdot 10^{+193}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot x}{\frac{y\_m}{x}}\\ \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 (<= x 1.35e+193)
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (* z (/ z y_m))))
    (/ (* 0.5 x) (/ y_m x)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.35e+193) {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)));
	} else {
		tmp = (0.5 * x) / (y_m / x);
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 1.35d+193) then
        tmp = 0.5d0 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)))
    else
        tmp = (0.5d0 * x) / (y_m / x)
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.35e+193) {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)));
	} else {
		tmp = (0.5 * x) / (y_m / x);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.35e+193:
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)))
	else:
		tmp = (0.5 * x) / (y_m / x)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 1.35e+193)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z * Float64(z / y_m))));
	else
		tmp = Float64(Float64(0.5 * x) / Float64(y_m / x));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.35e+193)
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)));
	else
		tmp = (0.5 * x) / (y_m / x);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.35e+193], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] / N[(y$95$m / x), $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}\;x \leq 1.35 \cdot 10^{+193}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\

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


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

    1. Initial program 73.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e193 < x

    1. Initial program 66.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 inf 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    11. Applied egg-rr88.9%

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

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

Alternative 6: 92.3% 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}\;x \leq 1.45 \cdot 10^{+193}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - \frac{z}{\frac{y\_m}{z}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot x}{\frac{y\_m}{x}}\\ \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 (<= x 1.45e+193)
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (/ z (/ y_m z))))
    (/ (* 0.5 x) (/ y_m x)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.45e+193) {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	} else {
		tmp = (0.5 * x) / (y_m / x);
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 1.45d+193) then
        tmp = 0.5d0 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)))
    else
        tmp = (0.5d0 * x) / (y_m / x)
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.45e+193) {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	} else {
		tmp = (0.5 * x) / (y_m / x);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.45e+193:
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)))
	else:
		tmp = (0.5 * x) / (y_m / x)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 1.45e+193)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z / Float64(y_m / z))));
	else
		tmp = Float64(Float64(0.5 * x) / Float64(y_m / x));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.45e+193)
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z / (y_m / z)));
	else
		tmp = (0.5 * x) / (y_m / x);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.45e+193], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] / N[(y$95$m / x), $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}\;x \leq 1.45 \cdot 10^{+193}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - \frac{z}{\frac{y\_m}{z}}\right)\\

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


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

    1. Initial program 73.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000007e193 < x

    1. Initial program 66.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 inf 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    11. Applied egg-rr88.9%

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

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

Alternative 7: 43.6% 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}\;x \leq 1.35 \cdot 10^{+25}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{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 (<= x 1.35e+25) (* y_m 0.5) (* x (* x (/ 0.5 y_m))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.35e+25) {
		tmp = y_m * 0.5;
	} else {
		tmp = x * (x * (0.5 / y_m));
	}
	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 (x <= 1.35d+25) then
        tmp = y_m * 0.5d0
    else
        tmp = x * (x * (0.5d0 / y_m))
    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 (x <= 1.35e+25) {
		tmp = y_m * 0.5;
	} else {
		tmp = x * (x * (0.5 / y_m));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.35e+25:
		tmp = y_m * 0.5
	else:
		tmp = x * (x * (0.5 / 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 (x <= 1.35e+25)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(x * Float64(x * Float64(0.5 / y_m)));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.35e+25)
		tmp = y_m * 0.5;
	else
		tmp = x * (x * (0.5 / y_m));
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.35e+25], N[(y$95$m * 0.5), $MachinePrecision], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+25}:\\
\;\;\;\;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.35e25

    1. Initial program 72.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 33.4%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified33.4%

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

    if 1.35e25 < x

    1. Initial program 74.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 inf 74.2%

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

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

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

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

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

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

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

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

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

Alternative 8: 43.6% 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}\;x \leq 1.1 \cdot 10^{+25}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{0.5 \cdot x}{y\_m}\\ \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 (<= x 1.1e+25) (* y_m 0.5) (* x (/ (* 0.5 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 (x <= 1.1e+25) {
		tmp = y_m * 0.5;
	} else {
		tmp = x * ((0.5 * x) / y_m);
	}
	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 (x <= 1.1d+25) then
        tmp = y_m * 0.5d0
    else
        tmp = x * ((0.5d0 * x) / y_m)
    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 (x <= 1.1e+25) {
		tmp = y_m * 0.5;
	} else {
		tmp = x * ((0.5 * x) / y_m);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.1e+25:
		tmp = y_m * 0.5
	else:
		tmp = x * ((0.5 * 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 (x <= 1.1e+25)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(x * Float64(Float64(0.5 * x) / y_m));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.1e+25)
		tmp = y_m * 0.5;
	else
		tmp = x * ((0.5 * x) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.1e+25], N[(y$95$m * 0.5), $MachinePrecision], N[(x * N[(N[(0.5 * x), $MachinePrecision] / y$95$m), $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}\;x \leq 1.1 \cdot 10^{+25}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    1. Initial program 72.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 33.4%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified33.4%

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

    if 1.1e25 < x

    1. Initial program 74.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 inf 74.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 34.4% 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 72.7%

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

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified28.4%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification28.4%

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

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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