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

Percentage Accurate: 69.9% → 90.7%
Time: 11.7s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 69.9% accurate, 1.0× speedup?

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

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

Alternative 1: 90.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 1.3 \cdot 10^{+126}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m + z}{\frac{y_m}{\left(y_m - z\right) \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.3e+126)
    (/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
    (/ (+ y_m z) (/ y_m (* (- y_m z) 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.3e+126) {
		tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
	} else {
		tmp = (y_m + z) / (y_m / ((y_m - z) * 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.3e+126)
		tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0));
	else
		tmp = Float64(Float64(y_m + z) / Float64(y_m / Float64(Float64(y_m - z) * 0.5)));
	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, 1.3e+126], 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[(N[(y$95$m + z), $MachinePrecision] / N[(y$95$m / N[(N[(y$95$m - z), $MachinePrecision] * 0.5), $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.3 \cdot 10^{+126}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\

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


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

    1. Initial program 77.6%

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

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

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

        \[\leadsto \frac{\left(y \cdot y - \color{blue}{\left(-z\right) \cdot \left(-z\right)}\right) + x \cdot x}{y \cdot 2} \]
      4. difference-of-squares78.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-def80.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-neg80.1%

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

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

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

    if 1.3e126 < y

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 52.1% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\ t_1 := \frac{x}{y_m} \cdot \frac{x}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 1.35 \cdot 10^{-276}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 5.2 \cdot 10^{-219}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 2.2 \cdot 10^{-181}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 1.18 \cdot 10^{-153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 6.2 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 49000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 7.8 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 3.15 \cdot 10^{+32} \lor \neg \left(y_m \leq 6.8 \cdot 10^{+68}\right):\\ \;\;\;\;y_m \cdot 0.5\\ \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 (* z (* z (/ -0.5 y_m)))) (t_1 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= y_m 1.35e-276)
      t_1
      (if (<= y_m 5.2e-219)
        t_0
        (if (<= y_m 2.2e-181)
          t_1
          (if (<= y_m 1.18e-153)
            t_0
            (if (<= y_m 6.2e-60)
              t_1
              (if (<= y_m 49000000.0)
                t_0
                (if (<= y_m 7.8e+20)
                  t_1
                  (if (or (<= y_m 3.15e+32) (not (<= y_m 6.8e+68)))
                    (* y_m 0.5)
                    t_0)))))))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = z * (z * (-0.5 / y_m));
	double t_1 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.35e-276) {
		tmp = t_1;
	} else if (y_m <= 5.2e-219) {
		tmp = t_0;
	} else if (y_m <= 2.2e-181) {
		tmp = t_1;
	} else if (y_m <= 1.18e-153) {
		tmp = t_0;
	} else if (y_m <= 6.2e-60) {
		tmp = t_1;
	} else if (y_m <= 49000000.0) {
		tmp = t_0;
	} else if (y_m <= 7.8e+20) {
		tmp = t_1;
	} else if ((y_m <= 3.15e+32) || !(y_m <= 6.8e+68)) {
		tmp = y_m * 0.5;
	} 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 = z * (z * ((-0.5d0) / y_m))
    t_1 = (x / y_m) * (x / 2.0d0)
    if (y_m <= 1.35d-276) then
        tmp = t_1
    else if (y_m <= 5.2d-219) then
        tmp = t_0
    else if (y_m <= 2.2d-181) then
        tmp = t_1
    else if (y_m <= 1.18d-153) then
        tmp = t_0
    else if (y_m <= 6.2d-60) then
        tmp = t_1
    else if (y_m <= 49000000.0d0) then
        tmp = t_0
    else if (y_m <= 7.8d+20) then
        tmp = t_1
    else if ((y_m <= 3.15d+32) .or. (.not. (y_m <= 6.8d+68))) then
        tmp = y_m * 0.5d0
    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 = z * (z * (-0.5 / y_m));
	double t_1 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.35e-276) {
		tmp = t_1;
	} else if (y_m <= 5.2e-219) {
		tmp = t_0;
	} else if (y_m <= 2.2e-181) {
		tmp = t_1;
	} else if (y_m <= 1.18e-153) {
		tmp = t_0;
	} else if (y_m <= 6.2e-60) {
		tmp = t_1;
	} else if (y_m <= 49000000.0) {
		tmp = t_0;
	} else if (y_m <= 7.8e+20) {
		tmp = t_1;
	} else if ((y_m <= 3.15e+32) || !(y_m <= 6.8e+68)) {
		tmp = y_m * 0.5;
	} 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 = z * (z * (-0.5 / y_m))
	t_1 = (x / y_m) * (x / 2.0)
	tmp = 0
	if y_m <= 1.35e-276:
		tmp = t_1
	elif y_m <= 5.2e-219:
		tmp = t_0
	elif y_m <= 2.2e-181:
		tmp = t_1
	elif y_m <= 1.18e-153:
		tmp = t_0
	elif y_m <= 6.2e-60:
		tmp = t_1
	elif y_m <= 49000000.0:
		tmp = t_0
	elif y_m <= 7.8e+20:
		tmp = t_1
	elif (y_m <= 3.15e+32) or not (y_m <= 6.8e+68):
		tmp = y_m * 0.5
	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(z * Float64(z * Float64(-0.5 / y_m)))
	t_1 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (y_m <= 1.35e-276)
		tmp = t_1;
	elseif (y_m <= 5.2e-219)
		tmp = t_0;
	elseif (y_m <= 2.2e-181)
		tmp = t_1;
	elseif (y_m <= 1.18e-153)
		tmp = t_0;
	elseif (y_m <= 6.2e-60)
		tmp = t_1;
	elseif (y_m <= 49000000.0)
		tmp = t_0;
	elseif (y_m <= 7.8e+20)
		tmp = t_1;
	elseif ((y_m <= 3.15e+32) || !(y_m <= 6.8e+68))
		tmp = Float64(y_m * 0.5);
	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 = z * (z * (-0.5 / y_m));
	t_1 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (y_m <= 1.35e-276)
		tmp = t_1;
	elseif (y_m <= 5.2e-219)
		tmp = t_0;
	elseif (y_m <= 2.2e-181)
		tmp = t_1;
	elseif (y_m <= 1.18e-153)
		tmp = t_0;
	elseif (y_m <= 6.2e-60)
		tmp = t_1;
	elseif (y_m <= 49000000.0)
		tmp = t_0;
	elseif (y_m <= 7.8e+20)
		tmp = t_1;
	elseif ((y_m <= 3.15e+32) || ~((y_m <= 6.8e+68)))
		tmp = y_m * 0.5;
	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[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 1.35e-276], t$95$1, If[LessEqual[y$95$m, 5.2e-219], t$95$0, If[LessEqual[y$95$m, 2.2e-181], t$95$1, If[LessEqual[y$95$m, 1.18e-153], t$95$0, If[LessEqual[y$95$m, 6.2e-60], t$95$1, If[LessEqual[y$95$m, 49000000.0], t$95$0, If[LessEqual[y$95$m, 7.8e+20], t$95$1, If[Or[LessEqual[y$95$m, 3.15e+32], N[Not[LessEqual[y$95$m, 6.8e+68]], $MachinePrecision]], N[(y$95$m * 0.5), $MachinePrecision], 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 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\
t_1 := \frac{x}{y_m} \cdot \frac{x}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 1.35 \cdot 10^{-276}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 5.2 \cdot 10^{-219}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 2.2 \cdot 10^{-181}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 1.18 \cdot 10^{-153}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 6.2 \cdot 10^{-60}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 49000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 7.8 \cdot 10^{+20}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 3.15 \cdot 10^{+32} \lor \neg \left(y_m \leq 6.8 \cdot 10^{+68}\right):\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.34999999999999993e-276 or 5.20000000000000004e-219 < y < 2.19999999999999997e-181 or 1.1800000000000001e-153 < y < 6.19999999999999976e-60 or 4.9e7 < y < 7.8e20

    1. Initial program 73.1%

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

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

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

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

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

    if 1.34999999999999993e-276 < y < 5.20000000000000004e-219 or 2.19999999999999997e-181 < y < 1.1800000000000001e-153 or 6.19999999999999976e-60 < y < 4.9e7 or 3.1500000000000001e32 < y < 6.8000000000000003e68

    1. Initial program 88.4%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    5. Simplified61.3%

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

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

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

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

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

    if 7.8e20 < y < 3.1500000000000001e32 or 6.8000000000000003e68 < y

    1. Initial program 48.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{-276}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-219}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-181}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 1.18 \cdot 10^{-153}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-60}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 49000000:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+20}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 3.15 \cdot 10^{+32} \lor \neg \left(y \leq 6.8 \cdot 10^{+68}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.1% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\ t_1 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\ t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 1.25 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 1.4 \cdot 10^{-217}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 2.3 \cdot 10^{-180}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 6.8 \cdot 10^{-152}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 8.5 \cdot 10^{-61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 36000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 8.5 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 6.4 \cdot 10^{+33} \lor \neg \left(y_m \leq 1.25 \cdot 10^{+67}\right):\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (/ -0.5 (/ (/ y_m z) z)))
        (t_1 (* z (* z (/ -0.5 y_m))))
        (t_2 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= y_m 1.25e-276)
      t_2
      (if (<= y_m 1.4e-217)
        t_0
        (if (<= y_m 2.3e-180)
          t_2
          (if (<= y_m 6.8e-152)
            t_0
            (if (<= y_m 8.5e-61)
              t_2
              (if (<= y_m 36000000.0)
                t_1
                (if (<= y_m 8.5e+20)
                  t_2
                  (if (or (<= y_m 6.4e+33) (not (<= y_m 1.25e+67)))
                    (* y_m 0.5)
                    t_1)))))))))))
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 = -0.5 / ((y_m / z) / z);
	double t_1 = z * (z * (-0.5 / y_m));
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.25e-276) {
		tmp = t_2;
	} else if (y_m <= 1.4e-217) {
		tmp = t_0;
	} else if (y_m <= 2.3e-180) {
		tmp = t_2;
	} else if (y_m <= 6.8e-152) {
		tmp = t_0;
	} else if (y_m <= 8.5e-61) {
		tmp = t_2;
	} else if (y_m <= 36000000.0) {
		tmp = t_1;
	} else if (y_m <= 8.5e+20) {
		tmp = t_2;
	} else if ((y_m <= 6.4e+33) || !(y_m <= 1.25e+67)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = (-0.5d0) / ((y_m / z) / z)
    t_1 = z * (z * ((-0.5d0) / y_m))
    t_2 = (x / y_m) * (x / 2.0d0)
    if (y_m <= 1.25d-276) then
        tmp = t_2
    else if (y_m <= 1.4d-217) then
        tmp = t_0
    else if (y_m <= 2.3d-180) then
        tmp = t_2
    else if (y_m <= 6.8d-152) then
        tmp = t_0
    else if (y_m <= 8.5d-61) then
        tmp = t_2
    else if (y_m <= 36000000.0d0) then
        tmp = t_1
    else if (y_m <= 8.5d+20) then
        tmp = t_2
    else if ((y_m <= 6.4d+33) .or. (.not. (y_m <= 1.25d+67))) then
        tmp = y_m * 0.5d0
    else
        tmp = t_1
    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 = -0.5 / ((y_m / z) / z);
	double t_1 = z * (z * (-0.5 / y_m));
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.25e-276) {
		tmp = t_2;
	} else if (y_m <= 1.4e-217) {
		tmp = t_0;
	} else if (y_m <= 2.3e-180) {
		tmp = t_2;
	} else if (y_m <= 6.8e-152) {
		tmp = t_0;
	} else if (y_m <= 8.5e-61) {
		tmp = t_2;
	} else if (y_m <= 36000000.0) {
		tmp = t_1;
	} else if (y_m <= 8.5e+20) {
		tmp = t_2;
	} else if ((y_m <= 6.4e+33) || !(y_m <= 1.25e+67)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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 = -0.5 / ((y_m / z) / z)
	t_1 = z * (z * (-0.5 / y_m))
	t_2 = (x / y_m) * (x / 2.0)
	tmp = 0
	if y_m <= 1.25e-276:
		tmp = t_2
	elif y_m <= 1.4e-217:
		tmp = t_0
	elif y_m <= 2.3e-180:
		tmp = t_2
	elif y_m <= 6.8e-152:
		tmp = t_0
	elif y_m <= 8.5e-61:
		tmp = t_2
	elif y_m <= 36000000.0:
		tmp = t_1
	elif y_m <= 8.5e+20:
		tmp = t_2
	elif (y_m <= 6.4e+33) or not (y_m <= 1.25e+67):
		tmp = y_m * 0.5
	else:
		tmp = t_1
	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(-0.5 / Float64(Float64(y_m / z) / z))
	t_1 = Float64(z * Float64(z * Float64(-0.5 / y_m)))
	t_2 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (y_m <= 1.25e-276)
		tmp = t_2;
	elseif (y_m <= 1.4e-217)
		tmp = t_0;
	elseif (y_m <= 2.3e-180)
		tmp = t_2;
	elseif (y_m <= 6.8e-152)
		tmp = t_0;
	elseif (y_m <= 8.5e-61)
		tmp = t_2;
	elseif (y_m <= 36000000.0)
		tmp = t_1;
	elseif (y_m <= 8.5e+20)
		tmp = t_2;
	elseif ((y_m <= 6.4e+33) || !(y_m <= 1.25e+67))
		tmp = Float64(y_m * 0.5);
	else
		tmp = t_1;
	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 = -0.5 / ((y_m / z) / z);
	t_1 = z * (z * (-0.5 / y_m));
	t_2 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (y_m <= 1.25e-276)
		tmp = t_2;
	elseif (y_m <= 1.4e-217)
		tmp = t_0;
	elseif (y_m <= 2.3e-180)
		tmp = t_2;
	elseif (y_m <= 6.8e-152)
		tmp = t_0;
	elseif (y_m <= 8.5e-61)
		tmp = t_2;
	elseif (y_m <= 36000000.0)
		tmp = t_1;
	elseif (y_m <= 8.5e+20)
		tmp = t_2;
	elseif ((y_m <= 6.4e+33) || ~((y_m <= 1.25e+67)))
		tmp = y_m * 0.5;
	else
		tmp = t_1;
	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[(-0.5 / N[(N[(y$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 1.25e-276], t$95$2, If[LessEqual[y$95$m, 1.4e-217], t$95$0, If[LessEqual[y$95$m, 2.3e-180], t$95$2, If[LessEqual[y$95$m, 6.8e-152], t$95$0, If[LessEqual[y$95$m, 8.5e-61], t$95$2, If[LessEqual[y$95$m, 36000000.0], t$95$1, If[LessEqual[y$95$m, 8.5e+20], t$95$2, If[Or[LessEqual[y$95$m, 6.4e+33], N[Not[LessEqual[y$95$m, 1.25e+67]], $MachinePrecision]], N[(y$95$m * 0.5), $MachinePrecision], t$95$1]]]]]]]]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\
t_1 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\
t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 1.25 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 1.4 \cdot 10^{-217}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 2.3 \cdot 10^{-180}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 6.8 \cdot 10^{-152}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 8.5 \cdot 10^{-61}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 36000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 8.5 \cdot 10^{+20}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 6.4 \cdot 10^{+33} \lor \neg \left(y_m \leq 1.25 \cdot 10^{+67}\right):\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 1.24999999999999992e-276 or 1.4e-217 < y < 2.29999999999999996e-180 or 6.79999999999999968e-152 < y < 8.50000000000000016e-61 or 3.6e7 < y < 8.5e20

    1. Initial program 73.1%

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

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

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

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

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

    if 1.24999999999999992e-276 < y < 1.4e-217 or 2.29999999999999996e-180 < y < 6.79999999999999968e-152

    1. Initial program 88.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity64.6%

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

        \[\leadsto \frac{-0.5}{\frac{1 \cdot y}{\color{blue}{z \cdot z}}} \]
      3. times-frac64.5%

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1}{z} \cdot \frac{y}{z}}} \]
    7. Applied egg-rr64.5%

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

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1 \cdot \frac{y}{z}}{z}}} \]
      2. *-lft-identity64.6%

        \[\leadsto \frac{-0.5}{\frac{\color{blue}{\frac{y}{z}}}{z}} \]
    9. Simplified64.6%

      \[\leadsto \frac{-0.5}{\color{blue}{\frac{\frac{y}{z}}{z}}} \]

    if 8.50000000000000016e-61 < y < 3.6e7 or 6.40000000000000034e33 < y < 1.24999999999999994e67

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

    if 8.5e20 < y < 6.40000000000000034e33 or 1.24999999999999994e67 < y

    1. Initial program 48.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.25 \cdot 10^{-276}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-217}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-180}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-152}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 36000000:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+20}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{+33} \lor \neg \left(y \leq 1.25 \cdot 10^{+67}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 52.0% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\ t_1 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\ t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 1.15 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 3.9 \cdot 10^{-218}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 1.4 \cdot 10^{-180}:\\ \;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\ \mathbf{elif}\;y_m \leq 1.42 \cdot 10^{-151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 1.05 \cdot 10^{-60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 215000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 1.5 \cdot 10^{+21}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 6.2 \cdot 10^{+33} \lor \neg \left(y_m \leq 6.6 \cdot 10^{+69}\right):\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (/ -0.5 (/ (/ y_m z) z)))
        (t_1 (* z (* z (/ -0.5 y_m))))
        (t_2 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= y_m 1.15e-276)
      t_2
      (if (<= y_m 3.9e-218)
        t_0
        (if (<= y_m 1.4e-180)
          (/ x (* y_m (/ 2.0 x)))
          (if (<= y_m 1.42e-151)
            t_0
            (if (<= y_m 1.05e-60)
              t_2
              (if (<= y_m 215000000.0)
                t_1
                (if (<= y_m 1.5e+21)
                  t_2
                  (if (or (<= y_m 6.2e+33) (not (<= y_m 6.6e+69)))
                    (* y_m 0.5)
                    t_1)))))))))))
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 = -0.5 / ((y_m / z) / z);
	double t_1 = z * (z * (-0.5 / y_m));
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.15e-276) {
		tmp = t_2;
	} else if (y_m <= 3.9e-218) {
		tmp = t_0;
	} else if (y_m <= 1.4e-180) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 1.42e-151) {
		tmp = t_0;
	} else if (y_m <= 1.05e-60) {
		tmp = t_2;
	} else if (y_m <= 215000000.0) {
		tmp = t_1;
	} else if (y_m <= 1.5e+21) {
		tmp = t_2;
	} else if ((y_m <= 6.2e+33) || !(y_m <= 6.6e+69)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = (-0.5d0) / ((y_m / z) / z)
    t_1 = z * (z * ((-0.5d0) / y_m))
    t_2 = (x / y_m) * (x / 2.0d0)
    if (y_m <= 1.15d-276) then
        tmp = t_2
    else if (y_m <= 3.9d-218) then
        tmp = t_0
    else if (y_m <= 1.4d-180) then
        tmp = x / (y_m * (2.0d0 / x))
    else if (y_m <= 1.42d-151) then
        tmp = t_0
    else if (y_m <= 1.05d-60) then
        tmp = t_2
    else if (y_m <= 215000000.0d0) then
        tmp = t_1
    else if (y_m <= 1.5d+21) then
        tmp = t_2
    else if ((y_m <= 6.2d+33) .or. (.not. (y_m <= 6.6d+69))) then
        tmp = y_m * 0.5d0
    else
        tmp = t_1
    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 = -0.5 / ((y_m / z) / z);
	double t_1 = z * (z * (-0.5 / y_m));
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.15e-276) {
		tmp = t_2;
	} else if (y_m <= 3.9e-218) {
		tmp = t_0;
	} else if (y_m <= 1.4e-180) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 1.42e-151) {
		tmp = t_0;
	} else if (y_m <= 1.05e-60) {
		tmp = t_2;
	} else if (y_m <= 215000000.0) {
		tmp = t_1;
	} else if (y_m <= 1.5e+21) {
		tmp = t_2;
	} else if ((y_m <= 6.2e+33) || !(y_m <= 6.6e+69)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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 = -0.5 / ((y_m / z) / z)
	t_1 = z * (z * (-0.5 / y_m))
	t_2 = (x / y_m) * (x / 2.0)
	tmp = 0
	if y_m <= 1.15e-276:
		tmp = t_2
	elif y_m <= 3.9e-218:
		tmp = t_0
	elif y_m <= 1.4e-180:
		tmp = x / (y_m * (2.0 / x))
	elif y_m <= 1.42e-151:
		tmp = t_0
	elif y_m <= 1.05e-60:
		tmp = t_2
	elif y_m <= 215000000.0:
		tmp = t_1
	elif y_m <= 1.5e+21:
		tmp = t_2
	elif (y_m <= 6.2e+33) or not (y_m <= 6.6e+69):
		tmp = y_m * 0.5
	else:
		tmp = t_1
	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(-0.5 / Float64(Float64(y_m / z) / z))
	t_1 = Float64(z * Float64(z * Float64(-0.5 / y_m)))
	t_2 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (y_m <= 1.15e-276)
		tmp = t_2;
	elseif (y_m <= 3.9e-218)
		tmp = t_0;
	elseif (y_m <= 1.4e-180)
		tmp = Float64(x / Float64(y_m * Float64(2.0 / x)));
	elseif (y_m <= 1.42e-151)
		tmp = t_0;
	elseif (y_m <= 1.05e-60)
		tmp = t_2;
	elseif (y_m <= 215000000.0)
		tmp = t_1;
	elseif (y_m <= 1.5e+21)
		tmp = t_2;
	elseif ((y_m <= 6.2e+33) || !(y_m <= 6.6e+69))
		tmp = Float64(y_m * 0.5);
	else
		tmp = t_1;
	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 = -0.5 / ((y_m / z) / z);
	t_1 = z * (z * (-0.5 / y_m));
	t_2 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (y_m <= 1.15e-276)
		tmp = t_2;
	elseif (y_m <= 3.9e-218)
		tmp = t_0;
	elseif (y_m <= 1.4e-180)
		tmp = x / (y_m * (2.0 / x));
	elseif (y_m <= 1.42e-151)
		tmp = t_0;
	elseif (y_m <= 1.05e-60)
		tmp = t_2;
	elseif (y_m <= 215000000.0)
		tmp = t_1;
	elseif (y_m <= 1.5e+21)
		tmp = t_2;
	elseif ((y_m <= 6.2e+33) || ~((y_m <= 6.6e+69)))
		tmp = y_m * 0.5;
	else
		tmp = t_1;
	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[(-0.5 / N[(N[(y$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 1.15e-276], t$95$2, If[LessEqual[y$95$m, 3.9e-218], t$95$0, If[LessEqual[y$95$m, 1.4e-180], N[(x / N[(y$95$m * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.42e-151], t$95$0, If[LessEqual[y$95$m, 1.05e-60], t$95$2, If[LessEqual[y$95$m, 215000000.0], t$95$1, If[LessEqual[y$95$m, 1.5e+21], t$95$2, If[Or[LessEqual[y$95$m, 6.2e+33], N[Not[LessEqual[y$95$m, 6.6e+69]], $MachinePrecision]], N[(y$95$m * 0.5), $MachinePrecision], t$95$1]]]]]]]]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\
t_1 := z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\
t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 1.15 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 3.9 \cdot 10^{-218}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 1.4 \cdot 10^{-180}:\\
\;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\

\mathbf{elif}\;y_m \leq 1.42 \cdot 10^{-151}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 1.05 \cdot 10^{-60}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 215000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 1.5 \cdot 10^{+21}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 6.2 \cdot 10^{+33} \lor \neg \left(y_m \leq 6.6 \cdot 10^{+69}\right):\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 1.14999999999999991e-276 or 1.42000000000000002e-151 < y < 1.04999999999999996e-60 or 2.15e8 < y < 1.5e21

    1. Initial program 72.9%

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

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

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

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

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

    if 1.14999999999999991e-276 < y < 3.9e-218 or 1.39999999999999999e-180 < y < 1.42000000000000002e-151

    1. Initial program 88.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity64.6%

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

        \[\leadsto \frac{-0.5}{\frac{1 \cdot y}{\color{blue}{z \cdot z}}} \]
      3. times-frac64.5%

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1}{z} \cdot \frac{y}{z}}} \]
    7. Applied egg-rr64.5%

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

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1 \cdot \frac{y}{z}}{z}}} \]
      2. *-lft-identity64.6%

        \[\leadsto \frac{-0.5}{\frac{\color{blue}{\frac{y}{z}}}{z}} \]
    9. Simplified64.6%

      \[\leadsto \frac{-0.5}{\color{blue}{\frac{\frac{y}{z}}{z}}} \]

    if 3.9e-218 < y < 1.39999999999999999e-180

    1. Initial program 80.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 100.0%

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

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

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

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

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

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

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

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

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

    if 1.04999999999999996e-60 < y < 2.15e8 or 6.2e33 < y < 6.5999999999999997e69

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

    if 1.5e21 < y < 6.2e33 or 6.5999999999999997e69 < y

    1. Initial program 48.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.15 \cdot 10^{-276}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-218}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-180}:\\ \;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{-151}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-60}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 215000000:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+21}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+33} \lor \neg \left(y \leq 6.6 \cdot 10^{+69}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 52.1% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\ t_1 := \frac{z \cdot -0.5}{\frac{y_m}{z}}\\ t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 1.1 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 3.6 \cdot 10^{-217}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 6.5 \cdot 10^{-181}:\\ \;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\ \mathbf{elif}\;y_m \leq 2.8 \cdot 10^{-153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 1.25 \cdot 10^{-59}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 1250000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 2.16 \cdot 10^{+21}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y_m \leq 9.2 \cdot 10^{+32} \lor \neg \left(y_m \leq 9.4 \cdot 10^{+67}\right):\\ \;\;\;\;y_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (/ -0.5 (/ (/ y_m z) z)))
        (t_1 (/ (* z -0.5) (/ y_m z)))
        (t_2 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= y_m 1.1e-276)
      t_2
      (if (<= y_m 3.6e-217)
        t_0
        (if (<= y_m 6.5e-181)
          (/ x (* y_m (/ 2.0 x)))
          (if (<= y_m 2.8e-153)
            t_0
            (if (<= y_m 1.25e-59)
              t_2
              (if (<= y_m 1250000000.0)
                t_1
                (if (<= y_m 2.16e+21)
                  t_2
                  (if (or (<= y_m 9.2e+32) (not (<= y_m 9.4e+67)))
                    (* y_m 0.5)
                    t_1)))))))))))
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 = -0.5 / ((y_m / z) / z);
	double t_1 = (z * -0.5) / (y_m / z);
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.1e-276) {
		tmp = t_2;
	} else if (y_m <= 3.6e-217) {
		tmp = t_0;
	} else if (y_m <= 6.5e-181) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 2.8e-153) {
		tmp = t_0;
	} else if (y_m <= 1.25e-59) {
		tmp = t_2;
	} else if (y_m <= 1250000000.0) {
		tmp = t_1;
	} else if (y_m <= 2.16e+21) {
		tmp = t_2;
	} else if ((y_m <= 9.2e+32) || !(y_m <= 9.4e+67)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = (-0.5d0) / ((y_m / z) / z)
    t_1 = (z * (-0.5d0)) / (y_m / z)
    t_2 = (x / y_m) * (x / 2.0d0)
    if (y_m <= 1.1d-276) then
        tmp = t_2
    else if (y_m <= 3.6d-217) then
        tmp = t_0
    else if (y_m <= 6.5d-181) then
        tmp = x / (y_m * (2.0d0 / x))
    else if (y_m <= 2.8d-153) then
        tmp = t_0
    else if (y_m <= 1.25d-59) then
        tmp = t_2
    else if (y_m <= 1250000000.0d0) then
        tmp = t_1
    else if (y_m <= 2.16d+21) then
        tmp = t_2
    else if ((y_m <= 9.2d+32) .or. (.not. (y_m <= 9.4d+67))) then
        tmp = y_m * 0.5d0
    else
        tmp = t_1
    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 = -0.5 / ((y_m / z) / z);
	double t_1 = (z * -0.5) / (y_m / z);
	double t_2 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 1.1e-276) {
		tmp = t_2;
	} else if (y_m <= 3.6e-217) {
		tmp = t_0;
	} else if (y_m <= 6.5e-181) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 2.8e-153) {
		tmp = t_0;
	} else if (y_m <= 1.25e-59) {
		tmp = t_2;
	} else if (y_m <= 1250000000.0) {
		tmp = t_1;
	} else if (y_m <= 2.16e+21) {
		tmp = t_2;
	} else if ((y_m <= 9.2e+32) || !(y_m <= 9.4e+67)) {
		tmp = y_m * 0.5;
	} else {
		tmp = t_1;
	}
	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 = -0.5 / ((y_m / z) / z)
	t_1 = (z * -0.5) / (y_m / z)
	t_2 = (x / y_m) * (x / 2.0)
	tmp = 0
	if y_m <= 1.1e-276:
		tmp = t_2
	elif y_m <= 3.6e-217:
		tmp = t_0
	elif y_m <= 6.5e-181:
		tmp = x / (y_m * (2.0 / x))
	elif y_m <= 2.8e-153:
		tmp = t_0
	elif y_m <= 1.25e-59:
		tmp = t_2
	elif y_m <= 1250000000.0:
		tmp = t_1
	elif y_m <= 2.16e+21:
		tmp = t_2
	elif (y_m <= 9.2e+32) or not (y_m <= 9.4e+67):
		tmp = y_m * 0.5
	else:
		tmp = t_1
	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(-0.5 / Float64(Float64(y_m / z) / z))
	t_1 = Float64(Float64(z * -0.5) / Float64(y_m / z))
	t_2 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (y_m <= 1.1e-276)
		tmp = t_2;
	elseif (y_m <= 3.6e-217)
		tmp = t_0;
	elseif (y_m <= 6.5e-181)
		tmp = Float64(x / Float64(y_m * Float64(2.0 / x)));
	elseif (y_m <= 2.8e-153)
		tmp = t_0;
	elseif (y_m <= 1.25e-59)
		tmp = t_2;
	elseif (y_m <= 1250000000.0)
		tmp = t_1;
	elseif (y_m <= 2.16e+21)
		tmp = t_2;
	elseif ((y_m <= 9.2e+32) || !(y_m <= 9.4e+67))
		tmp = Float64(y_m * 0.5);
	else
		tmp = t_1;
	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 = -0.5 / ((y_m / z) / z);
	t_1 = (z * -0.5) / (y_m / z);
	t_2 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (y_m <= 1.1e-276)
		tmp = t_2;
	elseif (y_m <= 3.6e-217)
		tmp = t_0;
	elseif (y_m <= 6.5e-181)
		tmp = x / (y_m * (2.0 / x));
	elseif (y_m <= 2.8e-153)
		tmp = t_0;
	elseif (y_m <= 1.25e-59)
		tmp = t_2;
	elseif (y_m <= 1250000000.0)
		tmp = t_1;
	elseif (y_m <= 2.16e+21)
		tmp = t_2;
	elseif ((y_m <= 9.2e+32) || ~((y_m <= 9.4e+67)))
		tmp = y_m * 0.5;
	else
		tmp = t_1;
	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[(-0.5 / N[(N[(y$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * -0.5), $MachinePrecision] / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 1.1e-276], t$95$2, If[LessEqual[y$95$m, 3.6e-217], t$95$0, If[LessEqual[y$95$m, 6.5e-181], N[(x / N[(y$95$m * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 2.8e-153], t$95$0, If[LessEqual[y$95$m, 1.25e-59], t$95$2, If[LessEqual[y$95$m, 1250000000.0], t$95$1, If[LessEqual[y$95$m, 2.16e+21], t$95$2, If[Or[LessEqual[y$95$m, 9.2e+32], N[Not[LessEqual[y$95$m, 9.4e+67]], $MachinePrecision]], N[(y$95$m * 0.5), $MachinePrecision], t$95$1]]]]]]]]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\
t_1 := \frac{z \cdot -0.5}{\frac{y_m}{z}}\\
t_2 := \frac{x}{y_m} \cdot \frac{x}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 1.1 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 3.6 \cdot 10^{-217}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 6.5 \cdot 10^{-181}:\\
\;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\

\mathbf{elif}\;y_m \leq 2.8 \cdot 10^{-153}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 1.25 \cdot 10^{-59}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 1250000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 2.16 \cdot 10^{+21}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y_m \leq 9.2 \cdot 10^{+32} \lor \neg \left(y_m \leq 9.4 \cdot 10^{+67}\right):\\
\;\;\;\;y_m \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 1.0999999999999999e-276 or 2.8000000000000001e-153 < y < 1.25e-59 or 1.25e9 < y < 2.16e21

    1. Initial program 72.9%

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

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

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

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

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

    if 1.0999999999999999e-276 < y < 3.59999999999999981e-217 or 6.4999999999999997e-181 < y < 2.8000000000000001e-153

    1. Initial program 88.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity64.6%

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

        \[\leadsto \frac{-0.5}{\frac{1 \cdot y}{\color{blue}{z \cdot z}}} \]
      3. times-frac64.5%

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1}{z} \cdot \frac{y}{z}}} \]
    7. Applied egg-rr64.5%

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

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1 \cdot \frac{y}{z}}{z}}} \]
      2. *-lft-identity64.6%

        \[\leadsto \frac{-0.5}{\frac{\color{blue}{\frac{y}{z}}}{z}} \]
    9. Simplified64.6%

      \[\leadsto \frac{-0.5}{\color{blue}{\frac{\frac{y}{z}}{z}}} \]

    if 3.59999999999999981e-217 < y < 6.4999999999999997e-181

    1. Initial program 80.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 100.0%

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

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

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

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

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

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

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

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

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

    if 1.25e-59 < y < 1.25e9 or 9.1999999999999998e32 < y < 9.40000000000000035e67

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot -0.5}}{\frac{y}{z}} \]
    9. Applied egg-rr58.2%

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

    if 2.16e21 < y < 9.1999999999999998e32 or 9.40000000000000035e67 < y

    1. Initial program 48.6%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification48.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.1 \cdot 10^{-276}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-217}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-181}:\\ \;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-153}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-59}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 1250000000:\\ \;\;\;\;\frac{z \cdot -0.5}{\frac{y}{z}}\\ \mathbf{elif}\;y \leq 2.16 \cdot 10^{+21}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{+32} \lor \neg \left(y \leq 9.4 \cdot 10^{+67}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot -0.5}{\frac{y}{z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 59.8% 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{-0.5}{\frac{\frac{y_m}{z}}{z}}\\ t_1 := \frac{x}{y_m} \cdot \frac{x}{2}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 9 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 1.32 \cdot 10^{-216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 2.4 \cdot 10^{-182}:\\ \;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\ \mathbf{elif}\;y_m \leq 3.2 \cdot 10^{-153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y_m \leq 8 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y_m \leq 2.6 \cdot 10^{+162}:\\ \;\;\;\;\frac{\left(y_m - z\right) \cdot \left(y_m + z\right)}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y_m \cdot 0.5\\ \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 (/ -0.5 (/ (/ y_m z) z))) (t_1 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= y_m 9e-277)
      t_1
      (if (<= y_m 1.32e-216)
        t_0
        (if (<= y_m 2.4e-182)
          (/ x (* y_m (/ 2.0 x)))
          (if (<= y_m 3.2e-153)
            t_0
            (if (<= y_m 8e-61)
              t_1
              (if (<= y_m 2.6e+162)
                (/ (* (- y_m z) (+ y_m z)) (* y_m 2.0))
                (* 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 t_0 = -0.5 / ((y_m / z) / z);
	double t_1 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 9e-277) {
		tmp = t_1;
	} else if (y_m <= 1.32e-216) {
		tmp = t_0;
	} else if (y_m <= 2.4e-182) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 3.2e-153) {
		tmp = t_0;
	} else if (y_m <= 8e-61) {
		tmp = t_1;
	} else if (y_m <= 2.6e+162) {
		tmp = ((y_m - z) * (y_m + z)) / (y_m * 2.0);
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) / ((y_m / z) / z)
    t_1 = (x / y_m) * (x / 2.0d0)
    if (y_m <= 9d-277) then
        tmp = t_1
    else if (y_m <= 1.32d-216) then
        tmp = t_0
    else if (y_m <= 2.4d-182) then
        tmp = x / (y_m * (2.0d0 / x))
    else if (y_m <= 3.2d-153) then
        tmp = t_0
    else if (y_m <= 8d-61) then
        tmp = t_1
    else if (y_m <= 2.6d+162) then
        tmp = ((y_m - z) * (y_m + z)) / (y_m * 2.0d0)
    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 t_0 = -0.5 / ((y_m / z) / z);
	double t_1 = (x / y_m) * (x / 2.0);
	double tmp;
	if (y_m <= 9e-277) {
		tmp = t_1;
	} else if (y_m <= 1.32e-216) {
		tmp = t_0;
	} else if (y_m <= 2.4e-182) {
		tmp = x / (y_m * (2.0 / x));
	} else if (y_m <= 3.2e-153) {
		tmp = t_0;
	} else if (y_m <= 8e-61) {
		tmp = t_1;
	} else if (y_m <= 2.6e+162) {
		tmp = ((y_m - z) * (y_m + z)) / (y_m * 2.0);
	} 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):
	t_0 = -0.5 / ((y_m / z) / z)
	t_1 = (x / y_m) * (x / 2.0)
	tmp = 0
	if y_m <= 9e-277:
		tmp = t_1
	elif y_m <= 1.32e-216:
		tmp = t_0
	elif y_m <= 2.4e-182:
		tmp = x / (y_m * (2.0 / x))
	elif y_m <= 3.2e-153:
		tmp = t_0
	elif y_m <= 8e-61:
		tmp = t_1
	elif y_m <= 2.6e+162:
		tmp = ((y_m - z) * (y_m + z)) / (y_m * 2.0)
	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)
	t_0 = Float64(-0.5 / Float64(Float64(y_m / z) / z))
	t_1 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (y_m <= 9e-277)
		tmp = t_1;
	elseif (y_m <= 1.32e-216)
		tmp = t_0;
	elseif (y_m <= 2.4e-182)
		tmp = Float64(x / Float64(y_m * Float64(2.0 / x)));
	elseif (y_m <= 3.2e-153)
		tmp = t_0;
	elseif (y_m <= 8e-61)
		tmp = t_1;
	elseif (y_m <= 2.6e+162)
		tmp = Float64(Float64(Float64(y_m - z) * Float64(y_m + z)) / Float64(y_m * 2.0));
	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)
	t_0 = -0.5 / ((y_m / z) / z);
	t_1 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (y_m <= 9e-277)
		tmp = t_1;
	elseif (y_m <= 1.32e-216)
		tmp = t_0;
	elseif (y_m <= 2.4e-182)
		tmp = x / (y_m * (2.0 / x));
	elseif (y_m <= 3.2e-153)
		tmp = t_0;
	elseif (y_m <= 8e-61)
		tmp = t_1;
	elseif (y_m <= 2.6e+162)
		tmp = ((y_m - z) * (y_m + z)) / (y_m * 2.0);
	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_] := Block[{t$95$0 = N[(-0.5 / N[(N[(y$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 9e-277], t$95$1, If[LessEqual[y$95$m, 1.32e-216], t$95$0, If[LessEqual[y$95$m, 2.4e-182], N[(x / N[(y$95$m * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 3.2e-153], t$95$0, If[LessEqual[y$95$m, 8e-61], t$95$1, If[LessEqual[y$95$m, 2.6e+162], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $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)

\\
\begin{array}{l}
t_0 := \frac{-0.5}{\frac{\frac{y_m}{z}}{z}}\\
t_1 := \frac{x}{y_m} \cdot \frac{x}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 9 \cdot 10^{-277}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 1.32 \cdot 10^{-216}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 2.4 \cdot 10^{-182}:\\
\;\;\;\;\frac{x}{y_m \cdot \frac{2}{x}}\\

\mathbf{elif}\;y_m \leq 3.2 \cdot 10^{-153}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y_m \leq 8 \cdot 10^{-61}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y_m \leq 2.6 \cdot 10^{+162}:\\
\;\;\;\;\frac{\left(y_m - z\right) \cdot \left(y_m + z\right)}{y_m \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;y_m \cdot 0.5\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 8.99999999999999985e-277 or 3.1999999999999999e-153 < y < 8.0000000000000003e-61

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

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

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

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

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

    if 8.99999999999999985e-277 < y < 1.31999999999999997e-216 or 2.3999999999999998e-182 < y < 3.1999999999999999e-153

    1. Initial program 88.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity64.6%

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

        \[\leadsto \frac{-0.5}{\frac{1 \cdot y}{\color{blue}{z \cdot z}}} \]
      3. times-frac64.5%

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1}{z} \cdot \frac{y}{z}}} \]
    7. Applied egg-rr64.5%

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

        \[\leadsto \frac{-0.5}{\color{blue}{\frac{1 \cdot \frac{y}{z}}{z}}} \]
      2. *-lft-identity64.6%

        \[\leadsto \frac{-0.5}{\frac{\color{blue}{\frac{y}{z}}}{z}} \]
    9. Simplified64.6%

      \[\leadsto \frac{-0.5}{\color{blue}{\frac{\frac{y}{z}}{z}}} \]

    if 1.31999999999999997e-216 < y < 2.3999999999999998e-182

    1. Initial program 80.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 100.0%

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

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

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

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

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

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

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

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

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

    if 8.0000000000000003e-61 < y < 2.6e162

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

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

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

    if 2.6e162 < y

    1. Initial program 15.0%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification50.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9 \cdot 10^{-277}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-216}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-182}:\\ \;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-153}:\\ \;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-61}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+162}:\\ \;\;\;\;\frac{\left(y - z\right) \cdot \left(y + z\right)}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 73.7% accurate, 0.6× 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 4.8 \cdot 10^{+104} \lor \neg \left(x \leq 5.9 \cdot 10^{+166}\right) \land x \leq 5.3 \cdot 10^{+172}:\\ \;\;\;\;\frac{y_m + z}{\frac{y_m}{\left(y_m - z\right) \cdot 0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y_m} \cdot \frac{x}{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 (or (<= x 4.8e+104) (and (not (<= x 5.9e+166)) (<= x 5.3e+172)))
    (/ (+ y_m z) (/ y_m (* (- y_m z) 0.5)))
    (* (/ x y_m) (/ x 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 ((x <= 4.8e+104) || (!(x <= 5.9e+166) && (x <= 5.3e+172))) {
		tmp = (y_m + z) / (y_m / ((y_m - z) * 0.5));
	} else {
		tmp = (x / y_m) * (x / 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 ((x <= 4.8d+104) .or. (.not. (x <= 5.9d+166)) .and. (x <= 5.3d+172)) then
        tmp = (y_m + z) / (y_m / ((y_m - z) * 0.5d0))
    else
        tmp = (x / y_m) * (x / 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 ((x <= 4.8e+104) || (!(x <= 5.9e+166) && (x <= 5.3e+172))) {
		tmp = (y_m + z) / (y_m / ((y_m - z) * 0.5));
	} else {
		tmp = (x / y_m) * (x / 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 (x <= 4.8e+104) or (not (x <= 5.9e+166) and (x <= 5.3e+172)):
		tmp = (y_m + z) / (y_m / ((y_m - z) * 0.5))
	else:
		tmp = (x / y_m) * (x / 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 ((x <= 4.8e+104) || (!(x <= 5.9e+166) && (x <= 5.3e+172)))
		tmp = Float64(Float64(y_m + z) / Float64(y_m / Float64(Float64(y_m - z) * 0.5)));
	else
		tmp = Float64(Float64(x / y_m) * Float64(x / 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 ((x <= 4.8e+104) || (~((x <= 5.9e+166)) && (x <= 5.3e+172)))
		tmp = (y_m + z) / (y_m / ((y_m - z) * 0.5));
	else
		tmp = (x / y_m) * (x / 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[Or[LessEqual[x, 4.8e+104], And[N[Not[LessEqual[x, 5.9e+166]], $MachinePrecision], LessEqual[x, 5.3e+172]]], N[(N[(y$95$m + z), $MachinePrecision] / N[(y$95$m / N[(N[(y$95$m - z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 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}\;x \leq 4.8 \cdot 10^{+104} \lor \neg \left(x \leq 5.9 \cdot 10^{+166}\right) \land x \leq 5.3 \cdot 10^{+172}:\\
\;\;\;\;\frac{y_m + z}{\frac{y_m}{\left(y_m - z\right) \cdot 0.5}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.8e104 or 5.90000000000000012e166 < x < 5.3e172

    1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e104 < x < 5.90000000000000012e166 or 5.3e172 < x

    1. Initial program 67.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 73.2%

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

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

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

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

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

Alternative 8: 43.5% 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.2 \cdot 10^{+70}:\\ \;\;\;\;\frac{y_m + z}{2}\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+82} \lor \neg \left(z \leq 5.6 \cdot 10^{+113}\right):\\ \;\;\;\;z \cdot \left(z \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 (<= z 4.2e+70)
    (/ (+ y_m z) 2.0)
    (if (or (<= z 2.9e+82) (not (<= z 5.6e+113)))
      (* z (* z (/ -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 (z <= 4.2e+70) {
		tmp = (y_m + z) / 2.0;
	} else if ((z <= 2.9e+82) || !(z <= 5.6e+113)) {
		tmp = z * (z * (-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 (z <= 4.2d+70) then
        tmp = (y_m + z) / 2.0d0
    else if ((z <= 2.9d+82) .or. (.not. (z <= 5.6d+113))) then
        tmp = z * (z * ((-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 (z <= 4.2e+70) {
		tmp = (y_m + z) / 2.0;
	} else if ((z <= 2.9e+82) || !(z <= 5.6e+113)) {
		tmp = z * (z * (-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 z <= 4.2e+70:
		tmp = (y_m + z) / 2.0
	elif (z <= 2.9e+82) or not (z <= 5.6e+113):
		tmp = z * (z * (-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 (z <= 4.2e+70)
		tmp = Float64(Float64(y_m + z) / 2.0);
	elseif ((z <= 2.9e+82) || !(z <= 5.6e+113))
		tmp = Float64(z * Float64(z * 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 (z <= 4.2e+70)
		tmp = (y_m + z) / 2.0;
	elseif ((z <= 2.9e+82) || ~((z <= 5.6e+113)))
		tmp = z * (z * (-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[z, 4.2e+70], N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[z, 2.9e+82], N[Not[LessEqual[z, 5.6e+113]], $MachinePrecision]], N[(z * N[(z * 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}\;z \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;\frac{y_m + z}{2}\\

\mathbf{elif}\;z \leq 2.9 \cdot 10^{+82} \lor \neg \left(z \leq 5.6 \cdot 10^{+113}\right):\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y_m}\right)\\

\mathbf{else}:\\
\;\;\;\;y_m \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 4.20000000000000015e70

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.20000000000000015e70 < z < 2.9000000000000001e82 or 5.59999999999999995e113 < z

    1. Initial program 71.6%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{y}{{z}^{2}}}} \]
    5. Simplified79.2%

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

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

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

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

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

    if 2.9000000000000001e82 < z < 5.59999999999999995e113

    1. Initial program 27.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 4.2 \cdot 10^{+70}:\\ \;\;\;\;\frac{y + z}{2}\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+82} \lor \neg \left(z \leq 5.6 \cdot 10^{+113}\right):\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 88.5% 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 3.8 \cdot 10^{+125}:\\ \;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m + z}{\frac{y_m}{\left(y_m - z\right) \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 3.8e+125)
    (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
    (/ (+ y_m z) (/ y_m (* (- y_m z) 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 <= 3.8e+125) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = (y_m + z) / (y_m / ((y_m - z) * 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 <= 3.8d+125) then
        tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = (y_m + z) / (y_m / ((y_m - z) * 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 <= 3.8e+125) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = (y_m + z) / (y_m / ((y_m - z) * 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 <= 3.8e+125:
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = (y_m + z) / (y_m / ((y_m - z) * 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 <= 3.8e+125)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(Float64(y_m + z) / Float64(y_m / Float64(Float64(y_m - z) * 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 <= 3.8e+125)
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	else
		tmp = (y_m + z) / (y_m / ((y_m - z) * 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, 3.8e+125], 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[(y$95$m + z), $MachinePrecision] / N[(y$95$m / N[(N[(y$95$m - z), $MachinePrecision] * 0.5), $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 3.8 \cdot 10^{+125}:\\
\;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\

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


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

    1. Initial program 77.6%

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

    if 3.80000000000000002e125 < y

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 33.6% accurate, 5.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \left(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.1%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Final simplification37.0%

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