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

Percentage Accurate: 68.9% → 96.0%
Time: 13.2s
Alternatives: 11
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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: 68.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: 96.0% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ t_1 := \mathsf{hypot}\left(x, y\_m + z\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-132} \lor \neg \left(t\_0 \leq \infty\right):\\ \;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{t\_1}{\frac{y\_m}{t\_1}}\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)))
        (t_1 (hypot x (+ y_m z))))
   (*
    y_s
    (if (or (<= t_0 -1e-132) (not (<= t_0 INFINITY)))
      (* 0.5 (- y_m (* z (/ z y_m))))
      (* 0.5 (/ t_1 (/ y_m 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 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	double t_1 = hypot(x, (y_m + z));
	double tmp;
	if ((t_0 <= -1e-132) || !(t_0 <= ((double) INFINITY))) {
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	} else {
		tmp = 0.5 * (t_1 / (y_m / t_1));
	}
	return y_s * tmp;
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	double t_1 = Math.hypot(x, (y_m + z));
	double tmp;
	if ((t_0 <= -1e-132) || !(t_0 <= Double.POSITIVE_INFINITY)) {
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	} else {
		tmp = 0.5 * (t_1 / (y_m / 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 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	t_1 = math.hypot(x, (y_m + z))
	tmp = 0
	if (t_0 <= -1e-132) or not (t_0 <= math.inf):
		tmp = 0.5 * (y_m - (z * (z / y_m)))
	else:
		tmp = 0.5 * (t_1 / (y_m / 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(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0))
	t_1 = hypot(x, Float64(y_m + z))
	tmp = 0.0
	if ((t_0 <= -1e-132) || !(t_0 <= Inf))
		tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m))));
	else
		tmp = Float64(0.5 * Float64(t_1 / Float64(y_m / 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 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	t_1 = hypot(x, (y_m + z));
	tmp = 0.0;
	if ((t_0 <= -1e-132) || ~((t_0 <= Inf)))
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	else
		tmp = 0.5 * (t_1 / (y_m / 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[(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]}, Block[{t$95$1 = N[Sqrt[x ^ 2 + N[(y$95$m + z), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(y$95$s * If[Or[LessEqual[t$95$0, -1e-132], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(t$95$1 / N[(y$95$m / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
t_1 := \mathsf{hypot}\left(x, y\_m + z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-132} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -9.9999999999999999e-133 or +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{{y}^{2} - {z}^{2}}{y}} \]
    6. Step-by-step derivation
      1. div-sub43.1%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(y + z, y - z, \mathsf{fma}\left(-z, z, {z}^{2}\right)\right)}\right)}{y} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt45.5%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{hypot}\left(x, y + z\right)} \cdot \frac{\mathsf{hypot}\left(x, y + z\right)}{y}\right) \]
      2. clear-num65.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(x, y + z\right) \cdot \color{blue}{\frac{1}{\frac{y}{\mathsf{hypot}\left(x, y + z\right)}}}\right) \]
      3. un-div-inv65.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{\mathsf{hypot}\left(x, y + z\right)}{\frac{y}{\mathsf{hypot}\left(x, y + z\right)}}} \]
    10. Applied egg-rr65.6%

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

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

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

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

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


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

    1. Initial program 78.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000003e151 < y

    1. Initial program 12.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{{y}^{2} - {z}^{2}}{y}} \]
    6. Step-by-step derivation
      1. div-sub12.9%

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{y \cdot \frac{y}{y}} - \frac{{z}^{2}}{y}\right) \]
      4. *-inverses77.0%

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

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

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

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

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

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

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

Alternative 3: 42.2% 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 := x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 10^{-214}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-119}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-14}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+41}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+62}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+92} \lor \neg \left(z \leq 4.2 \cdot 10^{+134}\right) \land z \leq 9 \cdot 10^{+158}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y\_m}\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* x (* x (/ 0.5 y_m)))))
   (*
    y_s
    (if (<= z 1e-214)
      t_0
      (if (<= z 1.25e-119)
        (* y_m 0.5)
        (if (<= z 1.7e-14)
          t_0
          (if (<= z 1.95e+32)
            (* y_m 0.5)
            (if (<= z 1.35e+41)
              t_0
              (if (<= z 8e+62)
                (* z (* z (/ -0.5 y_m)))
                (if (or (<= z 6.5e+92)
                        (and (not (<= z 4.2e+134)) (<= z 9e+158)))
                  (* y_m 0.5)
                  (* z (/ (/ z -2.0) y_m))))))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = x * (x * (0.5 / y_m));
	double tmp;
	if (z <= 1e-214) {
		tmp = t_0;
	} else if (z <= 1.25e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 1.7e-14) {
		tmp = t_0;
	} else if (z <= 1.95e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 1.35e+41) {
		tmp = t_0;
	} else if (z <= 8e+62) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 6.5e+92) || (!(z <= 4.2e+134) && (z <= 9e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (x * (0.5d0 / y_m))
    if (z <= 1d-214) then
        tmp = t_0
    else if (z <= 1.25d-119) then
        tmp = y_m * 0.5d0
    else if (z <= 1.7d-14) then
        tmp = t_0
    else if (z <= 1.95d+32) then
        tmp = y_m * 0.5d0
    else if (z <= 1.35d+41) then
        tmp = t_0
    else if (z <= 8d+62) then
        tmp = z * (z * ((-0.5d0) / y_m))
    else if ((z <= 6.5d+92) .or. (.not. (z <= 4.2d+134)) .and. (z <= 9d+158)) then
        tmp = y_m * 0.5d0
    else
        tmp = z * ((z / (-2.0d0)) / y_m)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = x * (x * (0.5 / y_m));
	double tmp;
	if (z <= 1e-214) {
		tmp = t_0;
	} else if (z <= 1.25e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 1.7e-14) {
		tmp = t_0;
	} else if (z <= 1.95e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 1.35e+41) {
		tmp = t_0;
	} else if (z <= 8e+62) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 6.5e+92) || (!(z <= 4.2e+134) && (z <= 9e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = x * (x * (0.5 / y_m))
	tmp = 0
	if z <= 1e-214:
		tmp = t_0
	elif z <= 1.25e-119:
		tmp = y_m * 0.5
	elif z <= 1.7e-14:
		tmp = t_0
	elif z <= 1.95e+32:
		tmp = y_m * 0.5
	elif z <= 1.35e+41:
		tmp = t_0
	elif z <= 8e+62:
		tmp = z * (z * (-0.5 / y_m))
	elif (z <= 6.5e+92) or (not (z <= 4.2e+134) and (z <= 9e+158)):
		tmp = y_m * 0.5
	else:
		tmp = z * ((z / -2.0) / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(x * Float64(x * Float64(0.5 / y_m)))
	tmp = 0.0
	if (z <= 1e-214)
		tmp = t_0;
	elseif (z <= 1.25e-119)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 1.7e-14)
		tmp = t_0;
	elseif (z <= 1.95e+32)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 1.35e+41)
		tmp = t_0;
	elseif (z <= 8e+62)
		tmp = Float64(z * Float64(z * Float64(-0.5 / y_m)));
	elseif ((z <= 6.5e+92) || (!(z <= 4.2e+134) && (z <= 9e+158)))
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(z * Float64(Float64(z / -2.0) / y_m));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = x * (x * (0.5 / y_m));
	tmp = 0.0;
	if (z <= 1e-214)
		tmp = t_0;
	elseif (z <= 1.25e-119)
		tmp = y_m * 0.5;
	elseif (z <= 1.7e-14)
		tmp = t_0;
	elseif (z <= 1.95e+32)
		tmp = y_m * 0.5;
	elseif (z <= 1.35e+41)
		tmp = t_0;
	elseif (z <= 8e+62)
		tmp = z * (z * (-0.5 / y_m));
	elseif ((z <= 6.5e+92) || (~((z <= 4.2e+134)) && (z <= 9e+158)))
		tmp = y_m * 0.5;
	else
		tmp = z * ((z / -2.0) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1e-214], t$95$0, If[LessEqual[z, 1.25e-119], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 1.7e-14], t$95$0, If[LessEqual[z, 1.95e+32], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 1.35e+41], t$95$0, If[LessEqual[z, 8e+62], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 6.5e+92], And[N[Not[LessEqual[z, 4.2e+134]], $MachinePrecision], LessEqual[z, 9e+158]]], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(N[(z / -2.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{elif}\;z \leq 1.25 \cdot 10^{-119}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 1.7 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8 \cdot 10^{+62}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+92} \lor \neg \left(z \leq 4.2 \cdot 10^{+134}\right) \land z \leq 9 \cdot 10^{+158}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 9.99999999999999913e-215 or 1.24999999999999998e-119 < z < 1.70000000000000001e-14 or 1.95e32 < z < 1.35e41

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-172.7%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/73.1%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/38.7%

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \cdot {x}^{2} \]
      4. div-inv38.8%

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

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

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

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

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

    if 9.99999999999999913e-215 < z < 1.24999999999999998e-119 or 1.70000000000000001e-14 < z < 1.95e32 or 8.00000000000000028e62 < z < 6.49999999999999999e92 or 4.2000000000000002e134 < z < 9.00000000000000092e158

    1. Initial program 63.7%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified66.9%

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

    if 1.35e41 < z < 8.00000000000000028e62

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

    if 6.49999999999999999e92 < z < 4.2000000000000002e134 or 9.00000000000000092e158 < z

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{z}{\frac{y}{-0.5}}} \]
      3. div-inv79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{y \cdot \frac{1}{-0.5}}} \]
      4. metadata-eval79.9%

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

      \[\leadsto z \cdot \color{blue}{\frac{z}{y \cdot -2}} \]
    10. Step-by-step derivation
      1. *-commutative79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{-2 \cdot y}} \]
      2. associate-/r*79.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 10^{-214}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-119}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+41}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+62}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+92} \lor \neg \left(z \leq 4.2 \cdot 10^{+134}\right) \land z \leq 9 \cdot 10^{+158}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 42.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{x}{y\_m} \cdot \frac{x}{2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 6 \cdot 10^{-215}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+37}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 1.32 \cdot 10^{+60}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+92} \lor \neg \left(z \leq 8 \cdot 10^{+133}\right) \land z \leq 9 \cdot 10^{+158}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y\_m}\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (* (/ x y_m) (/ x 2.0))))
   (*
    y_s
    (if (<= z 6e-215)
      t_0
      (if (<= z 1.02e-119)
        (* y_m 0.5)
        (if (<= z 6.2e-15)
          t_0
          (if (<= z 2e+32)
            (* y_m 0.5)
            (if (<= z 4e+37)
              (* x (* x (/ 0.5 y_m)))
              (if (<= z 1.32e+60)
                (* z (* z (/ -0.5 y_m)))
                (if (or (<= z 1.3e+92) (and (not (<= z 8e+133)) (<= z 9e+158)))
                  (* y_m 0.5)
                  (* z (/ (/ z -2.0) y_m))))))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = (x / y_m) * (x / 2.0);
	double tmp;
	if (z <= 6e-215) {
		tmp = t_0;
	} else if (z <= 1.02e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 6.2e-15) {
		tmp = t_0;
	} else if (z <= 2e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 4e+37) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 1.32e+60) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 1.3e+92) || (!(z <= 8e+133) && (z <= 9e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x / y_m) * (x / 2.0d0)
    if (z <= 6d-215) then
        tmp = t_0
    else if (z <= 1.02d-119) then
        tmp = y_m * 0.5d0
    else if (z <= 6.2d-15) then
        tmp = t_0
    else if (z <= 2d+32) then
        tmp = y_m * 0.5d0
    else if (z <= 4d+37) then
        tmp = x * (x * (0.5d0 / y_m))
    else if (z <= 1.32d+60) then
        tmp = z * (z * ((-0.5d0) / y_m))
    else if ((z <= 1.3d+92) .or. (.not. (z <= 8d+133)) .and. (z <= 9d+158)) then
        tmp = y_m * 0.5d0
    else
        tmp = z * ((z / (-2.0d0)) / y_m)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = (x / y_m) * (x / 2.0);
	double tmp;
	if (z <= 6e-215) {
		tmp = t_0;
	} else if (z <= 1.02e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 6.2e-15) {
		tmp = t_0;
	} else if (z <= 2e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 4e+37) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 1.32e+60) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 1.3e+92) || (!(z <= 8e+133) && (z <= 9e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = (x / y_m) * (x / 2.0)
	tmp = 0
	if z <= 6e-215:
		tmp = t_0
	elif z <= 1.02e-119:
		tmp = y_m * 0.5
	elif z <= 6.2e-15:
		tmp = t_0
	elif z <= 2e+32:
		tmp = y_m * 0.5
	elif z <= 4e+37:
		tmp = x * (x * (0.5 / y_m))
	elif z <= 1.32e+60:
		tmp = z * (z * (-0.5 / y_m))
	elif (z <= 1.3e+92) or (not (z <= 8e+133) and (z <= 9e+158)):
		tmp = y_m * 0.5
	else:
		tmp = z * ((z / -2.0) / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(x / y_m) * Float64(x / 2.0))
	tmp = 0.0
	if (z <= 6e-215)
		tmp = t_0;
	elseif (z <= 1.02e-119)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 6.2e-15)
		tmp = t_0;
	elseif (z <= 2e+32)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 4e+37)
		tmp = Float64(x * Float64(x * Float64(0.5 / y_m)));
	elseif (z <= 1.32e+60)
		tmp = Float64(z * Float64(z * Float64(-0.5 / y_m)));
	elseif ((z <= 1.3e+92) || (!(z <= 8e+133) && (z <= 9e+158)))
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(z * Float64(Float64(z / -2.0) / y_m));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = (x / y_m) * (x / 2.0);
	tmp = 0.0;
	if (z <= 6e-215)
		tmp = t_0;
	elseif (z <= 1.02e-119)
		tmp = y_m * 0.5;
	elseif (z <= 6.2e-15)
		tmp = t_0;
	elseif (z <= 2e+32)
		tmp = y_m * 0.5;
	elseif (z <= 4e+37)
		tmp = x * (x * (0.5 / y_m));
	elseif (z <= 1.32e+60)
		tmp = z * (z * (-0.5 / y_m));
	elseif ((z <= 1.3e+92) || (~((z <= 8e+133)) && (z <= 9e+158)))
		tmp = y_m * 0.5;
	else
		tmp = z * ((z / -2.0) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 6e-215], t$95$0, If[LessEqual[z, 1.02e-119], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 6.2e-15], t$95$0, If[LessEqual[z, 2e+32], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 4e+37], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.32e+60], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.3e+92], And[N[Not[LessEqual[z, 8e+133]], $MachinePrecision], LessEqual[z, 9e+158]]], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(N[(z / -2.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{x}{y\_m} \cdot \frac{x}{2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 6 \cdot 10^{-215}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 4 \cdot 10^{+37}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 1.32 \cdot 10^{+60}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 1.3 \cdot 10^{+92} \lor \neg \left(z \leq 8 \cdot 10^{+133}\right) \land z \leq 9 \cdot 10^{+158}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < 6.00000000000000051e-215 or 1.02e-119 < z < 6.1999999999999998e-15

    1. Initial program 72.8%

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

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow272.4%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-172.4%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/72.8%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/38.0%

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

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

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

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

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

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

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

    if 6.00000000000000051e-215 < z < 1.02e-119 or 6.1999999999999998e-15 < z < 2.00000000000000011e32 or 1.32e60 < z < 1.2999999999999999e92 or 8.0000000000000002e133 < z < 9.00000000000000092e158

    1. Initial program 63.7%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified66.9%

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

    if 2.00000000000000011e32 < z < 3.99999999999999982e37

    1. Initial program 100.0%

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

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

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

        \[\leadsto {\color{blue}{\left(y \cdot \frac{2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}}^{-1} \]
      4. add-sqr-sqrt100.0%

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow2100.0%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-1100.0%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/100.0%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/100.0%

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

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

        \[\leadsto \color{blue}{\frac{1}{2 \cdot y} \cdot {x}^{2}} \]
      2. *-commutative100.0%

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \cdot {x}^{2} \]
      4. div-inv100.0%

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

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

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

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

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

    if 3.99999999999999982e37 < z < 1.32e60

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

    if 1.2999999999999999e92 < z < 8.0000000000000002e133 or 9.00000000000000092e158 < z

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{z}{\frac{y}{-0.5}}} \]
      3. div-inv79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{y \cdot \frac{1}{-0.5}}} \]
      4. metadata-eval79.9%

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

      \[\leadsto z \cdot \color{blue}{\frac{z}{y \cdot -2}} \]
    10. Step-by-step derivation
      1. *-commutative79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{-2 \cdot y}} \]
      2. associate-/r*79.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 6 \cdot 10^{-215}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+37}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 1.32 \cdot 10^{+60}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+92} \lor \neg \left(z \leq 8 \cdot 10^{+133}\right) \land z \leq 9 \cdot 10^{+158}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 42.1% accurate, 0.3× 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 2.3 \cdot 10^{-214}:\\ \;\;\;\;\frac{x}{y\_m} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-14}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+40}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+60}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+91} \lor \neg \left(z \leq 3.8 \cdot 10^{+134}\right) \land z \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y\_m}\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= z 2.3e-214)
    (* (/ x y_m) (/ x 2.0))
    (if (<= z 1.02e-119)
      (* y_m 0.5)
      (if (<= z 2.7e-14)
        (/ (* x 0.5) (/ y_m x))
        (if (<= z 1.95e+32)
          (* y_m 0.5)
          (if (<= z 1.45e+40)
            (* x (* x (/ 0.5 y_m)))
            (if (<= z 2.85e+60)
              (* z (* z (/ -0.5 y_m)))
              (if (or (<= z 3.3e+91)
                      (and (not (<= z 3.8e+134)) (<= z 1.1e+158)))
                (* y_m 0.5)
                (* z (/ (/ z -2.0) y_m)))))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.3e-214) {
		tmp = (x / y_m) * (x / 2.0);
	} else if (z <= 1.02e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 2.7e-14) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (z <= 1.95e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 1.45e+40) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 2.85e+60) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 3.3e+91) || (!(z <= 3.8e+134) && (z <= 1.1e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 2.3d-214) then
        tmp = (x / y_m) * (x / 2.0d0)
    else if (z <= 1.02d-119) then
        tmp = y_m * 0.5d0
    else if (z <= 2.7d-14) then
        tmp = (x * 0.5d0) / (y_m / x)
    else if (z <= 1.95d+32) then
        tmp = y_m * 0.5d0
    else if (z <= 1.45d+40) then
        tmp = x * (x * (0.5d0 / y_m))
    else if (z <= 2.85d+60) then
        tmp = z * (z * ((-0.5d0) / y_m))
    else if ((z <= 3.3d+91) .or. (.not. (z <= 3.8d+134)) .and. (z <= 1.1d+158)) then
        tmp = y_m * 0.5d0
    else
        tmp = z * ((z / (-2.0d0)) / y_m)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.3e-214) {
		tmp = (x / y_m) * (x / 2.0);
	} else if (z <= 1.02e-119) {
		tmp = y_m * 0.5;
	} else if (z <= 2.7e-14) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (z <= 1.95e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 1.45e+40) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 2.85e+60) {
		tmp = z * (z * (-0.5 / y_m));
	} else if ((z <= 3.3e+91) || (!(z <= 3.8e+134) && (z <= 1.1e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if z <= 2.3e-214:
		tmp = (x / y_m) * (x / 2.0)
	elif z <= 1.02e-119:
		tmp = y_m * 0.5
	elif z <= 2.7e-14:
		tmp = (x * 0.5) / (y_m / x)
	elif z <= 1.95e+32:
		tmp = y_m * 0.5
	elif z <= 1.45e+40:
		tmp = x * (x * (0.5 / y_m))
	elif z <= 2.85e+60:
		tmp = z * (z * (-0.5 / y_m))
	elif (z <= 3.3e+91) or (not (z <= 3.8e+134) and (z <= 1.1e+158)):
		tmp = y_m * 0.5
	else:
		tmp = z * ((z / -2.0) / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (z <= 2.3e-214)
		tmp = Float64(Float64(x / y_m) * Float64(x / 2.0));
	elseif (z <= 1.02e-119)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 2.7e-14)
		tmp = Float64(Float64(x * 0.5) / Float64(y_m / x));
	elseif (z <= 1.95e+32)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 1.45e+40)
		tmp = Float64(x * Float64(x * Float64(0.5 / y_m)));
	elseif (z <= 2.85e+60)
		tmp = Float64(z * Float64(z * Float64(-0.5 / y_m)));
	elseif ((z <= 3.3e+91) || (!(z <= 3.8e+134) && (z <= 1.1e+158)))
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(z * Float64(Float64(z / -2.0) / y_m));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (z <= 2.3e-214)
		tmp = (x / y_m) * (x / 2.0);
	elseif (z <= 1.02e-119)
		tmp = y_m * 0.5;
	elseif (z <= 2.7e-14)
		tmp = (x * 0.5) / (y_m / x);
	elseif (z <= 1.95e+32)
		tmp = y_m * 0.5;
	elseif (z <= 1.45e+40)
		tmp = x * (x * (0.5 / y_m));
	elseif (z <= 2.85e+60)
		tmp = z * (z * (-0.5 / y_m));
	elseif ((z <= 3.3e+91) || (~((z <= 3.8e+134)) && (z <= 1.1e+158)))
		tmp = y_m * 0.5;
	else
		tmp = z * ((z / -2.0) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 2.3e-214], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.02e-119], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 2.7e-14], N[(N[(x * 0.5), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.95e+32], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 1.45e+40], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.85e+60], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 3.3e+91], And[N[Not[LessEqual[z, 3.8e+134]], $MachinePrecision], LessEqual[z, 1.1e+158]]], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(N[(z / -2.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.3 \cdot 10^{-214}:\\
\;\;\;\;\frac{x}{y\_m} \cdot \frac{x}{2}\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 2.7 \cdot 10^{-14}:\\
\;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\

\mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+40}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 2.85 \cdot 10^{+60}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 3.3 \cdot 10^{+91} \lor \neg \left(z \leq 3.8 \cdot 10^{+134}\right) \land z \leq 1.1 \cdot 10^{+158}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if z < 2.30000000000000011e-214

    1. Initial program 70.5%

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

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

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

        \[\leadsto {\color{blue}{\left(y \cdot \frac{2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}}^{-1} \]
      4. add-sqr-sqrt70.0%

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow270.0%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-170.0%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/70.4%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/35.7%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{2 \cdot y} \]
      3. *-commutative35.7%

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

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

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

    if 2.30000000000000011e-214 < z < 1.02e-119 or 2.6999999999999999e-14 < z < 1.95e32 or 2.84999999999999989e60 < z < 3.30000000000000017e91 or 3.79999999999999998e134 < z < 1.1000000000000001e158

    1. Initial program 63.7%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified66.9%

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

    if 1.02e-119 < z < 2.6999999999999999e-14

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-190.6%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/90.5%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/56.3%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{2 \cdot y} \]
      3. *-commutative56.4%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    11. Applied egg-rr56.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    12. Step-by-step derivation
      1. *-commutative56.3%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
      4. div-inv56.3%

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

        \[\leadsto \frac{x \cdot \color{blue}{0.5}}{\frac{y}{x}} \]
    13. Applied egg-rr56.3%

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

    if 1.95e32 < z < 1.45000000000000009e40

    1. Initial program 100.0%

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

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

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

        \[\leadsto {\color{blue}{\left(y \cdot \frac{2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}}^{-1} \]
      4. add-sqr-sqrt100.0%

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow2100.0%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-1100.0%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/100.0%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/100.0%

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

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

        \[\leadsto \color{blue}{\frac{1}{2 \cdot y} \cdot {x}^{2}} \]
      2. *-commutative100.0%

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \cdot {x}^{2} \]
      4. div-inv100.0%

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

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

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

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

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

    if 1.45000000000000009e40 < z < 2.84999999999999989e60

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

    if 3.30000000000000017e91 < z < 3.79999999999999998e134 or 1.1000000000000001e158 < z

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{z}{\frac{y}{-0.5}}} \]
      3. div-inv79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{y \cdot \frac{1}{-0.5}}} \]
      4. metadata-eval79.9%

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

      \[\leadsto z \cdot \color{blue}{\frac{z}{y \cdot -2}} \]
    10. Step-by-step derivation
      1. *-commutative79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{-2 \cdot y}} \]
      2. associate-/r*79.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.3 \cdot 10^{-214}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-119}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-14}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+32}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+40}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+60}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+91} \lor \neg \left(z \leq 3.8 \cdot 10^{+134}\right) \land z \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 42.2% accurate, 0.3× 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 5 \cdot 10^{-215}:\\ \;\;\;\;\frac{x}{y\_m} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-120}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-15}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+36}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{+65}:\\ \;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y\_m}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+92} \lor \neg \left(z \leq 2.05 \cdot 10^{+133}\right) \land z \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y\_m}\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= z 5e-215)
    (* (/ x y_m) (/ x 2.0))
    (if (<= z 8.6e-120)
      (* y_m 0.5)
      (if (<= z 6e-15)
        (/ (* x 0.5) (/ y_m x))
        (if (<= z 2e+32)
          (* y_m 0.5)
          (if (<= z 2.1e+36)
            (* x (* x (/ 0.5 y_m)))
            (if (<= z 2.65e+65)
              (/ (* z (* z -0.5)) y_m)
              (if (or (<= z 2.6e+92)
                      (and (not (<= z 2.05e+133)) (<= z 1.1e+158)))
                (* y_m 0.5)
                (* z (/ (/ z -2.0) y_m)))))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 5e-215) {
		tmp = (x / y_m) * (x / 2.0);
	} else if (z <= 8.6e-120) {
		tmp = y_m * 0.5;
	} else if (z <= 6e-15) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (z <= 2e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 2.1e+36) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 2.65e+65) {
		tmp = (z * (z * -0.5)) / y_m;
	} else if ((z <= 2.6e+92) || (!(z <= 2.05e+133) && (z <= 1.1e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 5d-215) then
        tmp = (x / y_m) * (x / 2.0d0)
    else if (z <= 8.6d-120) then
        tmp = y_m * 0.5d0
    else if (z <= 6d-15) then
        tmp = (x * 0.5d0) / (y_m / x)
    else if (z <= 2d+32) then
        tmp = y_m * 0.5d0
    else if (z <= 2.1d+36) then
        tmp = x * (x * (0.5d0 / y_m))
    else if (z <= 2.65d+65) then
        tmp = (z * (z * (-0.5d0))) / y_m
    else if ((z <= 2.6d+92) .or. (.not. (z <= 2.05d+133)) .and. (z <= 1.1d+158)) then
        tmp = y_m * 0.5d0
    else
        tmp = z * ((z / (-2.0d0)) / y_m)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 5e-215) {
		tmp = (x / y_m) * (x / 2.0);
	} else if (z <= 8.6e-120) {
		tmp = y_m * 0.5;
	} else if (z <= 6e-15) {
		tmp = (x * 0.5) / (y_m / x);
	} else if (z <= 2e+32) {
		tmp = y_m * 0.5;
	} else if (z <= 2.1e+36) {
		tmp = x * (x * (0.5 / y_m));
	} else if (z <= 2.65e+65) {
		tmp = (z * (z * -0.5)) / y_m;
	} else if ((z <= 2.6e+92) || (!(z <= 2.05e+133) && (z <= 1.1e+158))) {
		tmp = y_m * 0.5;
	} else {
		tmp = z * ((z / -2.0) / y_m);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if z <= 5e-215:
		tmp = (x / y_m) * (x / 2.0)
	elif z <= 8.6e-120:
		tmp = y_m * 0.5
	elif z <= 6e-15:
		tmp = (x * 0.5) / (y_m / x)
	elif z <= 2e+32:
		tmp = y_m * 0.5
	elif z <= 2.1e+36:
		tmp = x * (x * (0.5 / y_m))
	elif z <= 2.65e+65:
		tmp = (z * (z * -0.5)) / y_m
	elif (z <= 2.6e+92) or (not (z <= 2.05e+133) and (z <= 1.1e+158)):
		tmp = y_m * 0.5
	else:
		tmp = z * ((z / -2.0) / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (z <= 5e-215)
		tmp = Float64(Float64(x / y_m) * Float64(x / 2.0));
	elseif (z <= 8.6e-120)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 6e-15)
		tmp = Float64(Float64(x * 0.5) / Float64(y_m / x));
	elseif (z <= 2e+32)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 2.1e+36)
		tmp = Float64(x * Float64(x * Float64(0.5 / y_m)));
	elseif (z <= 2.65e+65)
		tmp = Float64(Float64(z * Float64(z * -0.5)) / y_m);
	elseif ((z <= 2.6e+92) || (!(z <= 2.05e+133) && (z <= 1.1e+158)))
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(z * Float64(Float64(z / -2.0) / y_m));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (z <= 5e-215)
		tmp = (x / y_m) * (x / 2.0);
	elseif (z <= 8.6e-120)
		tmp = y_m * 0.5;
	elseif (z <= 6e-15)
		tmp = (x * 0.5) / (y_m / x);
	elseif (z <= 2e+32)
		tmp = y_m * 0.5;
	elseif (z <= 2.1e+36)
		tmp = x * (x * (0.5 / y_m));
	elseif (z <= 2.65e+65)
		tmp = (z * (z * -0.5)) / y_m;
	elseif ((z <= 2.6e+92) || (~((z <= 2.05e+133)) && (z <= 1.1e+158)))
		tmp = y_m * 0.5;
	else
		tmp = z * ((z / -2.0) / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 5e-215], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.6e-120], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 6e-15], N[(N[(x * 0.5), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e+32], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 2.1e+36], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.65e+65], N[(N[(z * N[(z * -0.5), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], If[Or[LessEqual[z, 2.6e+92], And[N[Not[LessEqual[z, 2.05e+133]], $MachinePrecision], LessEqual[z, 1.1e+158]]], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(N[(z / -2.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{-215}:\\
\;\;\;\;\frac{x}{y\_m} \cdot \frac{x}{2}\\

\mathbf{elif}\;z \leq 8.6 \cdot 10^{-120}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 6 \cdot 10^{-15}:\\
\;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\

\mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 2.1 \cdot 10^{+36}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\

\mathbf{elif}\;z \leq 2.65 \cdot 10^{+65}:\\
\;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y\_m}\\

\mathbf{elif}\;z \leq 2.6 \cdot 10^{+92} \lor \neg \left(z \leq 2.05 \cdot 10^{+133}\right) \land z \leq 1.1 \cdot 10^{+158}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if z < 4.99999999999999956e-215

    1. Initial program 70.5%

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

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

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

        \[\leadsto {\color{blue}{\left(y \cdot \frac{2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}}^{-1} \]
      4. add-sqr-sqrt70.0%

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow270.0%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-170.0%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/70.4%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/35.7%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{2 \cdot y} \]
      3. *-commutative35.7%

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

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

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

    if 4.99999999999999956e-215 < z < 8.59999999999999964e-120 or 6e-15 < z < 2.00000000000000011e32 or 2.65000000000000011e65 < z < 2.5999999999999999e92 or 2.05000000000000002e133 < z < 1.1000000000000001e158

    1. Initial program 63.7%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified66.9%

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

    if 8.59999999999999964e-120 < z < 6e-15

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-190.6%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/90.5%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/56.3%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{2 \cdot y} \]
      3. *-commutative56.4%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    11. Applied egg-rr56.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    12. Step-by-step derivation
      1. *-commutative56.3%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
      4. div-inv56.3%

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

        \[\leadsto \frac{x \cdot \color{blue}{0.5}}{\frac{y}{x}} \]
    13. Applied egg-rr56.3%

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

    if 2.00000000000000011e32 < z < 2.10000000000000004e36

    1. Initial program 100.0%

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

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

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

        \[\leadsto {\color{blue}{\left(y \cdot \frac{2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}}^{-1} \]
      4. add-sqr-sqrt100.0%

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow2100.0%

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-1100.0%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/100.0%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/100.0%

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

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

        \[\leadsto \color{blue}{\frac{1}{2 \cdot y} \cdot {x}^{2}} \]
      2. *-commutative100.0%

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\frac{1}{0.5}}} \cdot {x}^{2} \]
      4. div-inv100.0%

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

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

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

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

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

    if 2.10000000000000004e36 < z < 2.65000000000000011e65

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5999999999999999e92 < z < 2.05000000000000002e133 or 1.1000000000000001e158 < z

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{z}{\frac{y}{-0.5}}} \]
      3. div-inv79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{y \cdot \frac{1}{-0.5}}} \]
      4. metadata-eval79.9%

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

      \[\leadsto z \cdot \color{blue}{\frac{z}{y \cdot -2}} \]
    10. Step-by-step derivation
      1. *-commutative79.9%

        \[\leadsto z \cdot \frac{z}{\color{blue}{-2 \cdot y}} \]
      2. associate-/r*79.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5 \cdot 10^{-215}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-120}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-15}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+36}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{+65}:\\ \;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+92} \lor \neg \left(z \leq 2.05 \cdot 10^{+133}\right) \land z \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{\frac{z}{-2}}{y}\\ \end{array} \]
  5. Add Preprocessing

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

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

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


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

    1. Initial program 78.9%

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

    if 3.65e121 < y

    1. Initial program 18.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{{y}^{2} - {z}^{2}}{y}} \]
    6. Step-by-step derivation
      1. div-sub21.4%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 73.7% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{{y}^{2} - {z}^{2}}{y}} \]
    6. Step-by-step derivation
      1. div-sub49.2%

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{y \cdot \frac{y}{y}} - \frac{{z}^{2}}{y}\right) \]
      4. *-inverses67.5%

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

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

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

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

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

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

    if 1.25e172 < x

    1. Initial program 53.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-153.3%

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/53.3%

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{y}{{x}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/61.8%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
    10. Step-by-step derivation
      1. clear-num61.8%

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{2 \cdot y} \]
      3. *-commutative61.8%

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

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    12. Step-by-step derivation
      1. *-commutative67.8%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
      4. div-inv67.9%

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

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

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

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

Alternative 9: 44.1% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 70.8%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified38.3%

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

    if 4.79999999999999966e91 < z

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 44.1% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 70.8%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified38.3%

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

    if 1.10000000000000011e93 < z

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{z}{\frac{y}{-0.5}}} \]
      3. div-inv72.6%

        \[\leadsto z \cdot \frac{z}{\color{blue}{y \cdot \frac{1}{-0.5}}} \]
      4. metadata-eval72.6%

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

      \[\leadsto z \cdot \color{blue}{\frac{z}{y \cdot -2}} \]
    10. Step-by-step derivation
      1. *-commutative72.6%

        \[\leadsto z \cdot \frac{z}{\color{blue}{-2 \cdot y}} \]
      2. associate-/r*72.6%

        \[\leadsto z \cdot \color{blue}{\frac{\frac{z}{-2}}{y}} \]
    11. Simplified72.6%

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

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

Alternative 11: 35.4% accurate, 5.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \left(y\_m \cdot 0.5\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) 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 69.3%

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

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

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

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

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

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024078 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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